[Cmake] Re: command to build dynamic lib changed causing my VXL build to break

Peter Vanroose Peter . Vanroose at esat . kuleuven . ac . be
Sun, 13 Jan 2002 10:47:02 +0100 (CET)


> constructors of static data, etc).  The -shared option tells the compiler
> to put in the proper init code, and automatically causes it to pass the -G
> option on to the linker.

Try adding "-v" on the compile (link) line to see what gcc really does.

I've had similar problems on solaris, but in my case it was because of a
missing "-nostdlib".   In that case, it's exactly in the call to the global
destructors that the program crash occurs:

gdb test_vcl_compiler
(gdb) r
0
1

Program received signal SIGSEGV, Segmentation fault.
0xef293558 in __do_global_dtors_aux () from libvcl.so

which seemed to suggest that the problem lies in the extra
global ctors/dtors which "-shared" adds.
But when I use "-Wl,-G" instead of "-shared", it's the same.

The former does
collect2 -V -Y P,/usr/ccs/lib:/usr/lib -Qy /gcc/.../crt1.o \
/gcc/.../crti.o /usr/ccs/lib/values-Xa.o /gcc/.../crtbegin.o \
-L... -G *.o -lgcc -lc -lgcc /gcc/.../crtend.o /gcc/.../crtn.o

while the latter does:
collect2 -V -G -dy -z text -Y P,/usr/ccs/lib:/usr/lib -Qy \
/gcc/.../crti.o /usr/ccs/lib/values-Xa.o /gcc/.../crtbegin.o \
-L... *.o -lgcc_s -lgcc -lgcc_s -lgcc /gcc/.../crtend.o /gcc/.../crtn.o


Now the problem (at least here) is with the -lgcc, because when
I remove all -l... from the collect2 line, the shared library is
less than half as large, and the program runs OK!

But strange enough, when I use  -nostdlib  (either with -shared
or -Wl,-G) also all the crt*.o disappear from the link line.
Is this correct behaviour?
Anyhow, most programs runs OK in both cases, but I've seen problems
with std::vector initialisation, in both cases.


--	Peter.