Bug 58427 - xgcc target compilation depends on installed libgcc_s.so
Summary: xgcc target compilation depends on installed libgcc_s.so
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.7.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-15 14:02 UTC by Rose Garcia
Modified: 2013-09-17 01:54 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.5.4, 4.7.3
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rose Garcia 2013-09-15 14:02:06 UTC
during target compilation (for example libssp or libstdc++) xgcc is invoked with the usual specs:

/src/build/gcc454/gcc-4.5.4/host-x86_64-unknown-linux-gnu/gcc/xgcc -B/src/build/gcc454/gcc-4.5.4/host-x86_64-unknown-linux-gnu/gcc/ ... conftest.c

specs:
%{static|static-libgcc:-lgcc -lgcc_eh}%{!static:%{!static-libgcc:%{!shared-libgcc:-lgcc --as-needed -lgcc_s --no-as-needed}%{shared-
libgcc:-lgcc_s%{!shared: -lgcc}}}}

in case binutils ld decides for some reason that libgcc_s is needed, it will hardcode a reference to libgcc_s into DT_NEEDED.
binutils itself finds the libgcc_s.so in the -B path, and adds it, but launching the resulting executable will fail because the *dynamic linker* has no way of knowing that it should look for the .so in host-x86_64-unknown-linux-gnu/gcc.

this causes the configure check for libssp and libstdc++ to fail with
"C compiler cannot create working executables".

possible solutions:
1) the spec file used by xgcc to compile target libraries should use libgcc_eh.a instead of libgcc_s.so
2) LD_LIBRARY_PATH has to be set to host-x86_64-unknown-linux-gnu/gcc (the -B path) so the dynamic linker can find libgcc_s.so

imo, 1) is preferable.
Comment 1 Rose Garcia 2013-09-15 14:29:42 UTC
related binutils bugreport:
https://sourceware.org/bugzilla/show_bug.cgi?id=12549#c18