SSE3044: Operating Systems (Fall 2012)


Building GCC 4.1.2 on Ubuntu 12.04.1 LTS

September 1, 2012

Jin-Soo Kim
Computer Systems Laboratory
Sungkyunkwan University

Our projects based on the Pintos operating system require gcc version 4.1.2. Unfortunately, only gcc versions from 4.4 to 4.6 are available on the latest Ubuntu platform (12.04.1 LTS as of this writing), with the default C compiler being gcc version 4.6.3. This document shows how to build gcc version 4.1.2 on Ubuntu 12.04.1 LTS for use with Pintos. This works for both 32-bit and 64-bit versions of Ubuntu 12.04.1 LTS.

1. Get the source code of gcc version 4.1.2

The source code of gcc can be obtained from any of mirror sites listed in http://gcc.gnu.org/mirrors.html. For example, the complete release of gcc version 4.1.2 can be downloaded and untar'ed as follows:

$ cd ~/src
$ wget http://www.netgull.com/gcc/releases/gcc-4.1.2/gcc-4.1.2.tar.bz2
$ tar xvjf gcc-4.1.2.tar.bz2

2. Install prerequisites

Once you untar the source code, the GCC installation manual is available in ~/src/gcc-4.1.2/INSTALL/index.html. Refer to the Prerequisites section in the manual and install any required tools.

3. Add symbolic links to header files/libraries

Add the following symbolic links. This is due to the multiarch systems support adopted in Ubuntu. Use x86_64-linux-gnu instead of i386-linux-gnu for 64-bit Ubuntu system.

$ cd /usr/include
$ sudo ln -s i386-linux-gnu/bits bits
$ sudo ln -s i386-linux-gnu/gnu gnu
$ sudo ln -s i386-linux-gnu/sys sys
$ sudo ln -s i386-linux-gnu/asm asm
$ cd /usr/lib
$ sudo ln -s i386-linux-gnu/crt1.o crt1.o
$ sudo ln -s i386-linux-gnu/crti.o crti.o
$ sudo ln -s i386-linux-gnu/crtn.o crtn.o

4. Build gcc

$ cd ~/src/gcc-4.1.2/
$ mkdir objdir
$ cd objdir
$ ../configure --prefix=/usr/local --program-prefix=sse- --libexecdir=/usr/local/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --enable-languages=c,c++
$ make bootstrap

The following error message may be displayed due to the incorrect version check for makeinfo. It is known that this error occurs when you are using binutils version 2.18 and makeinfo version 4.10 or higher.

WARNING: `makeinfo' is missing on your system. You should only need it
if you modified a `.texi' or `.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy `make' (AIX,
DU, IRIX). You might want to install the `Texinfo' package or
the `GNU make' package. Grab either from any GNU archive site.

If you encounter this error while building gcc, use the following command instead of $ make bootstrap.

$ make bootstrap MAKEINFO=makeinfo

5. Install gcc

"make install" will install files in /usr/local/*. Make sure the /usr/local/bin directory is included in the PATH.

$ sudo make install

$ ls -l /usr/local/bin
i686-pc-linux-gnu-gcc-4.1.2  i686-pc-linux-gnu-sse-gcc  sse-g++     sse-gcov
i686-pc-linux-gnu-sse-c++    sse-c++                    sse-gcc
i686-pc-linux-gnu-sse-g++    sse-cpp                    sse-gccbug