Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gold linker ld.gold -plugin : unknown option

I'm trying to build Google's ligjingle following the Getting started steps, and I've reached the "Building" section.

When I issue either

ninja -C out/Debug

or

ninja -C out/Release

I get the following error : I posted the output in pastebin too, if you prefer

ninja -C out/Debug
ninja: Entering directory `out/Debug'
[3/2606] LINK genmacro
FAILED: cc -Wl,-z,now -Wl,-z,relro -Wl,--fatal-warnings -pthread -Wl,-z,noexecstack -fPIC -B/home/nschoe/workspace/webrtc/jingle/trunk/third_party/binutils/Linux_x64/Release/bin -Wl,--disable-new-dtags -m64 -Wl,--icf=none -fuse-ld=gold -Wl,--gdb-index -o genmacro -Wl,--start-group obj/third_party/yasm/source/patched-yasm/tools/genmacro/genmacro.genmacro.o  -Wl,--end-group 
/home/nschoe/workspace/webrtc/jingle/trunk/third_party/binutils/Linux_x64/Release/bin/ld.gold: -plugin: unknown option
/home/nschoe/workspace/webrtc/jingle/trunk/third_party/binutils/Linux_x64/Release/bin/ld.gold: use the --help option for usage information
collect2: error: ld returned 1 exit status
[3/2606] CC obj/net/third_party/nss/ssl/libssl.sslauth.o
ninja: build stopped: subcommand failed.

I tried

ld.gold --help | grep "plugin"

and got :

--plugin PLUGIN             Load a plugin library
--plugin-opt OPTION         Pass an option to the plugin

So I suppose the error I'm getting is because somewhere in the code, ld.gold is called with -plugin xxx rather than --plugin xxx

I have been "playing" with grep -Hr and different combinations of "plugin" to try to find the problem, but so far I haven't found anything. I suppose it is hidden somewhere in a Makefile.

like image 601
nschoe Avatar asked May 20 '14 08:05

nschoe


1 Answers

The problem is not that the -plugin option should be --plugin. ld.gold accepts both options if it accepts either of them.

But it only accepts either of them if the build of binutils has been configured with --enable-plugins. Documentation.

When you run ld.gold --help | grep "plugin" the output shows that --plugin is a recognized option.

Therefore the problem appears to be this:-

/home/nschoe/workspace/webrtc/jingle/trunk/third_party/binutils/Linux_x64/Release/bin/ld.gold has not been configured with --enable-plugins

When you run ld.gold --help | grep "plugin" you are executing the first ld.gold that is found on your PATH. It is probably /usr/bin/ld.gold from your distro. You can find out by running:

which ld.gold

Anyhow, it isn't /home/nschoe/workspace/webrtc/jingle/trunk/third_party/binutils/Linux_x64/Release/bin/ld.gold and it is an ld.gold that has been configured with --enable-plugins

If you cd into /home/nschoe/workspace/webrtc/jingle/trunk/third_party/binutils/Linux_x64/Release/bin/ and run:

 ./ld.gold -plugin

you will get:

./ld.gold: -plugin: unknown option

To fix the problem the ideal solution is to rebuild /home/nschoe/workspace/webrtc/jingle/trunk/third_party/binutils as per that Documentation

If you cannot rebuild these third party binutils from source then it will probably work if you just copy the system ld.gold detected by which over the one in the third party binutils, or delete/rename the third party one and replace it with a symlink to the system one. There is an outside chance that either of the these hacks would cause you some obscure breakage.

like image 123
Mike Kinghan Avatar answered Oct 19 '22 11:10

Mike Kinghan