Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using gold in the place of ld as a system linker on fedora

Tags:

gcc

llvm

llvm-gcc

I want to use gold as my system linker instead of ld as ld doesn't support -fPIC and -shared. I followed this particular url to do so, gold-plugin As per the documentation, I ran gcc -v filename.c to find out what link command gcc would run. Then it tells me to check for line that runs collect2 and replace it with -plugin /path/to/LLVMgold.so. But gcc and collect2 are binary files. I studied a bit..and understood gcc calls collect2 ,in turn collect2 calls system linker ld by searching for ld-linux.so.2. I have rpm packeage of gcc4.4.4 installed on my fedora...how can I change my configuration.

How can I make gcc call ld-new/gold instead of collect2?

like image 316
vinhephaistion Avatar asked Nov 10 '12 11:11

vinhephaistion


1 Answers

I'm a bit late to answer, but I realised Fedora comes out with gold distributed with binutils. The command is ld.gold. You can select it as the default linker using alternatives :

# alternatives --config ld

There is 2 program that provides 'ld'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/bin/ld.bfd
   2           /usr/bin/ld.gold

Enter to keep the current selection[+], or type selection number: 2
like image 125
Lærne Avatar answered Sep 24 '22 03:09

Lærne