LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   *BSD (https://www.linuxquestions.org/questions/%2Absd-17/)
-   -   building cross compiler, having issues (https://www.linuxquestions.org/questions/%2Absd-17/building-cross-compiler-having-issues-669480/)

moonlightcheese 09-12-2008 09:35 AM

building cross compiler, having issues
 
this is my first time trying to build a compiler from the gnu compiler collection source so, inevitably, i'm having a few issues. i'm trying to build a cross compiler for arm4 targets on my virtual machine, running FreeBSD 7. I'm doing this for building arm4 code for an arm7tdmi chip in the gameboy advance for an operating system project. i have downloaded libgba and the appropriate headers but i need a compiler that will build raw binaries (not ELF compatible, should be a.out old binaries i think) that i can pull over to my flash cartridge and run on the system. here's what i've done so far:

1. downloaded binutils 2.18: won't compile for arm or i386 targets
2. downloaded binutils 2.9: won't compile for arm or i386 targets
3. downloaded binutils 2.8: won't compile for arm or i386 targets
4. make install gcc41 in /usr/ports: gcc upgraded successfully
5. tried to compile gcc43 from source: no success for i386 target: missing gmp, mpfr
6. make install gmp and mpfr in /usr/ports: successful
7. tried again to compile gcc43: no success, different error:
Code:

sed -e 's/@gcc_version@//' < > mkheadersT
Syntax error: redirection unexpected

right now i'd really just like for anything to compile properly. i'm starting to feel a bit overwhelmed. i realized building the compiler would be a huge undertaking but now i'm stuck...

should i even bother compiling from source? it seems impossible. i'm trying to gain a greater understanding of gcc and compilation for BSD systems as i'm hoping to soon make a career out of embedded systems programming... maybe i'm just a noob but i was hoping that it would be possible to download and compile gcc from source for any target OS? maybe not...

Is there some way to build a compiler using ./configure options from the ports tree? I'm thinking since that worked, perhaps there's a way to install with --prefix=/path/to/tools --target=arm4l or something like that... any help would be great.

i'd prefer to build this from the source available from gnu rather than ports just to get the experience and learn more about gcc but if that's not possible or no one has the info, compiling from ports would be sufficient.

pinniped 09-13-2008 02:09 AM

Read the GCC build/install documentation which came with the source very carefully (then read it again a few times over). The GFP and MPFR messages suggest that you are trying to compile FORTRAN. For a first try, only build the C compiler. In the case of building the compiler, the 'BUILD' machine is the machine which the compiler is being built on, the 'HOST' machine is the one which the compiler will run on (usually the same as BUILD), and the 'TARGET' machine is the machine which the compiler will build code for.

When the compiler has been built you will need to start building up the libraries, making sure you're invoking your cross-compiler. You also need to build the build tools (linker/loader, etc). As you build other programs you need to start passing a lot of parameters and setting a lot of environment variables to make sure the correct libs are being linked, correct headers being included, etc. This part is often such a nuisance that people patch the compiler source before building it so that the libs, includes, etc are all set to a location different from your installed system.

For the output, if you really want an old-style a.out (really not recommended), you need to add "-maout" to your CFLAGS environment variable.

I hope that helps get you started - have fun. :)


All times are GMT -5. The time now is 01:39 PM.