Casual Hacking

Main Menu

Bootstrapping gcc 4.6.2 from 4.1.2

by Waitman Gobble
Part 1
"Getting to MAKE (3.82)"
November 16, 2011

Procedure to build a modern version of GNU GCC compiler, and a development environment within user home,
adding support for new tools which are now or will be soon becoming standard. (ie, Parma Polyhedra Library,
Google gold ELF linker, Graphite Loop optimizations) In this example we are building the most recent stable
version, however this procedure could be used as a basis for building development/cvs releases. The version
shipped with my target host system, CentOS 5.7, is GNU GCC 4.1.2 (which was released February 13, 2007).
At the time of this writing, CentOS 5.7, based on EL-5.7, is modern and stable.

It Worked For Me

This is not intended to be a de-facto comprehensive reference, but simply notes from my specific build process.
Here I believe to have worked out a sequence and process, with proper configuration options selected for each
tool. To be sure you should always read the documentation!

Getting The Source

Most of the source code can be found at the ftp site ftp.gnu.org (no link, to avoid unnecessary ftp connects
to their server). Check the "gnu/" directory. Other software may be found using your favorite search engine.
For Java and BerkeleyDB you'll need to visit the Oracle site and set up an account in order to download the
components. If you would like to receive an unofficial copy of the sources listed here, drop me a line.

Other Notes: if you have access to mulitple processors on your system you might add something like -j2, -j4,
-j8, etc to the "make" lines to speed things up. Also, the example configurations here use GNU pth threads
(OSSP pth). Check the docs for information about other possibilities.


[devcc@q gcc]$ uname -a
Linux q.umatar.com 2.6.18-274.7.1.el5 #1 SMP Thu Oct 20 16:21:01 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
[devcc@q gcc]$ pwd
/home/devcc/src/gcc

Q) What "ships" with centos 5.7

$ make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-redhat-linux-gnu


first create user account devcc for build, fetch and drop source files in src
the software will install to ...


[devcc@q gcc]$ ls /home/devcc/
bin include info lib lib64 man share src x86_64-unknown-linux-gnu

ie, don't su or sudo!!!! installing gcc on top of a linux distro is probably not so good. :)

prevent some trouble from happening....

[devcc@q gcc]$ export CFLAGS=-fPIC


1. dmalloc-5.5.2

./configure --prefix=/home/devcc
make
make threads
make threadscxx
make install


2. libiconv-1.14

./configure --prefix=/home/devcc --with-gnu-ld 
make && make install


3. gettext-0.18.1.1

./configure --prefix=/home/devcc --with-libiconv-prefix=/home/devcc
make && make install


4. gmp-5.0.2

./configure --prefix=/home/devcc --enable-cxx
make && make check
make install


5. mpfr-3.1.0

./configure --prefix=/home/devcc --with-gmp=/home/devcc
make && make install


6. gc-7.2alpha6

./configure --prefix=/home/devcc 
make && make install


7. binutils-2.19.1

./configure --prefix=/home/devcc --enable-gold --enable-objc-gc \
	--with-mpfr=/home/devcc \
	--with-gmp=/home/devcc --with-build-sysroot=/home/devcc
make && make install

export PATH=/home/devcc/bin:$PATH


8. make-3.82

./configure --prefix=/home/devcc --with-dmalloc --with-gnu-ld \
	--with-libiconv-prefix=/home/devcc --with-libintl-prefix=/home/devcc
make && make install


$ /home/devcc/bin/make -v
GNU Make 3.82
Built for x86_64-unknown-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


9. pth

./configure --prefix=/home/devcc --with-dmalloc=/home/devcc --with-gnu-ld
/home/devcc/bin/make
/home/devcc/bin/make install


10. libsigsegv-2.6

./configure --prefix=/home/devcc
/home/devcc/bin/make
/home/devcc/bin/make install


11. m4-1.4.16

./configure --prefix=/home/devcc --enable-silent-rules --enable-changeword \
	--enable-c++ --with-dmalloc=/home/devcc --with-gnu-ld \
	--with-libpth-prefix=/home/devcc --with-libsigsegv-prefix=/home/devcc
/home/devcc/bin/make
/home/devcc/bin/make install

$ m4 --version
m4 (GNU M4) 1.4.16
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Rene' Seindal.


12. autoconf-2.68

./configure --prefix=/home/devcc
/home/devcc/bin/make
/home/devcc/bin/make install


13. automake-1.11.1

./configure --prefix=/home/devcc
/home/devcc/bin/make
/home/devcc/bin/make install


Next Section: Bootstrapping gcc 4.6.2 from 4.1.2 Part 2


Copyright 2011 Waitman Gobble · waitman@waitman.net