Gold linker ld.gold -plugin : unknown option
Asked Answered
F

1

6

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.

Fitful answered 20/5, 2014 at 8:28 Comment(3)
if you want to comment multiple lines, indent them by 4 spaces. if you want to comment a single line, surround them with just a single backtick on either side.Quantitative
Okay, will do. Sorry.Fitful
no need to apologize, I just can't imagine it's easy/enjoyable to do what you've been doing here for code formatting hahaQuantitative
M
10

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.

Meatus answered 20/5, 2014 at 14:21 Comment(2)
Wow thanks a lot for that explanation. You're totally right : the Linux_x64/Release/bin version doesn't have plugin support (which is very weird because this is Google's own code that downloaded (and built ?) it, and they use it to link the files... ) Anyway I'm following the documentation to try rebuild binutils with plugin support, if that fails, I'll try to make a symlink to my /usr/bin/ld.gold. Anyway thanks again and I'll post here again to tell if I managed.Fitful
Yeah it worked, thank again : you really helped out here. I still can't compile as I get the error : ``` cc: error: unrecognized command line option ‘-Wno-’ ``` But that definitely solved my problem with ld.gold, thanks. (Any idea why the new error ?)Fitful

© 2022 - 2024 — McMap. All rights reserved.