Gpertea gcc

From Cbcb
Revision as of 17:26, 10 January 2011 by Gpertea (talk | contribs) (→‎Compiling gcc/g++ 4.5.x)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

GCC/G++ notes

Linking tips

When statically linking with g++, the linker expects -l arguments (libraries) to come after the files containing references to them, so the .o and .a files must appear before the -l flags in the g++ command line.

Compiling gcc/g++ 4.5.x

I prefer to prepare the GCC compiler such that it will statically link the C/C++ runtime libraries into the executables generated by the compiler. This way the portability of the precompiled binaries is maximized. In order to compile GCC/G++ this way:

  • Make sure gmp, mpfr and mpc source trees are under the main gcc-*/ source dir

For some mpfr versions, the configure script may need to be patched:

extra_mpfr_configure_flags='--with-gmp-build=$$r/$(HOST_SUBDIR)/gmp' 

.. replace the above line with:

extra_mpfr_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir" 

Assuming tcsh, and that the gcc and g++ source were unpacked under the gcc-4.5.1 subdirectory:

cd ..
mkdir gcc45obj
setenv CFLAGS '-O2'
setenv CXXFLAGS '-O2 -fno-implicit-templates'

../gcc-4.5.1/configure --prefix=/fs/sz-user-supported/Linux-x86_64/packages/gcc-4.5.1 \
 --enable-threads=posix --disable-shared --disable-multilib --enable-__cxa_atexit \
 --disable-libunwind-exceptions --disable-checking --build=x86_64-redhat-linux --disable-dssi \
 --enable-plugin --disable-nls --with-cpu=generic --enable-languages=c,c++

make CFLAGS='-O2' BOOT_CFLAGS='-O2' BOOT_FLAGS='-O2' STAGE1_CFLAGS='-O2' LIBCFLAGS='-O2' \
LIBCXXFLAGS='-O2 -fno-implicit-templates' CXXFLAGS='-O2' bootstrap-lean

Building may take a long time. After it is done, installing it is simply a matter of running

make install