https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35179
Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target|i386-pc-solaris2.10 |i386-pc-solaris2.10, | |i486-linux-gnu CC| |egallager at gcc dot gnu.org --- Comment #7 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Radu Hociung from comment #6) > Comment on attachment 17939 [details] > Improved hello-test case showing working and failing command lines, with > Makefile > > Works as expected: > gcc -g -o hello-exec hellomain.o -L. -lhello > > Triggers the bug: > gcc -g -static -o hello-exec-gccbug35179 hellomain.o -shared -L. -lhello -v Testcase fails to link for me on Darwin due to a difference in linkers: $ make hello-exec-gccbug35179 /usr/local/bin/gcc -o hellomain.o -c -g hellomain.c hellomain.c: In function ‘main’: hellomain.c:9:2: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration] exit(0); ^~~~ hellomain.c:9:2: warning: incompatible implicit declaration of built-in function ‘exit’ hellomain.c:9:2: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’ /usr/local/bin/gcc -o hello_.o -g -c -fpic -DPIC hello.c /usr/local/bin/gcc -o libhello.so -shared -g hello_.o echo Linking with both -static and -shared flags exposes the bug. Linking with both -static and -shared flags exposes the bug. /usr/local/bin/gcc -g -static -o hello-exec-gccbug35179 hellomain.o -shared -L. -lhello -v Using built-in specs. COLLECT_GCC=/usr/local/bin/gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-apple-darwin9.8.0/8.0.0/lto-wrapper Target: i386-apple-darwin9.8.0 Configured with: ../configure --disable-werror --disable-werror-always --enable-languages=c,c++,lto,objc,obj-c++ --enable-stage1-checking=release,rtl -C --with-system-libunwind --enable-secureplt --enable-frame-pointer --enable-debug --with-isl --disable-host-shared --enable-maintainer-mode --disable-default-pie --with-ld64 --without-pic --enable-target-optspace CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++ AUTOCONF=/usr/local/bin/autoconf AUTOHEADER=/usr/local/bin/autoheader AUTORECONF=/usr/local/bin/autoreconf AUTOM4TE=/usr/local/bin/autom4te AUTOSCAN=/usr/local/bin/autoscan AUTOUPDATE=/usr/local/bin/autoupdate IFNAMES=/usr/local/bin/ifnames Thread model: posix gcc version 8.0.0 20170702 (experimental) (GCC) COMPILER_PATH=/usr/local/libexec/gcc/i386-apple-darwin9.8.0/8.0.0/:/usr/local/libexec/gcc/i386-apple-darwin9.8.0/8.0.0/:/usr/local/libexec/gcc/i386-apple-darwin9.8.0/:/usr/local/lib/gcc/i386-apple-darwin9.8.0/8.0.0/:/usr/local/lib/gcc/i386-apple-darwin9.8.0/ LIBRARY_PATH=/usr/local/lib/gcc/i386-apple-darwin9.8.0/8.0.0/:/usr/local/lib/gcc/i386-apple-darwin9.8.0/8.0.0/../../../ COLLECT_GCC_OPTIONS='-g' '-static' '-o' 'hello-exec-gccbug35179' '-L.' '-v' '-mmacosx-version-min=10.5.8' '-asm_macosx_version_min=10.5' '-mtune=core2' '-Zdynamiclib' /usr/local/libexec/gcc/i386-apple-darwin9.8.0/8.0.0/collect2 -static -dylib -arch i386 -macosx_version_min 10.5.8 -weak_reference_mismatches non-weak -o hello-exec-gccbug35179 -ldylib1.10.5.o -L. -L/usr/local/lib/gcc/i386-apple-darwin9.8.0/8.0.0 -L/usr/local/lib/gcc/i386-apple-darwin9.8.0/8.0.0/../../.. hellomain.o -lhello -lgcc_eh -lgcc -v -idsym collect2 version 8.0.0 20170702 (experimental) /usr/bin/ld -static -dylib -arch i386 -macosx_version_min 10.5.8 -weak_reference_mismatches non-weak -o hello-exec-gccbug35179 -ldylib1.10.5.o -L. -L/usr/local/lib/gcc/i386-apple-darwin9.8.0/8.0.0 -L/usr/local/lib/gcc/i386-apple-darwin9.8.0/8.0.0/../../.. hellomain.o -lhello -lgcc_eh -lgcc -v Apple Computer, Inc. version cctools-698.1~1 ld_classic: incompatible flag -dylib used (must specify "-dynamic" to be used) collect2: error: ld returned 1 exit status make: *** [hello-exec-gccbug35179] Error 1 $ Someone running GNU/Linux will have to try the testcase to move this out of WAITING.