OS Specific Toolchain: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Fix whomever wrote this code not doing his homework
Move build instructions to the new article 'Hosted GCC Cross-Compiler'
Line 270: Line 270:


= Building =
= Building =
{{Main|Hosted GCC Cross-Compiler}}
Configuring and building should be done in the build-xxx directory specific to the package you are building. Do not attempt to configure or build within the source directory. It is a method not supported by either myself or GNU. The configure option --disable-nls is optional, although I haven't tested without it.


Your OS specific toolchain is built differently from the introductory <tt>i686-elf</tt> toolchain as it has a user-space and standard library. In particular, you need to ensure your libc meets the minimum requirements for libgcc. You need to install the standard library headers into your [[Meaty_Skeleton#System_Root|System Root]] before building the cross-compiler. You need to tell the cross-binutils and cross-gcc where the system root is via the configure option <tt>--with-sysroot=/path/to/sysroot</tt>. You can then build your libc with your cross-compiler and then finally libstdc++ if desired.
Note that on multi-processor build machines, you may be able to speed the build process by adding "-j X" (where X is the number of jobs to run in parallel) to the make commands below.

Also note that if your build environment requires you to make the install target as a different user (such as root), you'll need to add $PREFIX/bin to the $PATH environment variable for that user as well.

=== Note for Mac OS X users ===
The [[GCC_Cross-Compiler#MacOS_users.2C_beware|warning]] listed in the GCC Cross-Compiler article applies here as well. Make sure to read it and set up $CC/$CXX/$CPP/$LD to point to a "real" GCC, as opposed to LLVM-GCC, or your build will most likely fail!

== Binutils ==
From /usr/src/build-binutils, run
../binutils-2.18/configure --target=$TARGET --prefix=$PREFIX --disable-werror
make
make install
export PATH=$PATH:$PREFIX/bin

== GCC ==
From /usr/src/build-gcc, run (only use --enable-languages=c if you haven't downloaded and unpacked gcc-g++!)
../gcc-4.2.1/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++
make all-gcc
make install-gcc

You will also want libgcc. Run
make all-target-libgcc
make install-target-libgcc

== Newlib ==
From /usr/src/build-newlib, run
../newlib-1.15.0/configure --target=$TARGET --prefix=$PREFIX
make
make install
and optionally
make install-info

== Libstdc++ ==
From /usr/src/build-gcc, run
make
make install
Note that libstdc++ can only be built after installing newlib, as it depends on libc.


= Common errors =
= Common errors =