Replacing ld with gold - any experience?

后端 未结 8 838
你的背包
你的背包 2020-11-28 04:32

Has anyone tried to use gold instead of ld?

gold promises to be much faster than ld, so it may help speeding up test cycles fo

8条回答
  •  一生所求
    2020-11-28 05:15

    As it took me a little while to find out how to selectively use gold (i.e. not system-wide using a symlink), I'll post the solution here. It's based on http://code.google.com/p/chromium/wiki/LinuxFasterBuilds#Linking_using_gold .

    1. Make a directory where you can put a gold glue script. I am using ~/bin/gold/.
    2. Put the following glue script there and name it ~/bin/gold/ld:

      #!/bin/bash
      gold "$@"
      

      Obviously, make it executable, chmod a+x ~/bin/gold/ld.

    3. Change your calls to gcc to gcc -B$HOME/bin/gold which makes gcc look in the given directory for helper programs like ld and thus uses the glue script instead of the system-default ld.

提交回复
热议问题