Reputation: 61590
I wanted to configure an autotooled project to invoke a non-standard
linker (the gold
linker),
using the stock autotools of Linux Mint 16/Ubuntu 13.10
I believed I would achieve this by:
libtoolize
-ing the project./configure LD=/path/to/my/linker ... etc.
However this has been ineffective. libtoolize
has been successful. After
a standard ./configure; make
I now see that libtool
is doing the
linking:
/bin/bash ./libtool --tag=CXX --mode=link g++ -g -O2 -o helloworld helloworld.o
But passing LD=/path/to/my/linker
to configure
makes no difference. Experimentally,
I even ran:
./configure LD=/does/not/exist
expecting to provoke an error, but I didn't. The output contains:
checking if the linker (/does/not/exist -m elf_x86_64) is GNU ld... no
checking whether the g++ linker (/does/not/exist -m elf_x86_64) supports shared libraries... yes
And thereafter a make continues to link, successfully, invoking g++
exactly as before.
What is the right way to configure a non-standard linker?
Upvotes: 5
Views: 4520
Reputation: 40264
I landed on this via a Google search, though my scenario is a bit different from yours; there was no libtool involved. An old open source program's Makefile
was hard-coding ld
to create an object file with a symbol from binary data.
This is what I ended up doing to work around the lack of $(LD)
being recognized when passed to configure
:
https://github.com/turboencabulator/tuxnes/commit/bab2747b175ee7f2fc3d9afb28d69d82db054b5e
Basically I added to configure.ac
:
AC_CHECK_TOOL([LD], [ld])
Leaving this answer here for if someone else lands via a google search.
Upvotes: 0
Reputation: 213877
But passing LD=/path/to/my/linker to configure makes no difference
This is because LD
is almost never and should almost never be used to link any user-space program. Correct links are performed by using the appropriate compiler driver (gcc
, g++
, etc) instead.
What is the right way to configure a non-standard linker?
If you have /some/path/ld
and you want gcc
to use that ld
, pass -B/some/path
flag to gcc.
It then follows that you likely want:
./configure CC='gcc -B/some/path' CXX='g++ -B/some/path' ...
Upvotes: 3