Difference between revisions of "GCC"

From CBLFS
Jump to navigationJump to search
(Non-Multilib)
m (Multilib: f95 language option is deprecated ; modified to 'fortran')
 
(19 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 
<div style="font-size: 5em; color: red;">BIG FAT WARNING!</div><br/>
 
<div style="font-size: 5em; color: red;">BIG FAT WARNING!</div><br/>
 
'''You are about to over-write your currently installed ''GCC''. If you have ''ANY'' doubts that this may fail. Do not continue. Also, Do not continue with ''make install'' unless you are ''100% confident'' that your build was successful!'''
 
'''You are about to over-write your currently installed ''GCC''. If you have ''ANY'' doubts that this may fail. Do not continue. Also, Do not continue with ''make install'' unless you are ''100% confident'' that your build was successful!'''
<div style="font-size: 2em; color: red;">This page is still under development!</div><br/>
 
  
 
{| style="text-align: left; background-color: AliceBlue;"
 
{| style="text-align: left; background-color: AliceBlue;"
|-
+
|-valign="top"
!Download Source:
+
!Downcload Source:
| http://ftp.gnu.org/gnu/gcc/gcc-4.1.1/gcc-4.1.1.tar.bz2
+
| http://ftp.gnu.org/gnu/gcc/gcc-{{GCC-Version}}/gcc-{{GCC-Version}}.tar.bz2
|-
 
!Download Patch:
 
| http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/gcc-4.1.1-PR20425-1.patch
 
 
|}
 
|}
  
 
----
 
----
 +
 +
'''An Ada compiler is not built on this page.'''
 +
 +
{{Package-Introduction|The GCC package contains GNU compilers.|http://gcc.gnu.org/}}
  
 
== Dependencies ==
 
== Dependencies ==
Line 21: Line 21:
 
* [[GMP]]
 
* [[GMP]]
 
* [[MPFR]]
 
* [[MPFR]]
 +
=== Optional (Java's Classpath Library Can Use) ===
 +
* [[LibXML2]]
 +
* [[LibXSLT]]
 +
* [[Gtk2]]
 +
* [[cairo]]
 +
* [[Pango]]
 +
* [[Qt3]]
 +
* [[Qt4]]
 +
* [[ALSA]]
 +
* [[Unzip]]
 +
* [[Zip]]
  
 
== Non-Multilib ==
 
== Non-Multilib ==
  
  Write-Me!
+
On a '''Pure64''' system, apply the following patch:
 +
 
 +
  patch -Np1 -i ../gcc-{{GCC-Version}}-pure64-1.patch
 +
 
 +
Apply a sed substitution that will suppress the installation of libiberty.a. The version of libiberty.a that was provided by Binutils during the initial CLFS build will be retained:
 +
 
 +
  sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
 +
 
 +
The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:
 +
 
 +
  mkdir -v ../gcc-build &&
 +
  cd ../gcc-build
 +
 
 +
Configure gcc, adding the additional language support you require to the --enable-languages= switch.  '''Note:'''  This configuration does not include all supported languages.
 +
 
 +
  ../gcc-{{GCC-Version}}/configure --prefix=/usr --libdir=/usr/lib \
 +
    --libexecdir=/usr/lib --enable-shared --enable-threads=posix \
 +
    --enable-__cxa_atexit --enable-c99 --enable-long-long \
 +
    --enable-clocale=gnu --disable-libstdcxx-pch --disable-multilib \
 +
    --enable-languages=c,c++,objc,fortran,java
 +
 
 +
Compile gcc:
 +
 
 +
  make bootstrap
 +
 
 +
The gcc test suite is vitally, critically important.  Do not skip it under any circumstances.  The GCC test suite is very comprehensive and is almost guaranteed to generate a few failures.  Test the results, but don't stop at errors:
 +
 
 +
  make -k check
 +
 
 +
To see the results of the the test suite, issue the following command:
 +
 
 +
  ../gcc-{{GCC-Version}}/contrib/test_summary
  
== Multilib ==
+
* For only the summaries, pipe the output through grep -A7 Summ.
 +
 
 +
'''''At this time only proceed if you are 100% positive that you have built a sane compiler.'''''
 +
 
 +
As the root user, install the collection of compilers:
 +
 
 +
  make install &&
 +
  ln -sfv ../usr/bin/cpp /lib &&
 +
  ln -sfv gcc /usr/bin/cc &&
 +
  chown -Rv root:root /usr/lib/gcc/$(gcc -dumpmachine)/{{GCC-Version}}/include &&
 +
 
 +
If you included Java as one of the languages, create the following symlink:
 +
 
 +
  ln -sfv `find /usr/lib/gcc -name ffitarget.h` /usr/include
 +
 
 +
=== Command Explanations ===
 +
 
 +
''--enable-shared'': Build shared versions of libraries, if shared libraries are supported on the target platform. Shared libraries are enabled by default on all platforms that support shared libraries.
 +
 
 +
''--enable-threads=posix'': This enables C++ exception handling for multi-threaded code according to the POSIX/Unix98 standard.
 +
 
 +
''--enable-__cxa_atexit'': This option allows use of __cxa_atexit, rather than atexit, to register C++ destructors for local statics and global objects and is essential for fully standards-compliant handling of destructors. It also affects the C++ ABI and therefore results in C++ shared libraries and C++ programs that are interoperable with other Linux distributions.
 +
 
 +
''--enable-c99'': Enable C99 support for C programs.
 +
 
 +
''--enable-long-long'': Enables long long support in the compiler.
 +
 
 +
''--enable-clocale=gnu'': This is a failsafe for incomplete locale data.
 +
 
 +
''--enable-languages=c,c++,objc,fortran,java'': This command tells configure which languages you wish to build compilers for. You can modify this command to add or removed the various languages that GCC supports.
 +
 
 +
''--disable-multilib'': Specify that multiple target libraries to support different target variants, calling conventions, etc should not be built. The default is to build a predefined set of them.
 +
 
 +
''--disable-libstdcxx-pch'': Do not build the pre-compiled header (PCH) for libstdc++. It takes up a lot of space, and we have no use for it.
 +
 
 +
'''ln -v -sf ../usr/bin/cpp /lib''': This creates a link in /lib to the C PreProcessor. There are packages that expect it to be installed in the /lib directory.
  
The following patch fixes the searching of multilib dirs for specs file. The patch standardizes the gcc drivers path iteration functions, ensuring multilib directories are searched in the correct order. This fixes various issues, most noticably with libtool on multilib systems:
+
'''ln -v -sf gcc /usr/bin/cc''': Some packages use the more generic '''cc''' command instead of '''gcc''', so we need a symlink to '''gcc''' allowing them to call '''gcc''' in that manner.
  
patch -Np1 -i ../gcc-4.1.1-PR20425-1.patch
+
'''chown -Rv root:root /usr/lib/gcc/$(gcc -dumpmachine)/4.1.1/include''': If you build the package as a user other than root, then root won't own the files. In order to correct this, we chown them to root (both user and group).
 +
 
 +
== Multilib ==
  
 
Suppress the installation of libiberty.a. The version of libiberty.a provided by Binutils will be used instead:
 
Suppress the installation of libiberty.a. The version of libiberty.a provided by Binutils will be used instead:
Line 43: Line 122:
 
Configure GCC:
 
Configure GCC:
  
  ../gcc-4.1.1/configure --prefix=/usr --libdir=/usr/lib64 \
+
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH64}" &&
     --libexecdir=/usr/lib64 --enable-shraed --enable-threads=posix \
+
  ../gcc-{{GCC-Version}}/configure --prefix=/usr --libdir=/usr/lib64 \
 +
     --libexecdir=/usr/lib64 --enable-shared --enable-threads=posix \
 
     --enable-__cxa_atexit --enable-c99 --enable-long-long \
 
     --enable-__cxa_atexit --enable-c99 --enable-long-long \
     --enable-clocale=gnu --disable-libstdcxx-pch \
+
     --enable-clocale=gnu --disable-libstdcxx-pch --enable-multilib \
     --enable-languages=c,c++,objc,f95,ada,java,treelang
+
     --enable-languages=c,c++,objc,fortran,java,treelang
  
 
Compile GCC:
 
Compile GCC:
  
  make bootstrap
+
  make bootstrap &&
 +
unset PKG_CONFIG_PATH
  
Test the Results, But do not stop at errors:
+
Test the results, but do not stop at errors:
  
 
  make -k check
 
  make -k check
Line 59: Line 140:
 
The -k flag is used to make the test suite run through to completion and not stop at the first failure. The GCC test suite is very comprehensive and is almost guaranteed to generate a few failures. To receive a summary of the test suite results, run:
 
The -k flag is used to make the test suite run through to completion and not stop at the first failure. The GCC test suite is very comprehensive and is almost guaranteed to generate a few failures. To receive a summary of the test suite results, run:
  
  ../gcc-4.1.1/contrib/test_summary
+
  ../gcc-{{GCC-Version}}/contrib/test_summary
  
 
* For only the summaries, pipe the output through grep -A7 Summ.
 
* For only the summaries, pipe the output through grep -A7 Summ.
Line 68: Line 149:
  
 
  make install &&
 
  make install &&
  ln -v -sf ../usr/bin/cpp /lib &&
+
  ln -sfv ../usr/bin/cpp /lib &&
  ln -v -sf gcc /usr/bin/cc &&
+
  ln -sfv gcc /usr/bin/cc &&
  chown -v -R root:root \
+
  chown -Rv root:root /usr/lib64/gcc/$(gcc -dumpmachine)/{{GCC-Version}}/include &&
    /usr/lib64/gcc/$(gcc -dumpmachine)/4.1.1/include &&
+
  chown -Rv root:root /usr/lib64/gcc/$(gcc -dumpmachine)/{{GCC-Version}}/ada{lib,include}
  chown -v -R root:root \
 
    /usr/lib64/gcc/$(gcc -dumpmachine)/4.1.1/ada{lib,include}
 
  
 
The '''libffi''' interface header is installed in a location where other packages will not be able to find it. If you included Java as one of the installed languages, create a symbolic link in '''/usr/include''' to remedy this:
 
The '''libffi''' interface header is installed in a location where other packages will not be able to find it. If you included Java as one of the installed languages, create a symbolic link in '''/usr/include''' to remedy this:
  
  ln -v -sf `find /usr/lib64/gcc -name ffitarget.h` /usr/include
+
  ln -sfv `find /usr/lib64/gcc -name ffitarget.h` /usr/include
 +
 
 +
= Contents =
 +
 
 +
{| style="text-align: left;"
 +
|-valign="top"
 +
! Installed Programs:
 +
| addr2name.awk, fastjar, gcj, gcj-dbtool,gcjh, gfortran, gij, gjnih, grepjar, grmic, grmiregistry, gtreelang, jcf-dump, jv-convert, jv-scan and architecture specific names for gcj and gcjh
 +
|-valign="top"
 +
! Installed Libraries:
 +
| libffi.{so,a}, libgcj.{so,a}, libgfortran.{so,a}, libgfortranbegin.a, libgij.{so,a}, libobjc.{so,a} and numerous other run-time libraries and executables in /usr/lib/gcc
 +
|-valign="top"
 +
! Installed Directories:
 +
| /usr/include/c++/4.0.3/{gcj,gnu,java,javax,org}, /usr/lib/gcj-4.0.3, /usr/lib/security and /usr/share/java
 +
|}
 +
 
 +
=== Short Descriptions ===
 +
 
 +
{| style="text-align: left;"
 +
|-valign="top"
 +
! addr2name.awk
 +
| emulates some of the functionality of addr2line for those systems that don't have it.
 +
|-valign="top"
 +
! fastjar
 +
| an attempt at creating a feature-for-feature copy of Sun's JDK's '''jar''' command . It's 50-100 times faster than '''jar'''.
 +
|-valign="top"
 +
! gcj
 +
| is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile Java source code to Java bytecode (class files) or directly to native machine code, and Java bytecode to native machine code.
 +
|-valign="top"
 +
! gcj-dbtool
 +
| is a tool for creating and manipulating class file mapping databases.
 +
|-valign="top"
 +
! gcjh
 +
| generates header files from Java class files.
 +
|-valign="top"
 +
! gfortran
 +
| is a Fortran 95 front end to GCC.
 +
|-valign="top"
 +
! gij
 +
| is the GNU interpreter for Java bytecode.
 +
|-valign="top"
 +
! gjnij
 +
| is used to generate JNI header files from class files. Running it is equivalent to running gcjh -jni.
 +
|-valign="top"
 +
! grepjar
 +
| searches jar files for a pattern.
 +
|-valign="top"
 +
! grmic
 +
| is a utility included with libgcj which generates stubs for remote objects.
 +
|-valign="top"
 +
! grmiregistry
 +
| starts a remote object registry on the current host.
 +
|-valign="top"
 +
! gtreelang
 +
| is Treelang front end for GCC. Treelang is a sample language, useful only to help people understand how to implement a new language front end to GCC. It is not a useful language in itself other than as an example or basis for building a new language. Therefore only language developers are likely to have an interest in it.
 +
|-valign="top"
 +
! jcf-dump
 +
| is a class file examiner, similar to '''javap.''' It will print information about a number of classes, which are specified by class name or file name.
 +
|-valign="top"
 +
! jv-convert
 +
| is a utility included with "libgcj" which converts a file from one encoding to another.  It is similar to the Unix iconv utility.
 +
|-valign="top"
 +
! jv-scan
 +
| can be used to print information about a Java source file.
 +
|}
 +
 
 +
[[Category:Programming]]

Latest revision as of 17:01, 12 January 2010

BIG FAT WARNING!


You are about to over-write your currently installed GCC. If you have ANY doubts that this may fail. Do not continue. Also, Do not continue with make install unless you are 100% confident that your build was successful!

Downcload Source: http://ftp.gnu.org/gnu/gcc/gcc-4.2.2/gcc-4.2.2.tar.bz2

An Ada compiler is not built on this page.

Introduction to GCC

The GCC package contains GNU compilers.

Project Homepage: http://gcc.gnu.org/

Dependencies

Recommended

Optional (Required to Build the Fortran Compiler)

Optional (Java's Classpath Library Can Use)

Non-Multilib

On a Pure64 system, apply the following patch:

 patch -Np1 -i ../gcc-4.2.2-pure64-1.patch

Apply a sed substitution that will suppress the installation of libiberty.a. The version of libiberty.a that was provided by Binutils during the initial CLFS build will be retained:

 sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in

The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:

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

Configure gcc, adding the additional language support you require to the --enable-languages= switch. Note: This configuration does not include all supported languages.

 ../gcc-4.2.2/configure --prefix=/usr --libdir=/usr/lib \
   --libexecdir=/usr/lib --enable-shared --enable-threads=posix \
   --enable-__cxa_atexit --enable-c99 --enable-long-long \
   --enable-clocale=gnu --disable-libstdcxx-pch --disable-multilib \
   --enable-languages=c,c++,objc,fortran,java

Compile gcc:

 make bootstrap

The gcc test suite is vitally, critically important. Do not skip it under any circumstances. The GCC test suite is very comprehensive and is almost guaranteed to generate a few failures. Test the results, but don't stop at errors:

 make -k check

To see the results of the the test suite, issue the following command:

 ../gcc-4.2.2/contrib/test_summary
  • For only the summaries, pipe the output through grep -A7 Summ.

At this time only proceed if you are 100% positive that you have built a sane compiler.

As the root user, install the collection of compilers:

 make install &&
 ln -sfv ../usr/bin/cpp /lib &&
 ln -sfv gcc /usr/bin/cc &&
 chown -Rv root:root /usr/lib/gcc/$(gcc -dumpmachine)/4.2.2/include &&

If you included Java as one of the languages, create the following symlink:

 ln -sfv `find /usr/lib/gcc -name ffitarget.h` /usr/include

Command Explanations

--enable-shared: Build shared versions of libraries, if shared libraries are supported on the target platform. Shared libraries are enabled by default on all platforms that support shared libraries.

--enable-threads=posix: This enables C++ exception handling for multi-threaded code according to the POSIX/Unix98 standard.

--enable-__cxa_atexit: This option allows use of __cxa_atexit, rather than atexit, to register C++ destructors for local statics and global objects and is essential for fully standards-compliant handling of destructors. It also affects the C++ ABI and therefore results in C++ shared libraries and C++ programs that are interoperable with other Linux distributions.

--enable-c99: Enable C99 support for C programs.

--enable-long-long: Enables long long support in the compiler.

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

--enable-languages=c,c++,objc,fortran,java: This command tells configure which languages you wish to build compilers for. You can modify this command to add or removed the various languages that GCC supports.

--disable-multilib: Specify that multiple target libraries to support different target variants, calling conventions, etc should not be built. The default is to build a predefined set of them.

--disable-libstdcxx-pch: Do not build the pre-compiled header (PCH) for libstdc++. It takes up a lot of space, and we have no use for it.

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

ln -v -sf gcc /usr/bin/cc: Some packages use the more generic cc command instead of gcc, so we need a symlink to gcc allowing them to call gcc in that manner.

chown -Rv root:root /usr/lib/gcc/$(gcc -dumpmachine)/4.1.1/include: If you build the package as a user other than root, then root won't own the files. In order to correct this, we chown them to root (both user and group).

Multilib

Suppress the installation of libiberty.a. The version of libiberty.a provided by Binutils will be used instead:

sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in

Create the Build Directory:

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

Configure GCC:

export PKG_CONFIG_PATH="${PKG_CONFIG_PATH64}" &&
../gcc-4.2.2/configure --prefix=/usr --libdir=/usr/lib64 \
    --libexecdir=/usr/lib64 --enable-shared --enable-threads=posix \
    --enable-__cxa_atexit --enable-c99 --enable-long-long \
    --enable-clocale=gnu --disable-libstdcxx-pch --enable-multilib \
    --enable-languages=c,c++,objc,fortran,java,treelang

Compile GCC:

make bootstrap &&
unset PKG_CONFIG_PATH

Test the results, but do not stop at errors:

make -k check

The -k flag is used to make the test suite run through to completion and not stop at the first failure. The GCC test suite is very comprehensive and is almost guaranteed to generate a few failures. To receive a summary of the test suite results, run:

../gcc-4.2.2/contrib/test_summary
  • For only the summaries, pipe the output through grep -A7 Summ.

At this time only proceed if you are 100% positive that you have built a sane compiler.

Install GCC:

make install &&
ln -sfv ../usr/bin/cpp /lib &&
ln -sfv gcc /usr/bin/cc &&
chown -Rv root:root /usr/lib64/gcc/$(gcc -dumpmachine)/4.2.2/include &&
chown -Rv root:root /usr/lib64/gcc/$(gcc -dumpmachine)/4.2.2/ada{lib,include}

The libffi interface header is installed in a location where other packages will not be able to find it. If you included Java as one of the installed languages, create a symbolic link in /usr/include to remedy this:

ln -sfv `find /usr/lib64/gcc -name ffitarget.h` /usr/include

Contents

Installed Programs: addr2name.awk, fastjar, gcj, gcj-dbtool,gcjh, gfortran, gij, gjnih, grepjar, grmic, grmiregistry, gtreelang, jcf-dump, jv-convert, jv-scan and architecture specific names for gcj and gcjh
Installed Libraries: libffi.{so,a}, libgcj.{so,a}, libgfortran.{so,a}, libgfortranbegin.a, libgij.{so,a}, libobjc.{so,a} and numerous other run-time libraries and executables in /usr/lib/gcc
Installed Directories: /usr/include/c++/4.0.3/{gcj,gnu,java,javax,org}, /usr/lib/gcj-4.0.3, /usr/lib/security and /usr/share/java

Short Descriptions

addr2name.awk emulates some of the functionality of addr2line for those systems that don't have it.
fastjar an attempt at creating a feature-for-feature copy of Sun's JDK's jar command . It's 50-100 times faster than jar.
gcj is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile Java source code to Java bytecode (class files) or directly to native machine code, and Java bytecode to native machine code.
gcj-dbtool is a tool for creating and manipulating class file mapping databases.
gcjh generates header files from Java class files.
gfortran is a Fortran 95 front end to GCC.
gij is the GNU interpreter for Java bytecode.
gjnij is used to generate JNI header files from class files. Running it is equivalent to running gcjh -jni.
grepjar searches jar files for a pattern.
grmic is a utility included with libgcj which generates stubs for remote objects.
grmiregistry starts a remote object registry on the current host.
gtreelang is Treelang front end for GCC. Treelang is a sample language, useful only to help people understand how to implement a new language front end to GCC. It is not a useful language in itself other than as an example or basis for building a new language. Therefore only language developers are likely to have an interest in it.
jcf-dump is a class file examiner, similar to javap. It will print information about a number of classes, which are specified by class name or file name.
jv-convert is a utility included with "libgcj" which converts a file from one encoding to another. It is similar to the Unix iconv utility.
jv-scan can be used to print information about a Java source file.
Retrieved from "?title=GCC&oldid=19860"