https://bugzilla.gdcproject.org/show_bug.cgi?id=289
Bug ID: 289 Summary: Static linking has wrong libc/libpthread order Product: GDC Version: 7.x Hardware: All OS: All Status: NEW Severity: major Priority: Normal Component: gdc Assignee: ibuc...@gdcproject.org Reporter: ste...@schuerger.com When compiling a little "helloworld" program with an ARM GDC cross-compiler toolchain, I encounter a symbol error: $ arm-linux-gnueabihf-gdc helloworld.o -o helloworld.arm -static /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/libgphobos.a(stdio.o): In function `_D3std5stdio11openNetworkFAyatZS3std5stdio4File': /home/stefan/src-gcc/build/build-gcc/arm-linux-gnueabihf/libphobos/src/../../../../gcc-7.3.0/libphobos/src/std/stdio.d:5122: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/libpthread.a(lowlevellock.o): In function `__lll_lock_wait_private': /home/stefan/src-gcc/build/glibc-2.27/nptl/lowlevellock.c:28: multiple definition of `__lll_lock_wait_private' /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/libc.a(libc-lowlevellock.o):/home/stefan/src-gcc/build/glibc-2.27/nptl/./lowlevellock.c:28: first defined here collect2: error: ld returned 1 exit status -v shows glibc is linked before libpthread, that's wrong: ... /opt/cross/libexec/gcc/arm-linux-gnueabihf/7.3.0/collect2 -plugin /opt/cross/libexec/gcc/arm-linux-gnueabihf/7.3.0/liblto_plugin.so -plugin-opt=/opt/cross/libexec/gcc/arm-linux-gnueabihf/7.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccWgyAkd.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ldl -Bstatic -X -m armelf_linux_eabi -o helloworld.arm /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/crt1.o /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/crti.o /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/crtbeginT.o -L/opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0 -L/opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib helloworld.o -lgphobos -lgdruntime --start-group -lgcc -lgcc_eh -lc -lm -lpthread -ldl --end-group /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/crtend.o /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/crtn.o When changing the link order manually, it works: /opt/cross/libexec/gcc/arm-linux-gnueabihf/7.3.0/collect2 -plugin /opt/cross/libexec/gcc/arm-linux-gnueabihf/7.3.0/liblto_plugin.so -plugin-opt=/opt/cross/libexec/gcc/arm-linux-gnueabihf/7.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cc5Y6i7I.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ldl -Bstatic -X -m armelf_linux_eabi -o helloworld.arm /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/crt1.o /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/crti.o /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/crtbeginT.o -L/opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0 -L/opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib helloworld.o -lgphobos -lgdruntime --start-group -lgcc -lgcc_eh -lpthread -lc -lm -ldl --end-group /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/crtend.o /opt/cross/lib/gcc/arm-linux-gnueabihf/7.3.0/../../../../arm-linux-gnueabihf/lib/crtn.o Please fix. Thanks! -- You are receiving this mail because: You are watching all bug changes.