I've built GCC 4.9.3 from sources and installed into my home directory with some prefix, e.g. gcc4.9
.
Now I want to use a newer version of binutils
along with GCC 4.9.3. I've built them and installed separately in my home directory, with prefix binutils2.26
.
How I can force gcc-ar
from gcc4.9
to use ar
from binutils2.26
instead of system one? It always calls /usr/bin/ar
and looks like there is no options to specify. Replacing /usr/bin/ar
somehow is not an option - I don't have root access on this machine.
I managed to fix this issue.
Using strace
, I found that gcc-ar
looks for ar
in several directories, including <gcc install dir>/libexec/gcc/x86_64-redhat-linux/4.9.3
.
So the obvious solution is to create links in this directory targeting corresponding binutils2.26
executables:
cd "<gcc install dir>/libexec/gcc/x86_64-redhat-linux/4.9.3"
for file in ~/binutils2.26/bin/* ; do ln -s "${file}" ; done
After that all, executables in ~/binutils2.26/bin
will be replicated as links in the GCC 4.9.3 directory and will be used automatically when building by that GCC version.