LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Cross compiler building (https://www.linuxquestions.org/questions/linux-from-scratch-13/cross-compiler-building-864491/)

dejavih 02-23-2011 05:57 AM

Cross compiler building
 
Hi all!

I'm a student from Spain and I'm trying to build a arm cross-compiler, I've searched on the web but I haven't found anything and I don't get it to work.

I hope that I've selected the correct subforum, if it isn't please move it to the correct subforum.

I've followed the next steps:

1. Install binutils:
./configure --target=$TARGET --prefix=$PREFIX --enable-multilib --disable-werror && make all install
2.Install "little gcc":
./configure --target=$TARGET --prefix=$PREFIX --with-newlib --without-headers --disable-shared --enable-languages=c,c++ --disable-werror --with-gmp-include=/home/javi/CROSS/GMPTILEINTEL/include --with-gmp-lib=/home/javi/CROSS/GMPTILEINTEL/lib --with-mpfr-include=/home/javi/CROSS/MPFRTILEINTEL/include --with-mpfr-lib=/home/javi/CROSS/MPFRTILEINTEL/lib && make all-gcc && make install-gcc
3. Install newlib:
./configure --target=$TARGET --prefix=$PREFIX --enable-multilib --disable-werror && make all && make install
4. Build again gcc("big gcc"):

./configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++ --enable-multilib --with-newlib --disable-werror --with-headers=/home/javi/CROSS/CROSSTOOLTILE/include && make all-gcc && make install-gcc


In the fourth step, if I use "--prefix=$PREFIX" the configure command doesn't work, the prompt gives me an error that I read on the web that I can resolve it changing the --prefix, ok, so I use the same command with another rute in --prefix, i.e:

./configure --target=$TARGET --prefix=/home/javi/workkk --enable-languages=c,c++ --enable-multilib --with-newlib --disable-werror --with-headers=/home/javi/CROSS/CROSSTOOLTILE/include && make all-gcc && make install-gcc

Well, everything have been installed, but if I try to compile a simple HelloWorld.c file with /home/javi/workkk/arm-elf-gcc and it dosn't work because arm-elf-gcc use i686-as and i686-ld (i686 is the architecture where I'm building the cross-compiler).

I know that arm-elf-gcc is using i686-as and i686-ld because when arm-elf-gcc reach to the assembler step the prompt says me that it doesn't understand any arm instruction.

I would like know how can I resolve it, I've read several manuals about the issue but I don't get to build a correct cross compiler for one reason or another.

Best Regards!

theNbomr 02-23-2011 09:43 AM

You should use a too like Crosstool-NG to build cross toolchains. There are way too many variables and problems to solve, and the authors of crosstool-ng have solved most of them.
--- rod.

dejavih 02-23-2011 10:40 AM

Quote:

Originally Posted by theNbomr (Post 4268588)
You should use a too like Crosstool-NG to build cross toolchains. There are way too many variables and problems to solve, and the authors of crosstool-ng have solved most of them.
--- rod.

Thanks for answering!

I didn't know this project, but in any case I would like to build a cross toolchain manually.

theNbomr 02-23-2011 12:06 PM

Quote:

Originally Posted by dejavih (Post 4268652)
I would like to build a cross toolchain manually.

I can't imagine why. Good luck with that. Even with a tool like crosstool-ng, there are plenty enough challenges, especially for ARM CPUs and all of its various nuances.

--- rod.

knudfl 02-23-2011 03:12 PM

Quote:

/home/javi/workkk/arm-elf-gcc and it dosn't work because arm-elf-gcc use i686-as
and i686-ld (i686 is the architecture where I'm building the cross-compiler).
I think it is possible to build gcc so it will know the correct linker.
( export LD=arm-ld etc. may also work.)

But then again : We have Crosstool-NG : So why use an extra week (month ?) with tries
to build a tool-chain ?
More reasons to use Crosstool-NG : It's constantly being updated. No other tools have
all the Crosstool-NG benefits.

If you want to know, how to build a tool chain, the usually suggested method is:
Build LFS, 'Linux From Scratch' a couple of times. And then move on to CLFS :
'Cross Linux From Scratch' http://www.linuxfromscratch.org/lfs/
..

dejavih 02-24-2011 05:02 AM

Hi again!

I want to know how build a cross toolchain manually because in the future if I need build a cross toolchain for an architecture that isn't supported by crosstool-NG I would like to know how could I do.

knudfl I will test exporting the path to LD_LIBRARY_PATH. Also I've followed the steps from LFS book but I haven't had success.

Thanks!

p.d: sorry for my English

knudfl 02-24-2011 06:46 AM

Quote:

exporting the path to LD_LIBRARY_PATH
Not a library. Not an LD_LIBRARY_PATH. LD is a binary, like /usr/bin/ld

example : 'LD=/opt/arm/bin/arm-ld' simply defines which ld to use.

theNbomr 02-24-2011 09:11 AM

Quote:

Originally Posted by dejavih (Post 4269508)
I want to know how build a cross toolchain manually because in the future if I need build a cross toolchain for an architecture that isn't supported by crosstool-NG I would like to know how could I do.

Then why don't you spend some time learning the ways of crosstool-NG, and when the day comes that you need an unsupported architecture you can just add that to crosstool? There is a lot of good infrastructure built into crosstool, and you would be doing yourself a huge favour by using it. Once you see how things are done with it, you will understand this. Plus, you will be able to receive fame and glory for contributing a new architecture to a widely used tool.

--- rod

dejavih 02-25-2011 04:56 AM

Quote:

Originally Posted by knudfl (Post 4269581)
Not a library. Not an LD_LIBRARY_PATH. LD is a binary, like /usr/bin/ld

example : 'LD=/opt/arm/bin/arm-ld' simply defines which ld to use.

I think that I tested with this option but it doesn't work, but I'll try again just in case. Tomorrow (Saturday) I'll tell you the result that is when I be able to test this.

Quote:

Originally Posted by theNbomr (Post 4269696)
Then why don't you spend some time learning the ways of crosstool-NG, and when the day comes that you need an unsupported architecture you can just add that to crosstool? There is a lot of good infrastructure built into crosstool, and you would be doing yourself a huge favour by using it. Once you see how things are done with it, you will understand this. Plus, you will be able to receive fame and glory for contributing a new architecture to a widely used tool.

--- rod

This is a good idea, I'm going to learn about how crosstool-NG works, maybe this helps me to resolve the problem. In any case, I'll keep trying to do manually but looking at the crosstool-NG, so, any help will be grateful.

Thanks!!:)


All times are GMT -5. The time now is 02:38 AM.