static linking

Alexandre Oliva oliva at dcc.unicamp.br
Sun Apr 11 14:25:56 PDT 1999


On Apr 11, 1999, Kiyo Inaba <inaba at src.ricoh.co.jp> wrote:

> Still libtool tries to link with ltdl.lo rather than with ltdl.o when
> I did not specify '--disable-shared'.

Yup, this is even documented in kaffe/FAQ/FAQ.libtool.
--with-staticvm and --with-staticlib are Kaffe-specific flags, that do 
not affect libltdl at all.  --disable-shared is for all
libtool-generated libraries, so it ends up causing libltdl to be
static too.

> Xgcc -g -Wall -Wstrict-prototypes -L/usr/local/lib -o Kaffe main.o .libs/KaffeS.o ../../libraries/clib/native/.libs/libnative.a -lm ../../libraries/clib/net/.libs/libnet.a ../../libraries/clib/io/.libs/libio.a ../../libraries/clib/zip/.libs/libzip.a -lz ../../libraries/clib/math/.libs/libmath.a -lm ../../libraries/clib/management/.libs/libmanagement.a ../kaffevm/.libs/libkaffevm.a -lgcc -lm
> Xld: symbol __GLOBAL_OFFSET_TABLE_ remains undefined

This smells very much like a bug in FreeBSD's ld that libtool had to
work around.  Considering that FreeBSD and NetBSD share common roots,
it doesn't sound surprising to me :-(

In the generated libtool script (or in ltmain.sh, if you prefer),
you'll find the following case statement:

	  case "$host" in
	  # compiling the symbol table file with pic_flag works around
	  # a FreeBSD bug that causes programs to crash when -lm is
	  # linked before any other PIC object.  But we must not use
	  # pic_flag when linking with -static.  The problem exists in
	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
	  *-*-freebsd2*|*-*-freebsd3.0*)
	    case "$compile_command " in
	    *" -static "*) ;;
	    *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
	    esac
	  esac

Please try:

	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-netbsd*)

instead of:

	  *-*-freebsd2*|*-*-freebsd3.0*)

Please tell me if it works, so that I can introduce this work-around
in libtool and Kaffe.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Brasil
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists



More information about the kaffe mailing list