LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
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.

Notices

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

Rep: Reputation: 4
CLFS GNAT support HOWTO.


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
http://ftp.gnu.org/gnu/gcc/gcc-4.6.1/gcc-4.6.1.tar.bz2
Gcc patch #1
http://www.linuxfromscratch.org/patc...es_fix-1.patch
Gcc patch #2
http://www.linuxfromscratch.org/patc...ompile-1.patch
AdaCore's GNAT compiler (be sure to download the 2010 edition!) 'gnat-gpl-2010-x86_64-pc-linux-gnu-bin.tar.gz'
http://libre.adacore.com/libre/download2


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:
Code:
exit
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.
Code:
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.
Code:
export OLDPATH=$PATH
export PATH=/cross-tools/oldgcc/bin:/cross-tools/bin:/fake-tools/bin:/usr/bin:/bin
4. Install binutils...
Code:
mkdir -v ../binutils-build
cd ../binutils-build
../binutils-2.21.51/configure --prefix=/fake-tools \
--disable-nls --disable-werror

make
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:
Code:
patch -Np1 -i ../gcc-4.6.1-cross_compile-1.patch
gcc-4.6.1-startfiles_fix-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.
Code:
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
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:
Code:
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.
Code:
export PATH=$OLDPATH
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.
Code:
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.
 
  


Reply


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


All times are GMT -5. The time now is 10:03 PM.

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