caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Re: ocaml 3.12.1 and delimcc
@ 2012-10-16  7:06 oleg
  2012-10-16 14:59 ` Anthony Tavener
  0 siblings, 1 reply; 6+ messages in thread
From: oleg @ 2012-10-16  7:06 UTC (permalink / raw)
  To: christophe.raffalli; +Cc: caml-list


It so happened that I had to upgrade to amd64 (Intel Core 2) last
week. I have installed FreeBSD 9.0 from scratch and OCaml 3.12.1 
from ports. I have just recompiled delimcc. All tests passed,
both for byte-code and the native compiler.

I'm really not sure what the reported problem might be. I have used
the following line in delimcc's Makefile
	OCAMLINCLUDES=./ocaml-byterun-3.11
That OCAMLINCLUDES worked with 3.12.0 (and with 3.12.1, it seems). I'm
not sure if it works with 4.x though.

Could you check your Makefile? Could you check that 
	$(LIBDIR)/Makefile.config
has sane values, where
	LIBDIR := $(shell ocamlc -where)
If you have several versions of OCaml on your system, it could be that
delimcc's Makefile picks a wrong version (inconsistent with
OCAMLINCLUDES). Such an inconsistency could certainly cause a
segfault.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Re: ocaml 3.12.1 and delimcc
  2012-10-16  7:06 [Caml-list] Re: ocaml 3.12.1 and delimcc oleg
@ 2012-10-16 14:59 ` Anthony Tavener
  2012-10-19  2:20   ` oleg
  0 siblings, 1 reply; 6+ messages in thread
From: Anthony Tavener @ 2012-10-16 14:59 UTC (permalink / raw)
  To: oleg; +Cc: christophe.raffalli, caml-list

[-- Attachment #1: Type: text/plain, Size: 1963 bytes --]

Thank-you Oleg, for limiting my hunt for a red-herring. :) I only looked
through the web-svn changes to 3.12.1 and nothing stood out as a
problematic change... I should have installed 3.12.1 to try it out.

With 4.00.0 (and this is a new machine with no prior installs) I pulled the
corresponding files from 4.0 source into an ocaml-byterun-4.00 directory,
and the native test segfaults. Just now I tried pointing to the 3.11
directory and it also segfaults. I expect going to 4.x there's been a
change of some significance for delimcc.

I'm not using GADTs or other 4.x features yet, and delimcc is more
important to me -- so I'm happy enough using 3.12 while casually prodding
at delimcc+4.x.

 -Tony

P.S. Thanks for the nifty gadgets! (I keep eyeing metaocaml too...)


On Tue, Oct 16, 2012 at 1:06 AM, <oleg@okmij.org> wrote:

>
> It so happened that I had to upgrade to amd64 (Intel Core 2) last
> week. I have installed FreeBSD 9.0 from scratch and OCaml 3.12.1
> from ports. I have just recompiled delimcc. All tests passed,
> both for byte-code and the native compiler.
>
> I'm really not sure what the reported problem might be. I have used
> the following line in delimcc's Makefile
>         OCAMLINCLUDES=./ocaml-byterun-3.11
> That OCAMLINCLUDES worked with 3.12.0 (and with 3.12.1, it seems). I'm
> not sure if it works with 4.x though.
>
> Could you check your Makefile? Could you check that
>         $(LIBDIR)/Makefile.config
> has sane values, where
>         LIBDIR := $(shell ocamlc -where)
> If you have several versions of OCaml on your system, it could be that
> delimcc's Makefile picks a wrong version (inconsistent with
> OCAMLINCLUDES). Such an inconsistency could certainly cause a
> segfault.
>
>
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 2716 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Re: ocaml 3.12.1 and delimcc
  2012-10-16 14:59 ` Anthony Tavener
@ 2012-10-19  2:20   ` oleg
  2012-10-19 10:35     ` Gabriel Kerneis
  0 siblings, 1 reply; 6+ messages in thread
From: oleg @ 2012-10-19  2:20 UTC (permalink / raw)
  To: anthony.tavener; +Cc: christophe.raffalli, caml-list


Many thanks to Christophe Raffalli for investigating the problem. It
turns out, the problem lies in GCC, which is used to compile a small
bit of C code in delimcc. As Christophe Raffalli reports, GCC versions
4.4 and 4.6 (and, I add, 4.2.1 -- the version used in FreeBSD) are not
problematic. However, when GCC 4.7 compiles the C portion of delimcc,
testd0opt gives a segfault. 

The stacks-native.c file in delimcc does rely on alloca and depends on
the absence of tail-call optimization. One function is written in a
way to defeat the optimization; alas, GCC may be to clever to optimize
the counter-measure away. Well, C only roughly fits the role of the
portable assembler. I don't have GCC 4.7 readily available and can't
offer an immediate fix. It is worth playing with optimization flags,
and set -O0, for instance, when compiling stacks-native.c. I'll see if
I could find a pragma or other way to disable undesirable
optimizations.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Re: ocaml 3.12.1 and delimcc
  2012-10-19  2:20   ` oleg
@ 2012-10-19 10:35     ` Gabriel Kerneis
  2012-10-20 17:25       ` Anthony Tavener
  2012-10-26  3:47       ` Anthony Tavener
  0 siblings, 2 replies; 6+ messages in thread
From: Gabriel Kerneis @ 2012-10-19 10:35 UTC (permalink / raw)
  To: oleg; +Cc: anthony.tavener, christophe.raffalli, caml-list

On Fri, Oct 19, 2012 at 02:20:56AM -0000, oleg@okmij.org wrote:
> I'll see if I could find a pragma or other way to disable undesirable
> optimizations.

No tested, but you could try -fno-optimize-sibling-calls:
$ gcc --help=optimizers|grep "tail recursive"
  -foptimize-sibling-calls    Optimize sibling and tail recursive calls

Best,
-- 
Gabriel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Re: ocaml 3.12.1 and delimcc
  2012-10-19 10:35     ` Gabriel Kerneis
@ 2012-10-20 17:25       ` Anthony Tavener
  2012-10-26  3:47       ` Anthony Tavener
  1 sibling, 0 replies; 6+ messages in thread
From: Anthony Tavener @ 2012-10-20 17:25 UTC (permalink / raw)
  To: Gabriel Kerneis; +Cc: oleg, christophe.raffalli, caml-list

[-- Attachment #1: Type: text/plain, Size: 752 bytes --]

I set the Makefile rule for stacks-native to use -O0
-fno-optimize-sibling-calls, but testd0opt still segfaults. I also tried
with only -O0.

My GCC version is 4.7.1; architecture is amd64.

Checking output with -S, "push_stack_fragment_really" is not inlined. Is
there anything I can check/report?


On Fri, Oct 19, 2012 at 4:35 AM, Gabriel Kerneis <kerneis@pps.jussieu.fr>wrote:

> On Fri, Oct 19, 2012 at 02:20:56AM -0000, oleg@okmij.org wrote:
> > I'll see if I could find a pragma or other way to disable undesirable
> > optimizations.
>
> No tested, but you could try -fno-optimize-sibling-calls:
> $ gcc --help=optimizers|grep "tail recursive"
>   -foptimize-sibling-calls    Optimize sibling and tail recursive calls
>
> Best,
> --
> Gabriel
>

[-- Attachment #2: Type: text/html, Size: 1244 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Re: ocaml 3.12.1 and delimcc
  2012-10-19 10:35     ` Gabriel Kerneis
  2012-10-20 17:25       ` Anthony Tavener
@ 2012-10-26  3:47       ` Anthony Tavener
  1 sibling, 0 replies; 6+ messages in thread
From: Anthony Tavener @ 2012-10-26  3:47 UTC (permalink / raw)
  To: Gabriel Kerneis; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 803 bytes --]

It turns out there is one specific optimization to disable with gcc 4.7.x:
 -fno-ipa-sra

So stacks-native.c can be compiled with -O2 -fno-ipa-sra.

The reason I continued to have a problem even after -O0, as Oleg found
out, is that testd0opt would link to my bad system-installed library
rather than the new one in the current directory. *facepalm*


On Fri, Oct 19, 2012 at 4:35 AM, Gabriel Kerneis <kerneis@pps.jussieu.fr>wrote:

> On Fri, Oct 19, 2012 at 02:20:56AM -0000, oleg@okmij.org wrote:
> > I'll see if I could find a pragma or other way to disable undesirable
> > optimizations.
>
> No tested, but you could try -fno-optimize-sibling-calls:
> $ gcc --help=optimizers|grep "tail recursive"
>   -foptimize-sibling-calls    Optimize sibling and tail recursive calls
>
> Best,
> --
> Gabriel
>

[-- Attachment #2: Type: text/html, Size: 1337 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-26  3:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-16  7:06 [Caml-list] Re: ocaml 3.12.1 and delimcc oleg
2012-10-16 14:59 ` Anthony Tavener
2012-10-19  2:20   ` oleg
2012-10-19 10:35     ` Gabriel Kerneis
2012-10-20 17:25       ` Anthony Tavener
2012-10-26  3:47       ` Anthony Tavener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).