2010-02-09 21:34:49 +01:00
|
|
|
|
2009-07-17 00:20:33 +02:00
|
|
|
#
|
|
|
|
# This file implements the support for external toolchains, i.e
|
|
|
|
# toolchains that have not been produced by Buildroot itself and that
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
# are already available on the system on which Buildroot runs. So far,
|
|
|
|
# we have tested this with:
|
|
|
|
#
|
|
|
|
# * Toolchains generated by Crosstool-NG
|
|
|
|
# * Toolchains generated by Buildroot
|
2010-07-05 18:58:59 +02:00
|
|
|
# * ARM, MIPS and PowerPC toolchains made available by
|
|
|
|
# Codesourcery. For the MIPS toolchain, the -muclibc variant isn't
|
|
|
|
# supported yet, only the default glibc-based variant is.
|
2009-07-17 00:20:33 +02:00
|
|
|
#
|
|
|
|
# The basic principle is the following
|
|
|
|
#
|
|
|
|
# 1. Perform some checks on the conformity between the toolchain
|
|
|
|
# configuration described in the Buildroot menuconfig system, and the
|
|
|
|
# real configuration of the external toolchain. This is for example
|
|
|
|
# important to make sure that the Buildroot configuration system
|
|
|
|
# knows whether the toolchain supports RPC, IPv6, locales, large
|
|
|
|
# files, etc. Unfortunately, these things cannot be detected
|
|
|
|
# automatically, since the value of these options (such as
|
|
|
|
# BR2_INET_RPC) are needed at configuration time because these
|
|
|
|
# options are used as dependencies for other options. And at
|
|
|
|
# configuration time, we are not able to retrieve the external
|
|
|
|
# toolchain configuration.
|
|
|
|
#
|
|
|
|
# 2. Copy the libraries needed at runtime to the target directory,
|
|
|
|
# $(TARGET_DIR). Obviously, things such as the C library, the dynamic
|
|
|
|
# loader and a few other utility libraries are needed if dynamic
|
|
|
|
# applications are to be executed on the target system.
|
|
|
|
#
|
|
|
|
# 3. Copy the libraries and headers to the staging directory. This
|
|
|
|
# will allow all further calls to gcc to be made using --sysroot
|
|
|
|
# $(STAGING_DIR), which greatly simplifies the compilation of the
|
|
|
|
# packages when using external toolchains. So in the end, only the
|
|
|
|
# cross-compiler binaries remains external, all libraries and headers
|
|
|
|
# are imported into the Buildroot tree.
|
|
|
|
|
2007-02-06 19:19:38 +01:00
|
|
|
#
|
2009-07-16 23:56:10 +02:00
|
|
|
# Copy a toolchain library and its symbolic links from the sysroot
|
|
|
|
# directory to the target directory. Also optionaly strips the
|
|
|
|
# library.
|
2007-02-06 19:19:38 +01:00
|
|
|
#
|
2010-07-05 18:59:02 +02:00
|
|
|
# Most toolchains have their libraries either in /lib or /usr/lib
|
|
|
|
# relative to their ARCH_SYSROOT_DIR. Buildroot toolchains, however,
|
|
|
|
# have basic libraries in /lib, and libstdc++/libgcc_s in
|
|
|
|
# /usr/<target-name>/lib(64).
|
|
|
|
#
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
# $1: arch specific sysroot directory
|
2009-07-16 23:56:10 +02:00
|
|
|
# $2: library name
|
2010-07-05 18:59:03 +02:00
|
|
|
# $3: destination directory of the libary, relative to $(TARGET_DIR)
|
2009-07-16 23:56:10 +02:00
|
|
|
# $4: strip (y|n), default is to strip
|
2007-02-06 19:19:38 +01:00
|
|
|
#
|
2007-08-22 14:35:41 +02:00
|
|
|
copy_toolchain_lib_root = \
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
ARCH_SYSROOT_DIR="$(strip $1)"; \
|
2009-07-16 23:56:10 +02:00
|
|
|
LIB="$(strip $2)"; \
|
2010-07-05 18:59:03 +02:00
|
|
|
DESTDIR="$(strip $3)" ; \
|
2009-07-16 23:56:10 +02:00
|
|
|
STRIP="$(strip $4)"; \
|
2007-08-22 14:35:41 +02:00
|
|
|
\
|
2010-07-05 18:59:02 +02:00
|
|
|
LIBS=`(cd $${ARCH_SYSROOT_DIR}; \
|
|
|
|
find -L . -path "./lib/$${LIB}.*" -o \
|
|
|
|
-path "./usr/lib/$${LIB}.*" -o \
|
|
|
|
-path "./usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/lib*/$${LIB}.*" \
|
|
|
|
)` ; \
|
2010-02-09 21:34:49 +01:00
|
|
|
for FILE in $${LIBS} ; do \
|
2007-08-22 14:35:41 +02:00
|
|
|
LIB=`basename $${FILE}`; \
|
2010-02-09 21:34:49 +01:00
|
|
|
LIBDIR=`dirname $${FILE}` ; \
|
2007-08-22 14:35:41 +02:00
|
|
|
while test \! -z "$${LIB}"; do \
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
FULLPATH="$${ARCH_SYSROOT_DIR}/$${LIBDIR}/$${LIB}" ; \
|
2010-07-05 18:59:03 +02:00
|
|
|
rm -fr $(TARGET_DIR)/$${DESTDIR}/$${LIB}; \
|
|
|
|
mkdir -p $(TARGET_DIR)/$${DESTDIR}; \
|
2010-02-09 21:34:49 +01:00
|
|
|
if test -h $${FULLPATH} ; then \
|
2010-07-05 18:59:03 +02:00
|
|
|
cp -d $${FULLPATH} $(TARGET_DIR)/$${DESTDIR}/; \
|
2010-02-09 21:34:49 +01:00
|
|
|
elif test -f $${FULLPATH}; then \
|
2010-07-05 18:59:03 +02:00
|
|
|
$(INSTALL) -D -m0755 $${FULLPATH} $(TARGET_DIR)/$${DESTDIR}/$${LIB}; \
|
2007-08-22 14:35:41 +02:00
|
|
|
case "$${STRIP}" in \
|
|
|
|
(0 | n | no) \
|
|
|
|
;; \
|
|
|
|
(*) \
|
2010-07-05 18:59:03 +02:00
|
|
|
$(TARGET_CROSS)strip "$(TARGET_DIR)/$${DESTDIR}/$${LIB}"; \
|
2007-08-22 14:35:41 +02:00
|
|
|
;; \
|
|
|
|
esac; \
|
|
|
|
else \
|
|
|
|
exit -1; \
|
|
|
|
fi; \
|
2010-02-09 21:34:49 +01:00
|
|
|
LIB="`readlink $${FULLPATH}`"; \
|
2007-08-22 14:35:41 +02:00
|
|
|
done; \
|
|
|
|
done; \
|
|
|
|
\
|
2007-02-06 19:19:38 +01:00
|
|
|
echo -n
|
|
|
|
|
2009-07-16 23:56:10 +02:00
|
|
|
#
|
|
|
|
# Copy the full external toolchain sysroot directory to the staging
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
# dir. The operation of this function is rendered a little bit
|
|
|
|
# complicated by the support for multilib toolchains.
|
2009-07-16 23:56:10 +02:00
|
|
|
#
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
# We start by copying etc, lib, sbin and usr from the sysroot of the
|
|
|
|
# selected architecture variant (as pointed by ARCH_SYSROOT_DIR). This
|
|
|
|
# allows to import into the staging directory the C library and
|
|
|
|
# companion libraries for the correct architecture variant. We
|
|
|
|
# explictly only copy etc, lib, sbin and usr since other directories
|
|
|
|
# might exist for other architecture variants (on Codesourcery
|
|
|
|
# toolchain, the sysroot for the default architecture variant contains
|
|
|
|
# the armv4t and thumb2 subdirectories, which are the sysroot for the
|
|
|
|
# corresponding architecture variants), and we don't want to import
|
|
|
|
# them.
|
|
|
|
#
|
|
|
|
# Then, if the selected architecture variant is not the default one
|
|
|
|
# (i.e, if SYSROOT_DIR != ARCH_SYSROOT_DIR), then we :
|
|
|
|
#
|
|
|
|
# * Import the header files from the default architecture
|
|
|
|
# variant. Header files are typically shared between the sysroots
|
|
|
|
# for the different architecture variants. If we use the
|
|
|
|
# non-default one, header files were not copied by the previous
|
|
|
|
# step, so we copy them here from the sysroot of the default
|
|
|
|
# architecture variant.
|
|
|
|
#
|
|
|
|
# * Create a symbolic link that matches the name of the subdirectory
|
|
|
|
# for the architecture variant in the original sysroot. This is
|
|
|
|
# required as the compiler will by default look in
|
|
|
|
# sysroot_dir/arch_variant/ for libraries and headers, when the
|
|
|
|
# non-default architecture variant is used. Without this, the
|
|
|
|
# compiler fails to find libraries and headers.
|
|
|
|
#
|
|
|
|
# $1: main sysroot directory of the toolchain
|
|
|
|
# $2: arch specific sysroot directory of the toolchain
|
|
|
|
# $3: arch specific subdirectory in the sysroot
|
2009-07-16 23:56:10 +02:00
|
|
|
#
|
2008-12-13 17:15:50 +01:00
|
|
|
copy_toolchain_sysroot = \
|
2009-07-16 23:56:10 +02:00
|
|
|
SYSROOT_DIR="$(strip $1)"; \
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
ARCH_SYSROOT_DIR="$(strip $2)"; \
|
|
|
|
ARCH_SUBDIR="$(strip $3)"; \
|
|
|
|
for i in etc lib sbin usr ; do \
|
2010-07-05 18:58:56 +02:00
|
|
|
if [ -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
|
|
|
|
cp -a $${ARCH_SYSROOT_DIR}/$$i $(STAGING_DIR)/ ; \
|
|
|
|
fi ; \
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
done ; \
|
|
|
|
if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
|
|
|
|
if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
|
|
|
|
cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
|
|
|
|
fi ; \
|
|
|
|
ln -s . $(STAGING_DIR)/$(ARCH_SUBDIR) ; \
|
|
|
|
fi ; \
|
2009-07-16 23:56:10 +02:00
|
|
|
find $(STAGING_DIR) -type d | xargs chmod 755
|
2008-12-13 17:15:50 +01:00
|
|
|
|
2010-07-05 18:58:58 +02:00
|
|
|
#
|
|
|
|
# Create lib64 -> lib and usr/lib64 -> usr/lib symbolic links in the
|
|
|
|
# target and staging directories. This is needed for some 64 bits
|
|
|
|
# toolchains such as the Crosstool-NG toolchains, for which the path
|
|
|
|
# to the dynamic loader and other libraries is /lib64, but the
|
|
|
|
# libraries are stored in /lib.
|
|
|
|
#
|
|
|
|
create_lib64_symlinks = \
|
|
|
|
(cd $(TARGET_DIR) ; ln -s lib lib64) ; \
|
|
|
|
(cd $(TARGET_DIR)/usr ; ln -s lib lib64) ; \
|
|
|
|
(cd $(STAGING_DIR) ; ln -s lib lib64) ; \
|
|
|
|
(cd $(STAGING_DIR)/usr ; ln -s lib lib64)
|
|
|
|
|
2009-07-16 23:56:10 +02:00
|
|
|
#
|
|
|
|
# Check the availability of a particular glibc feature. We assume that
|
|
|
|
# all Buildroot toolchain options are supported by glibc, so we just
|
|
|
|
# check that they are enabled.
|
|
|
|
#
|
|
|
|
# $1: Buildroot option name
|
|
|
|
# $2: feature description
|
|
|
|
#
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
check_glibc_feature = \
|
|
|
|
if [ x$($(1)) != x"y" ] ; then \
|
|
|
|
echo "$(2) available in C library, please enable $(1)" ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi
|
|
|
|
|
2009-07-16 23:56:10 +02:00
|
|
|
#
|
|
|
|
# Check the correctness of a glibc external toolchain configuration.
|
|
|
|
# 1. Check that the C library selected in Buildroot matches the one
|
|
|
|
# of the external toolchain
|
|
|
|
# 2. Check that all the C library-related features are enabled in the
|
|
|
|
# config, since glibc always supports all of them
|
|
|
|
#
|
|
|
|
# $1: sysroot directory
|
|
|
|
#
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
check_glibc = \
|
2009-07-16 23:56:10 +02:00
|
|
|
SYSROOT_DIR="$(strip $1)"; \
|
2010-07-05 18:58:57 +02:00
|
|
|
if ! test -f $${SYSROOT_DIR}/lib/ld-linux*.so.* -o -f $${SYSROOT_DIR}/lib/ld.so.* ; then \
|
2009-07-16 19:37:47 +02:00
|
|
|
echo "Incorrect selection of the C library"; \
|
|
|
|
exit -1; \
|
|
|
|
fi; \
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
$(call check_glibc_feature,BR2_LARGEFILE,Large file support) ;\
|
|
|
|
$(call check_glibc_feature,BR2_INET_IPV6,IPv6 support) ;\
|
|
|
|
$(call check_glibc_feature,BR2_INET_RPC,RPC support) ;\
|
|
|
|
$(call check_glibc_feature,BR2_ENABLE_LOCALE,Locale support) ;\
|
2009-07-31 11:40:34 +02:00
|
|
|
$(call check_glibc_feature,BR2_USE_WCHAR,Wide char support) ;\
|
|
|
|
$(call check_glibc_feature,BR2_PROGRAM_INVOCATION,Program invocation support)
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
|
2009-07-16 23:56:10 +02:00
|
|
|
#
|
|
|
|
# Check the conformity of Buildroot configuration with regard to the
|
|
|
|
# uClibc configuration of the external toolchain, for a particular
|
|
|
|
# feature.
|
|
|
|
#
|
|
|
|
# $1: uClibc macro name
|
|
|
|
# $2: Buildroot option name
|
|
|
|
# $3: uClibc config file
|
|
|
|
# $4: feature description
|
|
|
|
#
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
check_uclibc_feature = \
|
|
|
|
IS_IN_LIBC=`grep -q "\#define $(1) 1" $(3) && echo y` ; \
|
|
|
|
if [ x$($(2)) != x"y" -a x$${IS_IN_LIBC} == x"y" ] ; then \
|
|
|
|
echo "$(4) available in C library, please enable $(2)" ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi ; \
|
|
|
|
if [ x$($(2)) == x"y" -a x$${IS_IN_LIBC} != x"y" ] ; then \
|
|
|
|
echo "$(4) not available in C library, please disable $(2)" ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi
|
|
|
|
|
2009-07-16 23:56:10 +02:00
|
|
|
#
|
|
|
|
# Check the correctness of a uclibc external toolchain configuration
|
|
|
|
# 1. Check that the C library selected in Buildroot matches the one
|
|
|
|
# of the external toolchain
|
|
|
|
# 2. Check that the features enabled in the Buildroot configuration
|
|
|
|
# match the features available in the uClibc of the external
|
|
|
|
# toolchain
|
|
|
|
#
|
|
|
|
# $1: sysroot directory
|
|
|
|
#
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
check_uclibc = \
|
2009-07-16 23:56:10 +02:00
|
|
|
SYSROOT_DIR="$(strip $1)"; \
|
2010-07-05 18:59:00 +02:00
|
|
|
if ! test -f $${SYSROOT_DIR}/lib/ld*-uClibc.so.* ; then \
|
2009-07-16 19:37:47 +02:00
|
|
|
echo "Incorrect selection of the C library"; \
|
|
|
|
exit -1; \
|
|
|
|
fi; \
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
UCLIBC_CONFIG_FILE=$${SYSROOT_DIR}/usr/include/bits/uClibc_config.h ; \
|
|
|
|
$(call check_uclibc_feature,__UCLIBC_HAS_LFS__,BR2_LARGEFILE,$${UCLIBC_CONFIG_FILE},Large file support) ;\
|
|
|
|
$(call check_uclibc_feature,__UCLIBC_HAS_IPV6__,BR2_INET_IPV6,$${UCLIBC_CONFIG_FILE},IPv6 support) ;\
|
|
|
|
$(call check_uclibc_feature,__UCLIBC_HAS_RPC__,BR2_INET_RPC,$${UCLIBC_CONFIG_FILE},RPC support) ;\
|
|
|
|
$(call check_uclibc_feature,__UCLIBC_HAS_LOCALE__,BR2_ENABLE_LOCALE,$${UCLIBC_CONFIG_FILE},Locale support) ;\
|
|
|
|
$(call check_uclibc_feature,__UCLIBC_HAS_WCHAR__,BR2_USE_WCHAR,$${UCLIBC_CONFIG_FILE},Wide char support) ;\
|
2009-07-31 11:40:34 +02:00
|
|
|
$(call check_uclibc_feature,__UCLIBC_HAS_PROGRAM_INVOCATION_NAME__,BR2_PROGRAM_INVOCATION,$${UCLIBC_CONFIG_FILE},Program invocation support) ;\
|
2009-05-29 18:37:41 +02:00
|
|
|
|
2009-07-16 23:56:10 +02:00
|
|
|
#
|
|
|
|
# Check that the Buildroot configuration of the ABI matches the
|
|
|
|
# configuration of the external toolchain.
|
|
|
|
#
|
2009-07-16 19:37:47 +02:00
|
|
|
check_arm_abi = \
|
2009-07-17 00:07:08 +02:00
|
|
|
EXT_TOOLCHAIN_TARGET=$(shell LANG=C $(TARGET_CC) -v 2>&1 | grep ^Target | cut -f2 -d ' ') ; \
|
2009-07-16 19:37:47 +02:00
|
|
|
if echo $${EXT_TOOLCHAIN_TARGET} | grep -q 'eabi$$' ; then \
|
|
|
|
EXT_TOOLCHAIN_ABI="eabi" ; \
|
|
|
|
else \
|
|
|
|
EXT_TOOLCHAIN_ABI="oabi" ; \
|
|
|
|
fi ; \
|
|
|
|
if [ x$(BR2_ARM_OABI) == x"y" -a $${EXT_TOOLCHAIN_ABI} == "eabi" ] ; then \
|
|
|
|
echo "Incorrect ABI setting" ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi ; \
|
|
|
|
if [ x$(BR2_ARM_EABI) == x"y" -a $${EXT_TOOLCHAIN_ABI} == "oabi" ] ; then \
|
|
|
|
echo "Incorrect ABI setting" ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi ; \
|
2009-05-29 18:37:41 +02:00
|
|
|
|
2010-05-14 13:24:43 +02:00
|
|
|
#
|
|
|
|
# Check that the external toolchain supports C++
|
|
|
|
#
|
|
|
|
check_cplusplus = \
|
2010-07-06 00:03:35 +02:00
|
|
|
$(TARGET_CXX) -v > /dev/null 2>&1 ; \
|
|
|
|
if test $$? -ne 0 ; then \
|
2010-05-14 13:24:43 +02:00
|
|
|
echo "BR2_INSTALL_LIBSTDCPP is selected but C++ support not available in external toolchain" ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi ; \
|
|
|
|
|
2009-07-17 08:53:55 +02:00
|
|
|
#
|
|
|
|
# Check that the cross-compiler given in the configuration exists
|
|
|
|
#
|
|
|
|
check_cross_compiler_exists = \
|
2010-07-06 00:03:35 +02:00
|
|
|
$(TARGET_CC) -v > /dev/null 2>&1 ; \
|
|
|
|
if test $$? -ne 0 ; then \
|
|
|
|
echo "Cannot execute cross-compiler '$(TARGET_CC)'" ; \
|
2009-07-17 08:53:55 +02:00
|
|
|
exit 1 ; \
|
|
|
|
fi ; \
|
|
|
|
|
2009-07-16 19:37:47 +02:00
|
|
|
uclibc: dependencies $(STAMP_DIR)/ext-toolchain-installed
|
|
|
|
|
2010-07-05 18:59:03 +02:00
|
|
|
LIB_EXTERNAL_LIBS=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
|
2010-07-08 22:08:46 +02:00
|
|
|
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
|
2010-07-05 18:59:03 +02:00
|
|
|
LIB_EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
|
2009-07-16 23:56:10 +02:00
|
|
|
endif
|
|
|
|
|
2009-07-17 00:26:23 +02:00
|
|
|
ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
|
2010-07-05 18:59:03 +02:00
|
|
|
USR_LIB_EXTERNAL_LIBS+=libstdc++.so
|
2009-07-17 00:26:23 +02:00
|
|
|
endif
|
|
|
|
|
2010-05-28 23:23:14 +02:00
|
|
|
ifneq ($(BR2_PTHREADS_NONE),y)
|
2010-07-05 18:59:03 +02:00
|
|
|
LIB_EXTERNAL_LIBS+=libpthread.so
|
2010-05-28 23:23:20 +02:00
|
|
|
ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
|
2010-07-05 18:59:03 +02:00
|
|
|
LIB_EXTERNAL_LIBS+=libthread_db.so
|
2010-05-28 23:23:20 +02:00
|
|
|
endif # gdbserver
|
2010-05-28 23:23:14 +02:00
|
|
|
endif # ! no threads
|
|
|
|
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
# SYSROOT_DIR selection. We first try the -print-sysroot option,
|
|
|
|
# available in gcc 4.4.x and in some Codesourcery toolchains. If this
|
|
|
|
# option is not available, we fallback to the value of --with-sysroot
|
ext-toolchain: Fix ARCH_SYSROOT detection
For the detection of the ARCH_SYSROOT_DIR (which contains the C
library variant specific to the compiler flags), we used to pass only
the -march argument instead of the full TARGET_CFLAGS. This was done
because TARGET_CFLAGS contains --sysroot, and we don't want to tell
here the compiler which sysroot to use, because we're specifically
asking the compiler where the *normal* arch sysroot directory is.
Unfortunately, there are some multilib variants that aren't decided
only based on -march, but also on -msoft-float or other compiler
flags. Therefore, we take the opposite approach: pass the full
TARGET_CFLAGS, from which we have stripped the --sysroot option.
For example, this allows a PowerPC CodeSourcery toolchain, on which
we're using the soft-float multilib variant, to work properly as an
external toolchain.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2010-07-05 18:58:55 +02:00
|
|
|
# as visible in CROSS-gcc -v. We don't pass any option to gcc that
|
|
|
|
# could select a multilib variant as we want the "main" sysroot, which
|
|
|
|
# contains all variants of the C library in the case of multilib
|
|
|
|
# toolchains.
|
2010-07-06 00:03:35 +02:00
|
|
|
TARGET_CC_NO_SYSROOT=$(filter-out --sysroot=%,$(TARGET_CC))
|
|
|
|
SYSROOT_DIR=$(shell $(TARGET_CC_NO_SYSROOT) -print-sysroot 2>/dev/null)
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
ifeq ($(SYSROOT_DIR),)
|
2010-07-06 00:03:35 +02:00
|
|
|
SYSROOT_DIR=$(shell readlink -f $$(LANG=C $(TARGET_CC_NO_SYSROOT) -print-file-name=libc.a |sed -r -e 's:usr/lib/libc\.a::;'))
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Now, find if the toolchain specifies a sub-directory for the
|
|
|
|
# specific architecture variant we're interested in. This is the case
|
|
|
|
# with multilib toolchain, when the selected architecture variant is
|
ext-toolchain: Fix ARCH_SYSROOT detection
For the detection of the ARCH_SYSROOT_DIR (which contains the C
library variant specific to the compiler flags), we used to pass only
the -march argument instead of the full TARGET_CFLAGS. This was done
because TARGET_CFLAGS contains --sysroot, and we don't want to tell
here the compiler which sysroot to use, because we're specifically
asking the compiler where the *normal* arch sysroot directory is.
Unfortunately, there are some multilib variants that aren't decided
only based on -march, but also on -msoft-float or other compiler
flags. Therefore, we take the opposite approach: pass the full
TARGET_CFLAGS, from which we have stripped the --sysroot option.
For example, this allows a PowerPC CodeSourcery toolchain, on which
we're using the soft-float multilib variant, to work properly as an
external toolchain.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2010-07-05 18:58:55 +02:00
|
|
|
# not the default one. To do so, we ask the compiler by passing all
|
|
|
|
# flags, except the --sysroot flag since we want to the compiler to
|
|
|
|
# tell us where its original sysroot is. ARCH_SUBDIR will contain the
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
# subdirectory, in the main SYSROOT_DIR, that corresponds to the
|
|
|
|
# selected architecture variant. ARCH_SYSROOT_DIR will contain the
|
|
|
|
# full path to this location.
|
2010-07-06 00:03:35 +02:00
|
|
|
ARCH_SUBDIR=$(shell $(TARGET_CC_NO_SYSROOT) $(TARGET_CFLAGS) -print-multi-directory)
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
ARCH_SYSROOT_DIR=$(SYSROOT_DIR)/$(ARCH_SUBDIR)
|
2009-07-16 23:56:10 +02:00
|
|
|
|
2009-07-16 19:37:47 +02:00
|
|
|
$(STAMP_DIR)/ext-toolchain-installed:
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
@echo "Checking external toolchain settings"
|
2009-07-17 08:53:55 +02:00
|
|
|
$(Q)$(call check_cross_compiler_exists)
|
2009-07-16 23:56:10 +02:00
|
|
|
ifeq ($(strip $(SYSROOT_DIR)),)
|
|
|
|
@echo "External toolchain doesn't support --sysroot. Cannot use."
|
|
|
|
exit 1
|
|
|
|
endif
|
2009-07-16 19:37:47 +02:00
|
|
|
ifeq ($(BR2_arm),y)
|
2009-07-17 08:48:35 +02:00
|
|
|
$(Q)$(call check_arm_abi)
|
2009-07-16 19:37:47 +02:00
|
|
|
endif
|
2010-05-14 13:24:43 +02:00
|
|
|
ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
|
|
|
|
$(Q)$(call check_cplusplus)
|
|
|
|
endif
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_UCLIBC),y)
|
2009-07-17 08:48:35 +02:00
|
|
|
$(Q)$(call check_uclibc,$(SYSROOT_DIR))
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
else
|
2009-07-17 08:48:35 +02:00
|
|
|
$(Q)$(call check_glibc,$(SYSROOT_DIR))
|
Improve external toolchain checks
This patch adds some checks on the external toolchains.
First, it checks that the C library selection is correct, by looking
if gcc is able to find the main C library file through the
-print-file-name option.
Then, it attempts to check if the Buildroot toolchain options match
the configuration of the toolchain :
* for glibc, it checks that IPv6, RPC, locales, wide-char, large file
support Buildroot options are enabled, since with glibc all these
features are always available (at least this is the assumption we
make) ;
* for uClibc, it checks the Buildroot options with the uClibc
configuration file in $SYSROOT_DIR/usr/include/bits/uClibc_config.h
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2009-05-29 18:38:03 +02:00
|
|
|
endif
|
2007-02-06 19:19:38 +01:00
|
|
|
mkdir -p $(TARGET_DIR)/lib
|
2009-05-29 18:37:41 +02:00
|
|
|
@echo "Copy external toolchain libraries to target..."
|
2010-07-05 18:59:03 +02:00
|
|
|
$(Q)for libs in $(LIB_EXTERNAL_LIBS); do \
|
|
|
|
$(call copy_toolchain_lib_root,$(ARCH_SYSROOT_DIR),$$libs,/lib,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
|
|
|
|
done
|
|
|
|
$(Q)for libs in $(USR_LIB_EXTERNAL_LIBS); do \
|
|
|
|
$(call copy_toolchain_lib_root,$(ARCH_SYSROOT_DIR),$$libs,/usr/lib,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
|
2007-02-06 19:19:38 +01:00
|
|
|
done
|
2009-05-29 18:37:41 +02:00
|
|
|
@echo "Copy external toolchain sysroot to staging..."
|
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>
2009-08-22 01:13:22 +02:00
|
|
|
$(Q)$(call copy_toolchain_sysroot,$(SYSROOT_DIR),$(ARCH_SYSROOT_DIR),$(ARCH_SUBDIR))
|
2010-07-05 18:58:58 +02:00
|
|
|
# Create lib64 symbolic links if needed
|
|
|
|
$(Q)if [ -L $(ARCH_SYSROOT_DIR)/lib64 ] ; then \
|
|
|
|
$(call create_lib64_symlinks) ; \
|
|
|
|
fi
|
2009-07-16 19:37:47 +02:00
|
|
|
@touch $@
|