GCC Cross-Compiler: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Solar (talk | contribs)
m →‎Tested on...: No sense in having similar information in two places.
Solar (talk | contribs)
→‎Preparation: Some rewording.
Line 88: Line 88:
</source>
</source>


The prefix will configure the build process so that all the files of your cross-compiler environment end up in /usr/local/cross, without disturbing your "normal" compiler setup. This tutorial has been shown to work in the same way for the x86_64-elf target, for building 64 bit executables (GCC 4.3.x). In order to do this, simply export TARGET as x86_64-elf instead of i586-elf.
The prefix will configure the build process so that all the files of your cross-compiler environment end up in /usr/local/cross. You can change that prefix to whatever you like (e.g., /opt/cross or $HOME/cross would be options). Technically, you could even install directly to /usr, so that your cross-compiler would reside alongside your system compiler, but that is not recommended for several reasons (like risking to overwrite your system compiler if you get TARGET wrong, or getting into conflict with your system's package management).

This tutorial has been shown to work in the same way for the x86_64-elf target, for building 64 bit executables (GCC 4.3.x). In order to do this, simply export TARGET as x86_64-elf instead of i586-elf.


==== MacOS users, beware ====
==== MacOS users, beware ====


The makefiles of binutils and GCC use the `$(CC)` variable to invoke the compiler. By default, on MacOS this resolves to `gcc`, which is actually not "the real thing", but `llvm-gcc`. That wouldn't be so bad if `llvm-gcc` didn't have this nasty problem of not being able to compile the GCC sources into a ''functional'' binary. (Bugs have been reported, but that doesn't help you here and now.)
The makefiles of binutils and GCC use the `$(CC)` variable to invoke the compiler. On MacOS, this resolves to `gcc` by default, which is actually not the "real thing", but `llvm-gcc`. That wouldn't be so bad, but `llvm-gcc` is not able to compile the GCC sources into a ''functional'' binary. (Bugs have been reported, but that doesn't help you here and now.)


Luckily, MacOS ''does'' have a "real" GCC installed, too. We just have to tell make to use it instead of the default `llvm-gcc`.
MacOS ''does'' have a "real" GCC installed, too. You just have to tell `make` to use it instead of `llvm-gcc`:


<source lang="bash">
<source lang="bash">