Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Caml Light 0.8 and -fstrict-aliasing build issue
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-07-20 (12:58)
From: Alexis ROBERT <alexis.robert@g...>
Subject: Caml Light 0.8 and -fstrict-aliasing build issue

As the MPSI programme force us to use Caml Light instead of OCaml (our 
teachers hit us each time we pronounce ocaml :) ), I tried to build the 
sources on my computer, but during the build, I got this :

make[1]: Entering directory `/home/alexis/camllight/src/lib'
../camlrun ../camlcomp -stdlib . -O none -g -W string.mli
make[1]: *** [string.zi] Segmentation fault

More precisely, gdb told me that :

(gdb) run ../camlcomp -stdlib . -O none -g -W string.mli
Starting program: /home/alexis/camllight/src/camlrun ../camlcomp -stdlib 
. -O none -g -W arg.mli

Program received signal SIGSEGV, Segmentation fault.
interprete (prog=0xe0e960 "\006\016") at interp.c:508
508          cur_instr = *pc++; <= In the real source code, that's Next; 
I changed it with the macro content for more lisibility :)
(gdb) info locals
pc = (code_t) 0x9 <Address 0x9 out of bounds>
cur_instr = <value optimized out>

The reason of the segfaults seems to be linked with -fstrict-aliasing 
(included in -O2, I discovered it when disabling gcc optimizations to 
get cur_instr value). In fact, the weird thing is that pc pointer 
suddently decreases to 0x09, which doesn't seem to be a very sweet 
memory address, and causes a segfault in the Next macro when it 
deferences pc.

I've tried to follow pc using a watchpoint before the magic change, but 
it disables the watchpoint every time it reaches a segment of code where 
pc is not defined which makes the debugging process *very* annoying :)

A workaround would be to use OPTS="-fno-strict-aliasing" in 
runtime/Makefile line 5, but I don't know if it's very clean (or to 
disable direct jumping but that's even worse :D ).

My computer is running Ubuntu 9.04 with gcc 4.3.3 and a x86_64 cpu (I 
used the CVS version of caml light). It _MAY_ be a x86_64 only issue as 
I vaguely remember a friend having the same configuration as mine using 
Ubuntu x86 who has successfully built caml light, but I may have forgot 
some details.

Thanks !