%general-entities; ]> $LastChangedBy$ $Date$ GCC-&gcc-version; GCC-&gcc-version; 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 , 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. &lfs74_checked; If you are upgrading GCC from any other version prior to &gcc-version;, 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 Download (HTTP): Download (FTP): Download MD5 sum: &gcc-md5sum; Download size: &gcc-size; Estimated disk space required: &gcc-buildsize; Estimated build time: &gcc-time; GCC Dependencies Recommended Required if building java , , and 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 Download (HTTP): User Notes: 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 Install GCC by running the following commands: 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 . You may also want to refer to the information found in the GCC section of Chapter 6 in the LFS book (). The instructions below let the build machinery perform a bootstrap intentionally. This is necessary if you install the Ada compiler anyway. Even if you don't, a bootstrap is recommended for robustness. sed -i 's/\(install.*:\) install-.*recursive/\1/' libffi/Makefile.in && sed -i 's/\(install-data-am:\).*/\1/' libffi/include/Makefile.in && sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in && sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in && case `uname -m` in i?86) sed -i 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in ;; esac && mkdir ../gcc-build && cd ../gcc-build && ../gcc-&gcc-version;/configure \ --prefix=/usr \ --libdir=/usr/lib \ --libexecdir=/usr/lib \ --enable-shared \ --enable-threads=posix \ --enable-__cxa_atexit \ --disable-multilib \ --disable-bootstrap \ --disable-install-libiberty \ --with-system-zlib \ --enable-clocale=gnu \ --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 checks: ulimit -s 32768 && make -k check && ../gcc-&gcc-version;/contrib/test_summary Now, as the root user: make install && ln -v -sf ../usr/bin/cpp /lib && ln -v -sf gcc /usr/bin/cc && chown -v -R root:root \ /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed} \ /usr/lib/gcc/*linux-gnu/&gcc-version;/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 . The three other sed 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. --disable-multilib: This parameter ensures that files are created for the specific architecture of your computer. --enable-clocale=gnu: This parameter is a failsafe for incomplete locale data. --enable-lto: Setting this parameter allows to build a compiler which is able to perform link time optimization (lto). --enable-languages=c,c++,fortran,java,objc,obj-c++,ada,go: 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-&gcc-version;/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 Installed Libraries Installed Directories 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 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 /usr/include/c++/&gcc-version;/{gcj,gnu,java,javax,org,sun}, /usr/lib/gcc/<arch-model>-linux-gnu/&gcc-version;/ada{include,lib}, /usr/lib/gcj-&gcc-version;-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 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. aot-compile gappletviewer loads and run a Java applet. gappletviewer gc-analyze analyzes garbage collector (GC) memory dumps from Java code. gc-analyze gccgo is a GCC-based compiler for the Go language. gccgo gcj is an ahead-of-time compiler for the Java language. gcj gcj-dbtool is a tool for creating and manipulating class file mapping databases. gcj-dbtool gcjh generates header files from Java class files. gcjh gfortran is the Fortran compiler invoked by gcc. gfortran gij is the GNU interpreter for Java bytecode. gij gjar is an (partial) implementation of the jar utility that comes with Sun's JDK. gjar gjarsigner is a Java ARchive (JAR) file signing and verification tool. gjarsigner gjavah generates header files from Java class files. gjavah gkeytool manages private keys and public certificates in a Java environment. gkeytool gnat is the Ada compiler invoked by gcc. gnat gnatbind is used to bind compiled objects. gnatbind gnatchop is useful for renaming files to meet the standard Ada default file naming conventions. gnatchop gnatclean is used to remove files associated with a GNAT project. gnatclean gnatfind is the GNAT definition/use finder. gnatfind gnative2ascii is an encoding converter for Java. gnative2ascii gnatkr is used to determine the crunched name for a given file, when crunched to a specified maximum length. gnatkr gnatlink is used to link programs and build an executable file. gnatlink gnatls is the compiled unit browser. gnatls gnatmake is an automatic make facility. gnatmake gnatname will list the files associated with a GNAT project. gnatname gnatprep is the GNAT external preprocessor. gnatprep gnatxref is the GNAT cross-referencer. gnatxref gorbd is an object request broker daemon. gorbd grmic generates stubs for Remote Method Invocation. grmic grmid RMI activation system daemon. grmid grmiregistry starts a remote object registry on the current host. grmiregistry gserialver prints the serialVersionUID of the specified class. gserialver gtnameserv starts a naming service. gtnameserv jcf-dump prints information about Java class files. jcf-dump jv-convert converts files from one encoding to another. jv-convert rebuild-gcj-db Merge the per-solib databases made by aot-compile into one system-wide database. rebuild-gcj-db