collect2 picks wrong target-ld

Ian Lance Taylor
Mon Dec 5 17:33:00 GMT 2011

Georg-Johann Lay <> writes:

> Georg-Johann Lay schrieb:
>> Ian Lance Taylor schrieb:
>>> --prefix and --target, and you run both "make" and "make install", then
>>> gcc should use the installed ld.  It shouldn't run "avr-ld".  It should
>>> run "ld" from the special $(exec_prefix)/$(target_alias) directory.
>>> That directory exists to hold tools that the compiler needs to run,
>>> under canonical names.
> You have an idea what is going wrong and where I have to look?

First verify that after you make and install GNU binutils the directory
${exec_prefix}/${target_alias}/bin has an executable named "ld", among
others.  Typically the value of ${exec_prefix} will be the --prefix
option used when you run configure, and ${target_alias} will be the the
--target option.

Verify that the values for $(exec_prefix) and $(target_noncanonical)
in gcc/Makefile in the build directory exactly match the values of
${exec_prefix} and ${target_alias}.

Run a sample link using the option -Wl,-debug.  This will show the
search path used by collect2 to find binaries, as the COMPILER_PATH
option.  Verify that ${exec_prefix}/${target_alias}/bin is on that
path.  Also look at ld_file_name in the -Wl,-debug output to see which
linker collect2 thinks it is going to run.

With luck looking at those items will suggest where to look next.

> Why is collect2 searching for target-ld at all if it is supposed to
> use dedicated ld?

Because the dedicated ld depends on configuring and building the GNU
binutils and gcc in exactly the same way.  If the dedicated ld is not
found, collect2 looks for ${target_alias}-ld as a reasonable fallback.

> With -debug it spits out a directory list taken from $PATH and in some
> directory there is a target-ld which collect2 is calling.

Which directory?

Also, exactly how did you configure the binutils?  And exactly how did
you configure gcc?


More information about the Gcc-help mailing list