This should still be supported OK, as it's commonly used for building cross-compilers.
In fact, I've just done this with gcc 4.6.0 and binutils 2.21 (with gmp, mpc and mpfr at appropriate versions), and the following seemed to work fine:
- Get all the archives of the stuff you're going to build (gcc-4.6.0.tar.bz2, binutils-2.21.tar.bz2 etc) into a new dir, e.g.
src
Un-tar them all in this directory, so you end up with gcc-4.6.0/
binutils-2.21/
gmp-5.0.2/
and more sitting alongside one another
tar jxvf gcc-4.6.0.tar.bz2
... (unpack others here, watch file lists scroll past)
cd gcc-4.6.0
and symlink the gmp, mpc and mpfr directories without their version numbers in the links, e.g:
ln -s ../gmp-5.0.2 gmp
Now symlink everything from the binutils dir which doesn't exist in the gcc dir, so anything which already exists will take priority but the binutils tools will look be visible to the build:
for file in ../binutils-2.21/* ; do ln -s "${file}" ; done
Change up a dir and make a build directory to build all this in separately to the sources (this always used to be the recommended method, and it tends to still be more reliable than building inside the source dir):
cd .. ; mkdir build
At this point you should have a set of directories and links which looks something like this:
binutils-2.21/
build/
gcc-4.6.0/
gmp -> ../gmp-5.0.2
mpc -> ../mpc-0.9
mpfr -> ../mpfr-3.0.1
bfd -> ../binutils-2.21/bfd
binutils -> ../binutils-2.21/binutils
gas -> ../binutils-2.21/gas
... (lots more symlinks for binutils here, plus existing gcc stuff)
gmp-5.0.2/
mpc-0.9/
mpfr-3.0.1/
Configure the whole lot from this dir, with whatever options you need to pass to configure:
../gcc-4.6.0/configure --prefix=/foo/bar --enable-languages=c,c++,ada
Build, wait, install (you'll probably want to use make -j4
or so here to get some builds in parallel as it's going to take a while) :
make -j4 ; make install
Add the destination to your path if it's not already (and perhaps the lib dir to LD_LIBRARY_PATH if this is outside of those specified in /etc/ld.so.conf
, as mentioned in the messages about installing libraries during the make install
step), and everything should be up and running with this new version.
It's probably worth checking that you're using this installed version once you've opened a new shell, with :
`which gcc`
and
`which as`
..as well as that the version is as you expect with:
`gcc --version`
and
`as --version`
..as well as (of course) testing that the installed version builds executables fine with some simple examples before you let it loose on your code-base :)
Edit: The comments below contain some sets of versions which are known to work together. Not all combinations will work, so you might need to go through some trial and error for different combinations to those mentioned!
Much later edit: gdb is also possible to include in this build (again requires compatible component versions - see comments).
Add this as the last thing after binutils in a similar way, using for f in ../gdb-8.1.1/* ; do ln -s "${f}" ; done
and the build will automatically pick it up.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…