Bug 5361 - configure picks the wrong ld
Summary: configure picks the wrong ld
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.0.28a
Hardware: x64 Solaris
: P3 normal
Target Milestone: none
Assignee: Michael Adam
QA Contact: Samba QA Contact
: 5730 (view as bug list)
Depends on:
Reported: 2008-03-31 10:16 UTC by Andreas Franz Borchert
Modified: 2021-01-04 16:21 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Franz Borchert 2008-03-31 10:16:27 UTC
The configure script tests whether GNU ld is used by following piece of code:

{ echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; }
if test "${ac_cv_prog_gnu_ld+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then

This construct has two problems:
 - There is no way to override the definition of LD, i.e. to select another
   binary for ld.
 - The common configure option --with-gnu-ld / --without-gnu-ld is not
 - The ld found by accident in the PATH is not necessarily the ld which is
   invoked by gcc.
My recommendation would be to test the result of $CC -Wl,-V -- i.e. let the C compiler invoke ld with a verbosity flag to find out which ld is used. (Note that the option -v provokes a usage message in case of Sun's ld. -V causes both, GNU ld and Solaris ld, to generate a version info.)

Impact: When the configure script is run under Solaris and gcc is configured to use Solaris' ld, the ld will present a usage message detailing that the option -E is invalid. Please note that currently the use of gcc 4.x (we are using gcc 4.2.2) along with the GNU assembler and Solaris' ld is the recommended configuration for gcc under the Solaris 10 / x86 platform. (This is different from the Solaris 10 / SPARC platform where GNU ld is usually used by gcc.) See http://www.sourceware.org/ml/binutils/2006-04/msg00126.html.

Workaround: Building works without problems as soon LD=ld is replaced by LD=/usr/ccs/bin/ld on the gcc 4.x / Solaris 10 / x86 platform.
Comment 1 Michael Adam 2008-10-27 06:33:35 UTC
Just stumbled over this one.
The same problem has already been analyzed in (later) bug #5730 for Samba 3.2.

Sorry - somehow, I did not get this the first time (?) it was reported...
Your analysis and workaround are correct.
Thanks for the input as how to detect the linker used by gcc.

I will play with it...

Comment 2 Michael Adam 2009-05-17 18:00:02 UTC
*** Bug 5730 has been marked as a duplicate of this bug. ***
Comment 3 Björn Jacke 2021-01-04 16:21:49 UTC
closing, we have waf buildsystem now