buildrootschalter/toolchain
Thomas Petazzoni 05c75314c9 external-toolchain: Support for multilib toolchains
Multilib toolchains provide different versions of the base libraries
for different architecture variants. For example, the ARM Codesourcery
toolchain provides base libraries for ARMv5 (default), ARMv4t and
Thumb2.

Depending on the -march= argument passed to gcc, the sysroot used by
the compiler is therefore different. This means that the sysroot
location in CROSS-gcc -v cannot be used. Instead, we must use
CROSS-gcc -print-sysroot when available and fall back to the old way
if unavailable.

Moreover, we cannot simply copy the full sysroot as we used to do,
because the sysroot organization of multilib toolchain is more
complicated. In Codesourcery toolchains, we have :

 /
   etc      -- for ARMv5
   lib      -- for ARMv5
   sbin     -- for ARMv5
   usr      -- for ARMv5 (includes headers)
   armv4t
     etc    -- for ARMv4t
     lib    -- for ARMv4t
     sbin   -- for ARMv4t
     usr    -- for ARMv4t (no headers!)
   thumb2
     etc    -- for Thumb2
     lib    -- for Thumb2
     sbin   -- for Thumb2
     usr    -- for Thumb2 (no headers!)

So we have the default ARMv5 architecture variant that is installed in
the main directory, and we have subdirectories for the ARMv4t and
Thumb2 architecture variants.

Copying the full sysroot to the staging directory doesn't work. All
our packages are based on the fact that they should install libraries
in staging/usr/lib. But if ARMv4t is used, the compiler would only
look in staging/armv4t/usr/lib for libraries (even when overriding the
sysroot with the --sysroot option, the multilib compiler suffixes the
sysroot directory with the architecture variant if it matches a
recognized one).

Therefore, we have to copy only the sysroot that we are interested
in. This is rendered a little bit complicated by the fact that the
armv4t and thumb2 sysroot do not contain the headers since they are
shared with the armv5 sysroot.

So, this patch :

 * Modifies how we compute SYSROOT_DIR in order to use -print-sysroot
   if it exists. SYSROOT_DIR contains the location of the main sysroot
   directory, i.e the sysroot for the default architecture variant.

 * Defines ARCH_SUBDIR as the subdirectory in the main sysroot for the
   currently selected architecture variant (in our case, it can be
   ".", "armv4t" or "thumb2"). ARCH_SYSROOT_DIR is defined as the full
   path to the sysroot of the currently selected architecture variant.

 * Modifies copy_toolchain_lib_root (which copies a library to the
   target/ directory) so that libraries are taken from
   ARCH_SYSROOT_DIR instead of SYSROOT_DIR. This ensures that
   libraries for the correct architecture variant are properly copied
   to the target.

 * Modifies copy_toolchain_sysroot (which copies the sysroot to the
   staging/ directory), so that it copies the contents of
   ARCH_SYSROOT_DIR, and if needed, adds the headers from the main
   sysroot directory and a symbolic link (armv4t -> . or thumb2 -> .)
   to make the compiler believe that its sysroot is really in armv4t/
   or thumb2/.

Tested with Codesourcery 2009q1 ARM toolchain, Crosstool-NG ARM glibc
and ARM uClibc toolchains.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2010-04-17 02:09:38 +02:00
..
binutils Get rid of all usages of BR2_RECENT 2010-04-12 15:26:37 +02:00
ccache ccache: remove cleanup of documentation 2010-02-20 19:31:04 +01:00
dependencies target/cpio: cleanup 2010-04-09 11:04:32 +02:00
elf2flt get rid of broken nios2 support 2010-03-30 17:19:59 +02:00
external-toolchain external-toolchain: Support for multilib toolchains 2010-04-17 02:09:38 +02:00
gcc Get rid of all usages of BR2_RECENT 2010-04-12 15:26:37 +02:00
gdb get rid of broken nios2 support 2010-03-30 17:19:59 +02:00
kernel-headers Get rid of all usages of BR2_RECENT 2010-04-12 15:26:37 +02:00
mklibs toolchain/: get rid of unneeded $(strip ..) 2008-12-08 08:15:42 +00:00
sstrip toolchain/: get rid of unneeded $(strip ..) 2008-12-08 08:15:42 +00:00
uClibc Get rid of all usages of BR2_RECENT 2010-04-12 15:26:37 +02:00
Config.in toolchain: get rid of "binary" for external toolchain 2010-02-08 11:01:04 +01:00
Config.in.1 Use BR2_TOOLCHAIN_BUILDROOT instead of BR2_TOOLCHAIN_SOURCE 2009-12-14 23:54:47 +01:00
Config.in.2 Remove BR2_ENABLE_LOCALE_PREGENERATED 2010-04-11 21:10:34 +02:00
Makefile.in Get rid of the OPTIMIZE_FOR_CPU variable 2010-04-11 21:10:35 +02:00
patch-kernel.sh toolchain/patch-kernel.sh: xtensa directory overlay support 2009-07-24 02:31:34 +02:00
wget-show-external-deps.sh buildroot: add external-deps target 2008-03-04 12:19:16 +00:00