Thursday, 30 July 2009

gcc-4.4.1 with graphite framework

Ok, so the recent release of the beloved (?) gcc compiler provides not only usual bug fixes and enhancements but also some exciting features such as the graphite framework which aims to provide better optimization of a compiled code (loops to be precise) thus resulting in faster binaries. There's some interesting theory behind it too! And here is a forum discussion just in case something goes wrong ;)

Is it faster? I dunno...feels like it ;) Is it bleeding edge? Oh yeah! ;] So make some backup, etc., ya've been warned!

First, enable the graphite USE flag in /etc/make.conf. Next, keyword two required libraries - for a x86_64 box this is needed:

echo 'dev-libs/ppl ~amd64' >> /etc/portage/package.keywords
echo 'dev-libs/cloog-ppl ~amd64' >> /etc/portage/package.keywords

Ready to emerge!

# emerge -av gcc

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild N ] dev-libs/ppl-0.10.2 USE="-doc (-pch) -prolog -test -watchdog" 9,590 kB [0]
[ebuild N ] dev-libs/cloog-ppl-0.15.3 788 kB [0]
[ebuild R ] sys-devel/gcc-4.4.1-r1 USE="graphite* gtk hardened mudflap nls nptl (-altivec) -bootstrap -build -doc (-fixed-point) -fortran -gcj -ip28 -ip32r10k -libffi (-multilib) -multislot (-n32) (-n64) -nocxx -objc -objc++ -objc-gc -openmp -test -vanilla" 0 kB [1]

Total: 3 packages (2 new, 1 reinstall), Size of downloads: 10,378 kB
Portage tree and overlays:
[0] /usr/portage
[1] /usr/local/toolchain-overlay

Would you like to merge these packages? [Yes/No]

few minutes later... ;)

# gcc -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.4.1-r1/work/gcc-4.4.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-espf --disable-libgomp --enable-cld --disable-libgcj --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.4.1-r1 p1.0, espf-0.3.1'
Thread model: posix
gcc version 4.4.1 (Gentoo Hardened 4.4.1-r1 p1.0, espf-0.3.1)


Ok, now it's time to adjust CCFLAGS. They should look similar to this (the last three options are important here):

CFLAGS="-O2 -march=native -pipe -floop-interchange -floop-strip-mine -floop-block"
CXXFLAGS="${CFLAGS}"


Rite...all set! Now the classics:

emerge binutils gcc glibc linux-headers && emerge -eav world


...is it faster then? ;]

5 comments:

  1. Emerge didn't find it with me - had to use
    ebuild /usr/portage/sys-devel/gcc-4.4.1-r1
    Emerging would have just reinstalled gcc-4.3.2. Yes I synced, yes I did everything in this blog, yes I scoured the web before resorting to a manual merge.

    ReplyDelete
  2. Hi,
    that's probably because recently the repository has been moved into a layman overlay and now is available as 'hardened-development' directly via layman :). I don't think that the old one is updated anymore... Also make sure that you have keyworded/unmasked all packages (gcc and glibc) So do emerge layman (and git) after getting stage3 and use it to get the hardened repository... I'm building a new hardened box now with encrypted root partition using LUKS so I'll be posting an updated howto soon...stay tuned! ;]

    ReplyDelete
  3. Great! It now actually shows gcc-4.4.1 with emerge --search, but emerge initially wanted to downgrade to 4.3.2. So I added gcc to the package.keywords file and now it works. Now I have a new tool to play with that I wouldn't have found otherwise and a better compiler (installed the right way). Thanks!

    ReplyDelete
  4. No problem, glad I could help :) Enjoy!

    ReplyDelete
  5. Thanks for sharing! I'm going to try this at home.

    ReplyDelete

Have your say: