Thursday, October 13, 2011

Building gcc-4.3.4 on Fedora 15

Currently you need to rely on proprietary drivers to use CUDA or OpenCL on a GPU under Linux.

There is clover a OpenCL implementation capable of running on a CPU - but in my case I had to use CUDA. And CUDA requires gcc 4.3.4, which is not available for Fedora 15 natively, so we have to build it our self.
Actually it is quite straight to build it.
Install some requirements:
$ sudo yum install glibc-devel.i686 glibc-devel.x86_64 \
    gmp-devel mpfr-devel
Fetch the source:
$ mkdir gcc
$ cd gcc
$ curl -O \
   "ftp://ftp.gwdg.de/pub/misc/gcc/releases/gcc-4.3.4/gcc-4.3.4.tar.bz2"
And finally configure, build and install it. It took around 20minutes on my machine. I installed this gcc version not in my native PATH, as I didn't want any collisions, I choose ../build as a suitable destination. In this case you have to remember to modify your PATH and LD_LIBRARY_PATH environment variables. So the app (e.g. nvcc) in question is looking in the right path when calling gcc.
$ export DST="${PWD}/../build"
$ mkdir "$DST"
$ nice ./configure --prefix="$DST" \
    --with-gmp=/usr/lib/ --with-mpc=/usr/lib/ --with-mpfr=/usr/lib/
$ nice make -j8
$ make install
I can also consider adding the --program-suffix=4.3.4 to add the given suffix to all binaries, this makes sense when you install this build into %{_bindir} and %{_libdir}.
Finally you can launch nvcc or whatever application is requiring gcc-4.3.4.
$ PATH="${DST}/bin:$PATH" LD_LIBRARY_PATH="${DST}/lib64:${DST}/lib" \
    nvcc [...]

No comments:

Post a Comment