|
Message-ID: <20180509112932.1a3176b0@windsurf.home> Date: Wed, 9 May 2018 11:29:32 +0200 From: Thomas Petazzoni <thomas.petazzoni@...tlin.com> To: Rich Felker <dalias@...c.org> Cc: musl@...ts.openwall.com Subject: Re: undefined reference to `raise' with musl static toolchain Hello, On Tue, 8 May 2018 12:34:23 -0400, Rich Felker wrote: > > It would appear that your version of libgcc references libc. Now, with > > static linking, the libraries must appear in the correct order to > > satisfy all dependencies, but here you have a circular dependency between > > libgcc and libc. Since all gcc compiled code depends on libgcc, and libc > > is compiled with gcc, there are only two ways to break the cycle: > > > > 1. Remove the dependency. No idea how, not unless you basically inline > > raise() into __aeabi_idiv0(). > > > > 2. Add libc again after the command line. > > gcc already does this if you pass -static. I suspect the issue is that > Thomas is using a toolchain where gcc doesn't know it's > static-linking, and ld only static-links because there's no libc.so > present. This setup is highly fragile and afaik it's not intended by > the gcc developers to work. I don't know if there's anything like > --enable-default-static for gcc but that would be the right solution > for a static-only toolchain I think. Indeed, passing -static explicitly fixes the problem. Without -static: test@...ld:~/buildroot$ ./output/host/bin/arm-linux-gcc -o foo foo.c -v Using built-in specs. COLLECT_GCC=/home/test/buildroot/output/host/bin/arm-linux-gcc.br_real COLLECT_LTO_WRAPPER=/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/lto-wrapper Target: arm-buildroot-linux-musleabihf Configured with: ./configure --prefix=/home/test/buildroot/output/host --sysconfdir=/home/test/buildroot/output/host/etc --enable-static --target=arm-buildroot-linux-musleabihf --with-sysroot=/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --with-gmp=/home/test/buildroot/output/host --with-mpc=/home/test/buildroot/output/host --with-mpfr=/home/test/buildroot/output/host --with-pkgversion='Buildroot 2018.05-git-01130-gd007bca' --with-bugurl=http://bugs.buildroot.net/ --disable-libmpx --disable-libquadmath --disable-libsanitizer --enable-tls --disable-libmudflap --enable-threads --without-isl --without-cloog --disable-decimal-float --with-abi=aapcs-linux --with-cpu=cortex-a8 --with-fpu=vfpv3-d16 --with-float=hard --with-mode=arm --enable-languages=c,c++ --with-build-time-tools=/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/bin --disable-shared --disable-libcilkrts --disable -libgomp Thread model: posix gcc version 6.4.0 (Buildroot 2018.05-git-01130-gd007bca) COLLECT_GCC_OPTIONS='-o' 'foo' '-v' '-mcpu=cortex-a8' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu' /home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/cc1 -quiet -v -isysroot /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot foo.c -quiet -dumpbase foo.c -mcpu=cortex-a8 -mfloat-abi=hard -mfpu=vfpv3-d16 -mabi=aapcs-linux -marm -mtls-dialect=gnu -auxbase foo -version -o /tmp/cc9R8ARE.s GNU C11 (Buildroot 2018.05-git-01130-gd007bca) version 6.4.0 (arm-buildroot-linux-musleabihf) compiled by GNU C version 4.7.2, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/usr/local/include" #include "..." search starts here: #include <...> search starts here: /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/include /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/usr/include /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/include End of search list. GNU C11 (Buildroot 2018.05-git-01130-gd007bca) version 6.4.0 (arm-buildroot-linux-musleabihf) compiled by GNU C version 4.7.2, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 4fc01250e8946128cafb87416e07c618 foo.c: In function 'main': foo.c:1:18: warning: implicit declaration of function 'mktime' [-Wimplicit-function-declaration] int main(void) { mktime(); return 0; } ^~~~~~ COLLECT_GCC_OPTIONS='-o' 'foo' '-v' '-mcpu=cortex-a8' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu' /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/bin/as -v -mcpu=cortex-a8 -mfloat-abi=hard -mfpu=vfpv3-d16 -meabi=5 -o /tmp/ccIJ7oOn.o /tmp/cc9R8ARE.s GNU assembler version 2.29.1 (arm-buildroot-linux-musleabihf) using BFD version (GNU Binutils) 2.29.1 COMPILER_PATH=/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/:/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/:/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/:/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/:/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/:/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/bin/ LIBRARY_PATH=/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/:/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/lib/:/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib/:/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/usr/lib/ COLLECT_GCC_OPTIONS='-o' 'foo' '-v' '-mcpu=cortex-a8' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu' /home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/collect2 -plugin /home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/liblto_plugin.so -plugin-opt=/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccHzI6L6.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc --sysroot=/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot --eh-frame-hdr -dynamic-linker /lib/ld-musl-armhf.so.1 -X -m armelf_linux_eabi -o foo /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib/crt1.o /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib/crti.o /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/crtbegin.o -L/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0 -L/home/test/buildroot/output/host/lib/gcc/arm-buildr oot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/lib -L/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib -L/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/usr/lib /tmp/ccIJ7oOn.o -lgcc -lc -lgcc /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/crtend.o /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib/crtn.o /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/libgcc.a(_dvmd_lnx.o): In function `__aeabi_idiv0': /home/test/buildroot/output/build/host-gcc-final-6.4.0/build/arm-buildroot-linux-musleabihf/libgcc/../../../libgcc/config/arm/lib1funcs.S:1354: undefined reference to `raise' collect2: error: ld returned 1 exit status With -static: test@...ld:~/buildroot$ ./output/host/bin/arm-linux-gcc -o foo foo.c -static -v Using built-in specs. COLLECT_GCC=/home/test/buildroot/output/host/bin/arm-linux-gcc.br_real COLLECT_LTO_WRAPPER=/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/lto-wrapper Target: arm-buildroot-linux-musleabihf Configured with: ./configure --prefix=/home/test/buildroot/output/host --sysconfdir=/home/test/buildroot/output/host/etc --enable-static --target=arm-buildroot-linux-musleabihf --with-sysroot=/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --with-gmp=/home/test/buildroot/output/host --with-mpc=/home/test/buildroot/output/host --with-mpfr=/home/test/buildroot/output/host --with-pkgversion='Buildroot 2018.05-git-01130-gd007bca' --with-bugurl=http://bugs.buildroot.net/ --disable-libmpx --disable-libquadmath --disable-libsanitizer --enable-tls --disable-libmudflap --enable-threads --without-isl --without-cloog --disable-decimal-float --with-abi=aapcs-linux --with-cpu=cortex-a8 --with-fpu=vfpv3-d16 --with-float=hard --with-mode=arm --enable-languages=c,c++ --with-build-time-tools=/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/bin --disable-shared --disable-libcilkrts --disable -libgomp Thread model: posix gcc version 6.4.0 (Buildroot 2018.05-git-01130-gd007bca) COLLECT_GCC_OPTIONS='-o' 'foo' '-static' '-v' '-mcpu=cortex-a8' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu' /home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/cc1 -quiet -v -isysroot /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot foo.c -quiet -dumpbase foo.c -mcpu=cortex-a8 -mfloat-abi=hard -mfpu=vfpv3-d16 -mabi=aapcs-linux -marm -mtls-dialect=gnu -auxbase foo -version -o /tmp/ccAsjDgp.s GNU C11 (Buildroot 2018.05-git-01130-gd007bca) version 6.4.0 (arm-buildroot-linux-musleabihf) compiled by GNU C version 4.7.2, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/usr/local/include" #include "..." search starts here: #include <...> search starts here: /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/include /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/usr/include /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/include End of search list. GNU C11 (Buildroot 2018.05-git-01130-gd007bca) version 6.4.0 (arm-buildroot-linux-musleabihf) compiled by GNU C version 4.7.2, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 4fc01250e8946128cafb87416e07c618 foo.c: In function 'main': foo.c:1:18: warning: implicit declaration of function 'mktime' [-Wimplicit-function-declaration] int main(void) { mktime(); return 0; } ^~~~~~ COLLECT_GCC_OPTIONS='-o' 'foo' '-static' '-v' '-mcpu=cortex-a8' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu' /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/bin/as -v -mcpu=cortex-a8 -mfloat-abi=hard -mfpu=vfpv3-d16 -meabi=5 -o /tmp/ccx5VIfD.o /tmp/ccAsjDgp.s GNU assembler version 2.29.1 (arm-buildroot-linux-musleabihf) using BFD version (GNU Binutils) 2.29.1 COMPILER_PATH=/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/:/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/:/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/:/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/:/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/:/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/bin/ LIBRARY_PATH=/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/:/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/lib/:/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib/:/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/usr/lib/ COLLECT_GCC_OPTIONS='-o' 'foo' '-static' '-v' '-mcpu=cortex-a8' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu' /home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/collect2 -plugin /home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/liblto_plugin.so -plugin-opt=/home/test/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/6.4.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccEXBDfR.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc --sysroot=/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot -Bstatic -X -m armelf_linux_eabi -o foo /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib/crt1.o /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib/crti.o /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/crtbeginT.o -L/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0 -L/home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/../../../../arm-buildroot-linux-musleabihf/lib -L/ home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib -L/home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/usr/lib /tmp/ccx5VIfD.o --start-group -lgcc -lc --end-group /home/test/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/6.4.0/crtend.o /home/test/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot/lib/crtn.o COLLECT_GCC_OPTIONS='-o' 'foo' '-static' '-v' '-mcpu=cortex-a8' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu' Does this means we *must* pass -static, even if the toolchain only has the static variant of the C library ? I'm doing a build to confirm, but I don't think we have the same requirement with uClibc-ng. Best regards, Thomas -- Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.