------- Comment #5 from oblivian at users dot sourceforge dot net 2008-04-03 01:40 ------- Is this something special in the compiler specs for libc?
I created this test file conftest.c #include <stdio.h> int testing_lib() { printf("hello world!\n"); return 0; } And ran a scaled down libgcc command with the stage 1 compiler: /media/disk/build/scripts/tools/toolchain-pass-1/build/./gcc/xgcc -B/media/disk/build/scripts/tools/toolchain-pass-1/build/./gcc/ -B/tools/usr/i686-pc-linux-gnu/bin/ -B/tools/usr/i686-pc-linux-gnu/lib/ -isystem /tools/usr/i686-pc-linux-gnu/include -isystem /tools/usr/i686-pc-linux-gnu/sys-include -L/media/disk/build/scripts/tools/toolchain-pass-1/build/./ld -O2 -O2 -g -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -o ./conftest.so.1.tmp conftest.c -lm -lc ------------------------------------------------------------------------------ conftest.c:4: warning: function declaration isn't a prototype conftest.c: In function 'testing_lib': conftest.c:4: warning: old-style function definition /media/disk/build/scripts/tools/toolchain-pass-1/build/gcc/../ld/ld-new: cannot find /tools/lib/libc.so.6 inside /tools collect2: ld returned 1 exit status ------------------------------------------------------------------------------ Now running the same command without -lc ------------------------------------------------------------------------------ /media/disk/build/scripts/tools/toolchain-pass-1/build/./gcc/xgcc -B/media/disk/build/scripts/tools/toolchain-pass-1/build/./gcc/ -B/tools/usr/i686-pc-linux-gnu/bin/ -B/tools/usr/i686-pc-linux-gnu/lib/ -isystem /tools/usr/i686-pc-linux-gnu/include -isystem /tools/usr/i686-pc-linux-gnu/sys-include -L/media/disk/build/scripts/tools/toolchain-pass-1/build/./ld -O2 -O2 -g -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -o ./conftest.so.1.tmp conftest.c -lm conftest.c:4: warning: function declaration isn't a prototype conftest.c: In function 'testing_lib': conftest.c:4: warning: old-style function definition ------------------------------------------------------------------------------- Despite the warnings it creates the shared library file and running ldd conftest.so.1.tmp linux-gate.so.1 => (0xb7eec000) libm.so.6 => /tools/lib/libm.so.6 (0xb7ebf000) /tools/lib/ld-linux.so.2 (0xb7eed000) libc.so.6 => /tools/lib/libc.so.6 (0xb7d94000) The new file not only is linked with the correct libm, but also libc???? Where is this special handling of -lc? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35804