https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35179

--- Comment #8 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #7)
> (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.

Now that I have access to the GCC compile farm, the testcase still fails on me
when I try it there:

egallager@gcc12:~/hello-test$ make hello-exec-gccbug35179
/opt/cfarm/gcc-latest/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'
/opt/cfarm/gcc-latest/bin/gcc -o hello_.o -g -c -fpic -DPIC hello.c 
/opt/cfarm/gcc-latest/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.
/opt/cfarm/gcc-latest/bin/gcc -g -static -o hello-exec-gccbug35179 hellomain.o
-shared -L. -lhello -v 
Using built-in specs.
COLLECT_GCC=/opt/cfarm/gcc-latest/bin/gcc
COLLECT_LTO_WRAPPER=/home/iulius/autobuild/bin/gcc-7.1.0/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-7.1.0-src/configure
--prefix=/home/iulius/autobuild/bin/gcc-7.1.0
--with-gmp=/home/iulius/autobuild/bin/gmp-6.1.2
--with-mpfr=/home/iulius/autobuild/bin/mpfr-3.1.5
--with-mpc=/home/iulius/autobuild/bin/mpc-1.0.3 --disable-nls
--enable-threads=posix --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 7.1.0 (GCC) 
COMPILER_PATH=/home/iulius/autobuild/bin/gcc-7.1.0/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/:/home/iulius/autobuild/bin/gcc-7.1.0/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/:/home/iulius/autobuild/bin/gcc-7.1.0/libexec/gcc/x86_64-pc-linux-gnu/:/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/:/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/:/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g' '-static' '-o' 'hello-exec-gccbug35179' '-shared'
'-L.' '-v' '-mtune=generic' '-march=x86-64'

/home/iulius/autobuild/bin/gcc-7.1.0/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/collect2
-m elf_x86_64 -shared -o hello-exec-gccbug35179 /usr/lib/../lib64/crti.o
/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/crtbeginT.o
-L. -L/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0
-L/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64
-L/lib/../lib64 -L/usr/lib/../lib64
-L/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/../../..
hellomain.o -lhello --start-group -lgcc -lgcc_eh -lc --end-group
/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/crtendS.o
/usr/lib/../lib64/crtn.o
/usr/bin/ld:
/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/crtbeginT.o:
relocation R_X86_64_32 against `__TMC_END__' can not be used when making a
shared object; recompile with -fPIC
/home/iulius/autobuild/bin/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/crtbeginT.o:
could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [hello-exec-gccbug35179] Error 1
egallager@gcc12:~/hello-test$

Reply via email to