Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.


  Search this Thread
Old 09-02-2011, 05:43 AM   #1
Registered: Oct 2003
Posts: 37

Rep: Reputation: 4

Hi there! I have noticed that on BCLFS under compilers there is no GNAT support so I took it a upon myself to make a howto.

Here we go!
Okay before we even start, let me tell you that this was actually a pain in the ass at first, but is pretty simple after you have failed the first 100 times. It is easier support GNAT if you start over, sadly Ada support within gcc doesn't like when you cross-compile too totally different versions of gcc, that being said I will guide you on how to build a fully functional Ada backend for your cross-compile tools (which will allow you to include the Ada backend later on).

First things first, follow the book up until Ch.4 "Setting Up the Environment" (we dont want to add host defines or targets just yet)...

There are some prerequisites.
Gcc 4.6.1
Gcc patch #1
Gcc patch #2
AdaCore's GNAT compiler (be sure to download the 2010 edition!) 'gnat-gpl-2010-x86_64-pc-linux-gnu-bin.tar.gz'

1. Make the directory '/fake-tools' and its link just as the book tells you how to do it for the cross-tools and tools directories.
As root:
mkdir -v ${CLFS}/fake-tools
ln -sv ${CLFS}/fake-tools /
chown -v clfs ${CLFS}/cross-tools
su - clfs
2. Install AdaCore's GNAT-GPL Compiler, make sure it's 2010 edition because 2011 removes a command from gnatbind that will cause this build to fail. So we unpack the tarball and install it.
tar -xvf gnat-gpl-2010-x86_64-pc-linux-gnu-bin.tar.gz
cd gnat-2010-x86_64-pc-linux-gnu-bin
make ins-all prefix=/cross-tools/oldgcc
3. Adjust the $PATH variable. This has to be done to tell the system where to find gnat and later on our new compiler.
export PATH=/cross-tools/oldgcc/bin:/cross-tools/bin:/fake-tools/bin:/usr/bin:/bin
4. Install binutils...
mkdir -v ../binutils-build
cd ../binutils-build
../binutils-2.21.51/configure --prefix=/fake-tools \
--disable-nls --disable-werror

make install

mkdir -v /fake-tools/lib 
ln -sv  /fake-tools/lib /fake-tools/lib64
5. Native GCC, the reason why we need to go through all this trouble is because gcc doesn't like to make cross-compilers that are not of the same version of the compiler you are using to cross-compile, so we are going to build a native up to date gcc with an ada backend we can use for the book.

First we need to patch:
patch -Np1 -i ../gcc-4.6.1-cross_compile-1.patch
patch -Np1 -i ../gcc-4.6.0-specs-1.patch
Note: Patch may tell you that Hunk#1 succeed with fuzz, do not worry about this!

I didn't build all gcc support libraries, because we don't actually want to link to these, we want gcc to build stand alone versions.
tar -jxf ../mpfr-3.0.1.tar.bz2
mv -v mpfr-3.0.1 mpfr
tar -jxf ../gmp-5.0.2.tar.bz2
mv -v gmp-5.0.2 gmp
tar -zxf ../mpc-0.9.tar.gz
mv -v mpc-0.9 mpc

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

../gcc-4.6.1/configure --prefix=/fake-tools --disable-nls \
--disable-shared --disable-multilib --disable-decimal-float \
--disable-threads --disable-libmudflap --disable-libssp \
--disable-libgomp --disable-libquadmath \
--disable-target-libiberty --disable-target-zlib \
--enable-languages=c,ada --without-ppl --without-cloog \
--enable-adalib --enable-bootstrap

make install
6. After gcc is finished, remove the old gnat compiler has we have a updated version of it now and change the $PATH variable yet again:
rm -rf /cross-tools/oldgcc
export PATH=/cross-tools/bin:/fake-tools/bin:/usr/bin:/bin
7. Continue with the rest of the CLFS install, do not forget to pass '--disable-target-libiberty --disable-target-zlib \
--enable-languages=c,ada --enable-adalib' to the configure script when you build gcc-static

8. Finally fix the $PATH and remove /fake-tools since they will not be needed anymore.
rm -rf /fake-tools
rm -rf ${CLFS}/fake-tools

9. All you need to do now is pass '--disable-target-libiberty --disable-target-zlib --enable-languages=c,ada --enable-adalib'to the rest of the gcc builds and you will have a fully working ada backend for gcc.

10. In final cross-gcc (before you build your temperary system) you need to create some symlinks or building any Ada libraries will fail.
I will give you an example, note that this has to be done to all the gnat tools, bind, gnat, gnatmake, etc as many scripts call these names not the full name of the compiler or tool.
cd /cross-tools/bin
ln -s x86_64_unknown-linux-gnu-gnatbind gnatbind

And now we have a fully functional Ada backend to be used in the rest of CLFS and BCLFS enjoy... if this was not any help to you, tell me to shut up and I'll be on my way. :P

Last edited by magiknight; 09-02-2011 at 05:49 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
CLFS x86_64 gnat... ProtoformX Linux From Scratch 2 09-19-2009 12:51 PM
Howto use paco in CLFS DaCapitalist Linux From Scratch 2 07-14-2009 10:53 AM
chown clfs:clfs mishap Louis_Carole Linux From Scratch 4 03-21-2007 07:40 PM
GCC Compile with GNAT BlackLabel Linux - Desktop 0 12-14-2006 12:22 PM
gcc? g++? gnat? huh? foohooblue Mandriva 1 02-10-2006 11:23 AM > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 07:37 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration