Subject: USE_SSP=yes on netbsd-4 doesn't work with -static
To: NetBSD Toolchain and Build Technical Discussion List <tech-toolchain@NetBSD.org>
From: Greg A. Woods <woods@planix.com>
List: netbsd-users
Date: 02/19/2007 17:41:25
USE_SSP=yes on netbsd-4 doesn't work with -static:

#      link  bc/bc
/build/woods/once/netbsd-4-i386-i386-tools/bin/i386--netbsdelf-gcc -O2 -g -pipe  -fstack-protector -Wstack-protector --param ssp-buffer-size=1  -Werror -O2 -Wl,-nostdlib    -static -o bc   -B/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/ -B/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/   bc.o execute.o global.o load.o main.o number.o scan.o storage.o util.o -ll -ledit -ltermcap   -L/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib -L/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib
/build/woods/once/netbsd-4-i386-i386-tools/lib/gcc/i386--netbsdelf/4.1.2/../../../../i386--netbsdelf/bin/ld: cannot find -lssp_nonshared
collect2: ld returned 1 exit status

It looks like the gcc wrapper is adding an extra, unnecessary, and
incorrect,'-l' name when invoking ld since there are what would seem to
be suitable libssp.* files available already in the $DESTDIR:

$ l /build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/libssp*
/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/libssp.a
/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/libssp.so@
/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/libssp.so.0@
/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/libssp.so.0.0
/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/libssp_p.a
/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/libssp_pic.a


If I run the 'collect2' invocation by hand (in the $OBJDIR), removing
the extraneous '-lssp_noshared' parameter, then the link succeeds
without error:

$ cd gnu/usr.bin/bc
$ cdobj
/build/woods/once/netbsd-4-i386-i386-ppro-obj/usr/src/gnu/usr.bin/bc
$ /build/woods/once/netbsd-4-i386-i386-tools/libexec/gcc/i386--netbsdelf/4.1.2/collect2 -dc -dp -e __start -static -o bc /build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/crt0.o /build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/crti.o /build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/crtbeginT.o -L/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib -L/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib -L/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib -L/build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib -L/build/woods/once/netbsd-4-i386-i386-tools/lib/gcc/i386--netbsdelf/4.1.2 -L/build/woods/once/netbsd-4-i386-i386-tools/lib/gcc/i386--netbsdelf/4.1.2/../../../../i386--netbsdelf/lib -nostdlib bc.o execute.o global.o load.o main.o number.o scan.o storage.o util.o -ll -ledit -ltermcap -lssp -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/crtend.o /build/woods/once/netbsd-4-i386-ppro-destdir/usr/lib/crtn.o
$ file bc
bc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for NetBSD 4.0, statically linked, not stripped
$ size bc 
   text    data     bss     dec     hex filename
 322881    6220   20788  349889   556c1 bc
$ ./bc 
1+1
2


-- 
						Greg A. Woods

H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>       Secrets of the Weird <woods@weird.com>