Saturday, August 13, 2011

Feeling underlinked?

Diego's flood of tinderbox underlinking bugs kept me puzzled in the beginning, because one thing I don't want to do is replace the linker on all my systems with some piece of half-experimental code. Luckily, after some discussion with him on IRC it became clear that many of the issues discovered by using gold can also be found using the --no-add-needed option of the normal linker. However, it has to be forced in the gcc profile to really make sure that it is applied.
So, if you want to make your system sensitive to most underlinking issues, run the following script (closely based on Diego's forced-as-needed instructions) as root. It will create an additional gcc profile, which you can then choose with eselect... Happy bugfixing.

export SPECSFILE=$(dirname "$(gcc -print-libgcc-file-name)")/forced.specs
export CURRPROFILE=/etc/env.d/gcc/$(gcc-config -c)
gcc -dumpspecs | sed -e '/link:/,+1 s:--eh-frame-hdr:\0 --as-needed --no-add-needed:' > "$SPECSFILE"


  1. Ahh, I wondered about this, but didn't get an answer.

    I too, wasn't keen to get into bed with the linker that ruined Diego's day some time back by destroying his tinderbox.

    Hopefully I can address the few issues in one of my packages.

  2. —no-copy-dt-needed-entries is just the new name of the option, --no-add-needed is already deprecated in gcc-4.5 (but gcc-4.4 only understands the old version)...