GCC-4.8.2

Introduction to GCC

The GCC package contains GNU compilers. This package is useful for compiling programs written in C, C++, Fortran, Java, Objective C, Objective C++, Ada, and Go. You should ensure you actually need one of these additional compilers (C and C++ are installed in LFS) before you install them. Additionally, there are instructions in the BLFS book to install OpenJDK-1.7.0.55/IcedTea-2.4.7, which can be used instead of the Java provided by the GCC package. Many consider the Iced Tea version to be a more robust Java environment than the one provided by GCC.

This package is known to build and work properly using an LFS-7.5 platform.

[Caution]

Caution

If you are upgrading GCC from any other version prior to 4.8.2, then you must be careful compiling 3rd party kernel modules. You should ensure that the kernel and all its native modules are also compiled using the same version of GCC that you use to build the 3rd party module. This issue does not affect native kernel (and kernel modules) updates, as the instructions below are a complete reinstallation of GCC. If you have existing 3rd party modules installed, ensure they are recompiled using the updated version of GCC. As always, never update the kernel headers from the ones used when Glibc was compiled during LFS.

Package Information

GCC Dependencies

Required if building java

Zip-3.0, UnZip-6.0, and Which-2.20

Recommended

[Note]

Note

If you plan to compile Ada, you will need to install GNAT temporarily to satisfy the circular dependency when you recompile GCC to include Ada. At the AdaCore download page, choose your platform and 2013, then select the file to download. You probably want the x86-linux or x86_64-linux file.

GNAT GPL 2013 Package Information

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/gcc

Installation of GNAT

Before unpacking and changing into the GCC source directory, first unpack the GNAT tarball. You may have to drill down several levels and unpack a second tarball. For example, AdaCore-Download-2013-07-22_0530.tar expands to x86_64-linux/2013/gnatgpl/gnat-gpl-2013-x86_64-pc-linux-gnu-bin.tar.gz. Expand this second tarball and change into the newly created directory. Install GNAT by running the following command:

make ins-all prefix=/opt/gnat

The GNAT compiler can be invoked by executing the gcc binary installed in /opt/gnat/bin.

You may now remove the GNAT source directory if desired.

Prepare to compile GCC by placing the GNAT version of gcc at the beginning of the PATH variable by using the following commands as the root user:

PATH_HOLD=$PATH &&
export PATH=/opt/gnat/bin:$PATH_HOLD

Doing so has the drawback that the GCC and Binutils executables are taken from the just installed GNAT package, but the versions of those executables are outdated compared to those installed in LFS. This is not important for the GCC compilers, since they recompile themselves during the bootstrap process. On the other hand, the outdated ld and as tools are used all along. In order to use the LFS tools, issue:

find /opt/gnat -name ld -exec mv -v {} {}.old \;
find /opt/gnat -name as -exec mv -v {} {}.old \;

Installation of GCC

[Important]

Important

The installation process may overwrite your existing GCC gcc and c++ compilers and libraries. Having the Tcl, Expect and DejaGnu packages installed before beginning the build is highly recommended so you can run the full suite of tests.

Do not continue with the make install command until you are confident the build was successful. You can compare your test results with those found at http://gcc.gnu.org/ml/gcc-testresults/. You may also want to refer to the information found in the GCC section of Chapter 6 in the LFS book (../../../../lfs/view/development/chapter06/gcc.html).

The instructions below will make sure that “bootstrap” is performed intentionally. This is necessary if the Ada compiler is being built anyway. Even if it isn't, a bootstrap is recommended for robustness. To disable bootstrap anyways, pass --disable-bootstrap to the ./configure options below.

Install GCC by running the following commands:

sed -i 's/\(install.*:\) install-.*recursive/\1/' libffi/Makefile.in         &&
sed -i 's/\(install-data-am:\).*/\1/'             libffi/include/Makefile.in &&

case `uname -m` in
      i?86) sed -i 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in ;;
esac &&

sed -i -e /autogen/d -e /check.sh/d fixincludes/Makefile.in 
mv -v libmudflap/testsuite/libmudflap.c++/pass41-frag.cxx{,.disable}

mkdir ../gcc-build &&
cd    ../gcc-build &&

../gcc-4.8.2/configure          \
    --prefix=/usr               \
    --libdir=/usr/lib           \
    --enable-shared             \
    --enable-threads=posix      \
    --enable-__cxa_atexit       \
    --enable-clocale=gnu        \
    --disable-multilib          \
    --with-system-zlib          \
    --enable-lto                \
    --enable-languages=c,c++,fortran,ada,go,java,objc,obj-c++ &&
make

If you have installed additional packages such as Valgrind and GDB, the GCC part of the testsuite will run more tests than in LFS. Some of those will report FAIL and others XPASS (pass when expected to FAIL). To run the tests, issue:

ulimit -s 32768 &&
make -k check   &&

../gcc-4.8.2/contrib/test_summary

Now, as the root user:

make install &&

ln -v -sf ../usr/bin/cpp /lib &&
ln -v -sf gcc /usr/bin/cc     &&

mkdir -pv /usr/share/gdb/auto-load/usr/lib              &&
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &&

chown -v -R root:root \
    /usr/lib/gcc/*linux-gnu/4.8.2/include{,-fixed} \
    /usr/lib/gcc/*linux-gnu/4.8.2/ada{lib,include}

You should now remove the GNAT installation and perform other cleanups:

rm -rf /opt/gnat &&
export PATH=$PATH_HOLD &&
unset PATH_HOLD

Command Explanations

The first two sed commands prevent the installation of the libffi library bundled with GCC, since it is outdated compared to libffi-3.0.13. The following three commands are the same ones used during the build of LFS.

mkdir ../gcc-build; cd ../gcc-build: The GCC documentation recommends building the package in a dedicated build directory.

--enable-shared --enable-threads=posix --enable-__cxa_atexit: These parameters are required to build the C++ libraries to published standards.

--enable-clocale=gnu: This parameter is a failsafe for incomplete locale data.

--disable-multilib: This parameter ensures that files are created for the specific architecture of your computer.

--enable-lto: Setting this parameter allows to build a compiler which is able to perform “Link Time Optimization (LTO)”.

--enable-languages=c,c++,fortran,ada,go,java,objc,obj-c++: This command identifies which languages to build. You may modify this command to remove undesired languages.

ulimit -s 32768: This command prevents several tests from running out of stack space.

make -k check: This command runs the test suite without stopping if any errors are encountered.

../gcc-4.8.2/contrib/test_summary: This command will produce a summary of the test suite results. You can append | grep -A7 Summ to the command to produce an even more condensed version of the summary. You may also wish to redirect the output to a file for review and comparison later on.

ln -v -sf ../usr/bin/cpp /lib: This command creates a link to the C PreProcessor as some packages expect it to be installed in the /lib directory.

ln -v -sf gcc /usr/bin/cc: This link is created as some packages refer to the C compiler using an alternate name.

chown -v -R root:root /usr/lib/gcc/*linux-gnu/...: If the package is built by a user other than root, the ownership of the installed include and adalib directories (and their contents) will be incorrect. These commands change the ownership to the root user and group . Omit the command changing the Ada directories if you did not include Ada as one of the installed languages.

Contents

Installed Programs: aot-compile, gappletviewer, gc-analyze, gccgo, gcj, gcj-dbtool, gcjh, gfortran, gij, gjar, gjarsigner, gjavah, gkeytool, gnat, gnatbind, gnatchop, gnatclean, gnatfind, gnative2ascii, gnatkr, gnatlink, gnatls, gnatmake, gnatname, gnatprep, gnatxref, gorbd, grmic, grmid, grmiregistry, gserialver, gtnameserv, jcf-dump, jv-convert, rebuild-gcj-db, and architecture specific names
Installed Libraries: libgcj_bc.so, libgcj.so, libgcj-tools.so, libgfortran.{so,a}, libgij.so, libgo.{so,a}, libgobegin.a, libobjc.{so,a} and numerous other run-time libraries and executables in /usr/lib/gcc and /usr/libexec/gcc
Installed Directories: /usr/include/c++/4.8.2/{gcj,gnu,java,javax,org,sun}, /usr/lib/gcc/<arch-model>-linux-gnu/4.8.2/ada{include,lib}, /usr/lib/gcj-4.8.2-13, /usr/lib/go, /usr/lib/security, and /usr/share/java

Some program and library names and descriptions are not listed here, but can be found at ../../../../lfs/view/development/chapter06/gcc.html#contents-gcc as they were initially installed during the building of LFS.

Short Descriptions

aot-compile

searches a directory for Java bytecode and uses gcj to compile it to native code.

gappletviewer

loads and run a Java applet.

gc-analyze

analyzes garbage collector (GC) memory dumps from Java code.

gccgo

is a GCC-based compiler for the Go language.

gcj

is an ahead-of-time compiler for the Java language.

gcj-dbtool

is a tool for creating and manipulating class file mapping databases.

gcjh

generates header files from Java class files.

gfortran

is the Fortran compiler invoked by gcc.

gij

is the GNU interpreter for Java bytecode.

gjar

is an (partial) implementation of the jar utility that comes with Sun's JDK.

gjarsigner

is a Java ARchive (JAR) file signing and verification tool.

gjavah

generates header files from Java class files.

gkeytool

manages private keys and public certificates in a Java environment.

gnat

is the Ada compiler invoked by gcc.

gnatbind

is used to bind compiled objects.

gnatchop

is useful for renaming files to meet the standard Ada default file naming conventions.

gnatclean

is used to remove files associated with a GNAT project.

gnatfind

is the GNAT definition/use finder.

gnative2ascii

is an encoding converter for Java.

gnatkr

is used to determine the crunched name for a given file, when crunched to a specified maximum length.

gnatlink

is used to link programs and build an executable file.

gnatls

is the compiled unit browser.

gnatmake

is an automatic make facility.

gnatname

will list the files associated with a GNAT project.

gnatprep

is the GNAT external preprocessor.

gnatxref

is the GNAT cross-referencer.

gorbd

is an object request broker daemon.

grmic

generates stubs for Remote Method Invocation.

grmid

RMI activation system daemon.

grmiregistry

starts a remote object registry on the current host.

gserialver

prints the serialVersionUID of the specified class.

gtnameserv

starts a naming service.

jcf-dump

prints information about Java class files.

jv-convert

converts files from one encoding to another.

rebuild-gcj-db

Merge the per-solib databases made by aot-compile into one system-wide database.

Last updated on 2014-02-18 20:55:40 +0000