From 0729b544b3f943f238042d8169ccb8e2f6c88a95 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 31 Dec 2011 11:57:15 +0100 Subject: Improve external toolchain logic to support IA32 Sourcery CodeBench toolchain The IA32 Sourcery CodeBench toolchain has a relatively special structure, with the following multilib variants: * Intel Pentium 4, 32 bits, the multilib variant is in ./ relative to the main sysroot, with the libraries in the lib/ directory. * Intel Xeon Nocona, 64 bits, the multilib variant is in ./ relative to the main sysroot, with the libraries in the lib64/ directory. * Intel Atom 32 bits, the multilib variant is in atom/ relative to the main sysroot, with the libraries in the lib/ directory. * Intel Core 2 64 bits, the multilib variant is in core2/ relative to the main sysroot, with the libraries in lib64/ directory. So the first two variants are in the same sysroot, only the name of the directory for the libraries is different. Therefore, we introduce a new ARCH_LIB_DIR variable, which contains either 'lib' or 'lib64'. This variable is defined according to the location of the libc.a file for the selected multilib variant, and is then used when copying the libraries to the target and to the staging directory. In addition to this, we no longer use the -print-multi-directory to get the ARCH_SUBDIR, since in the case of the 64 bits variants of this toolchain, it returns just '64' and not a real path. Instead, we simply compute the difference between the arch-specific sysroot and the main sysroot. We also take that opportunity to expand the documentation on the meaning of the different variables. Signed-off-by: Thomas Petazzoni --- toolchain/helpers.mk | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'toolchain/helpers.mk') diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 65cc9982d..4c3f2406f 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -10,19 +10,22 @@ # 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//lib(64). +# /usr//lib(64). Thanks to ARCH_LIB_DIR we also take into +# account toolchains that have the libraries in lib64 and usr/lib64. # # $1: arch specific sysroot directory -# $2: library name -# $3: destination directory of the libary, relative to $(TARGET_DIR) +# $2: library directory ('lib' or 'lib64') from which libraries must be copied +# $3: library name +# $4: destination directory of the libary, relative to $(TARGET_DIR) # copy_toolchain_lib_root = \ ARCH_SYSROOT_DIR="$(strip $1)"; \ - LIB="$(strip $2)"; \ - DESTDIR="$(strip $3)" ; \ + ARCH_LIB_DIR="$(strip $2)" ; \ + LIB="$(strip $3)"; \ + DESTDIR="$(strip $4)" ; \ \ LIBS=`(cd $${ARCH_SYSROOT_DIR}; \ - find -L lib* usr/lib* usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/lib* \ + find -L $${ARCH_LIB_DIR} usr/$${ARCH_LIB_DIR} usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/$${ARCH_LIB_DIR} \ -maxdepth 1 -name "$${LIB}.*" 2>/dev/null \ )` ; \ for FILE in $${LIBS} ; do \ @@ -84,12 +87,14 @@ copy_toolchain_lib_root = \ # $1: main sysroot directory of the toolchain # $2: arch specific sysroot directory of the toolchain # $3: arch specific subdirectory in the sysroot +# $4: directory of libraries ('lib' or 'lib64') # copy_toolchain_sysroot = \ SYSROOT_DIR="$(strip $1)"; \ ARCH_SYSROOT_DIR="$(strip $2)"; \ ARCH_SUBDIR="$(strip $3)"; \ - for i in etc lib sbin usr ; do \ + ARCH_LIB_DIR="$(strip $4)" ; \ + for i in etc $${ARCH_LIB_DIR} sbin usr ; do \ if [ -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \ rsync -au --chmod=Du+w --exclude 'usr/lib/locale' $${ARCH_SYSROOT_DIR}/$$i $(STAGING_DIR)/ ; \ fi ; \ -- cgit v1.2.3 From 50ac5f9a573d3918cc5257a30a7c85db7841ac42 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 31 Dec 2011 12:02:52 +0100 Subject: Support multilib variants in sub-subdirectories When an external toolchain has multiple variants organized in sub-directories, Buildroot only copies the selected sysroot and not all sysroots. In order to make this work, Buildroot creates a symbolic link of the name of the original selected sysroot to the main sysroot to trick the compiler so that it finds its libraries at the expected location. I.e, if the toolchain as the following organization (example take on the ARM CodeSourcery toolchain) : . for ARMv5T armv4 for ARMv4T thumb2 for ARMv7-A/Thumb and ARMv4T is selected, then Buildroot will copy the contents of armv4t/ from the toolchain into its $(STAGING_DIR) and then create a $(STAGING_DIR)/armv4t symbolic link to $(STAGING_DIR). However, our logic to do so only works when there was one directory level for multilib sysroots. But in the MIPS CodeSourcery toolchain there are multiple levels. For example, the MIPS16 soft-float little-endian sysroot variant is in mips16/soft-float/el/ compared to the main sysroot. This patch improves our logic to support this case. The logic is a bit more complicated as we don't want to create a symbolic link to an absolute path, but a symbolic link to a relative path, because we want the host/ directory to be relocatable. Signed-off-by: Thomas Petazzoni --- toolchain/helpers.mk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'toolchain/helpers.mk') diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 4c3f2406f..3f4818f22 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -103,7 +103,14 @@ copy_toolchain_sysroot = \ if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \ cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \ fi ; \ - ln -s . $(STAGING_DIR)/$${ARCH_SUBDIR} ; \ + mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \ + relpath="./" ; \ + nbslashs=`echo -n $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \ + for slash in `seq 1 $${nbslashs}` ; do \ + relpath=$${relpath}"../" ; \ + done ; \ + ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \ + echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \ fi ; \ find $(STAGING_DIR) -type d | xargs chmod 755 -- cgit v1.2.3 From 090d486441e6ee1898a6a27f8827076464cf2110 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 31 Dec 2011 16:15:43 +0100 Subject: external-toolchain: adjust check for uClibc static toolchains The current check for uClibc toolchain was verifying that a ld-uClibc.so dynamic loader was present. However, with static-only uClibc toolchains, this does not work. Instead, we check for an uClibc-specific header file in the sysroot. Signed-off-by: Thomas Petazzoni --- toolchain/helpers.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolchain/helpers.mk') diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 3f4818f22..6e7f1f4c9 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -196,7 +196,7 @@ check_uclibc_feature = \ # check_uclibc = \ SYSROOT_DIR="$(strip $1)"; \ - if ! test -f $${SYSROOT_DIR}/lib/ld*-uClibc.so.* ; then \ + if ! test -f $${SYSROOT_DIR}/usr/include/bits/uClibc_config.h ; then \ echo "Incorrect selection of the C library"; \ exit -1; \ fi; \ -- cgit v1.2.3 From e6e60becb008dd389c51d2d75cbfd63551300dae Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 28 Jan 2012 17:12:02 +0100 Subject: external-toolchain: add support for Linaro 2012.01 Linaro has just released a new pre-built toolchain, available as a tarball, which is a pure toolchain (only the C library is included). This makes this new Linaro 2012.01 toolchain usable in Buildroot, so let's integrate the support for it. In addition to simply adding the new external toolchain at the usual locations, this patch allows need to adapt a few things to support Linaro toolchains. Most toolchains store their libraries in the "lib/" or "usr/lib" directories relative to the toolchain. Buildroot toolchains on the other hand, store the libraries in the "usr//lib" directory. And the Linaro toolchain has choosen to use the "lib/" directory. Therefore, this patch adjust: * The logic to search a particular library when that library needs to be copied to the target directory * The logic to deduce the sysroot directory from the libc.a file location in the toolchain: removing "(usr/?)lib(64?)" is no longer sufficient, we need to take into account the "lib//" case. Since the Linaro toolchain generates code for Cortex-A processors only, the selection of this toolchain is limited to Cortex-A8 and Cortex-A9. Signed-off-by: Thomas Petazzoni --- toolchain/helpers.mk | 31 +++++++++++++++++++++++++------ toolchain/toolchain-external/Config.in | 15 +++++++++++++++ toolchain/toolchain-external/ext-tool.mk | 11 +++++++---- 3 files changed, 47 insertions(+), 10 deletions(-) (limited to 'toolchain/helpers.mk') diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 6e7f1f4c9..bb1ea9040 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -7,11 +7,30 @@ # directory to the target directory. Also optionaly strips the # library. # -# 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//lib(64). Thanks to ARCH_LIB_DIR we also take into -# account toolchains that have the libraries in lib64 and usr/lib64. +# Most toolchains (CodeSourcery ones) have their libraries either in +# /lib or /usr/lib relative to their ARCH_SYSROOT_DIR, so we search +# libraries in: +# +# $${ARCH_LIB_DIR} +# usr/$${ARCH_LIB_DIR} +# +# Buildroot toolchains, however, have basic libraries in /lib, and +# libstdc++/libgcc_s in /usr//lib(64), so we also need to +# search libraries in: +# +# usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/$${ARCH_LIB_DIR} +# +# Finally, Linaro toolchains have the libraries in lib//, +# so we need to search libraries in: +# +# $${ARCH_LIB_DIR}/$(TOOLCHAIN_EXTERNAL_PREFIX) +# +# Thanks to ARCH_LIB_DIR we also take into account toolchains that +# have the libraries in lib64 and usr/lib64. +# +# Please be very careful to check the major toolchain sources: +# Buildroot, Crosstool-NG, CodeSourcery and Linaro before doing any +# modification on the below logic. # # $1: arch specific sysroot directory # $2: library directory ('lib' or 'lib64') from which libraries must be copied @@ -25,7 +44,7 @@ copy_toolchain_lib_root = \ DESTDIR="$(strip $4)" ; \ \ LIBS=`(cd $${ARCH_SYSROOT_DIR}; \ - find -L $${ARCH_LIB_DIR} usr/$${ARCH_LIB_DIR} usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/$${ARCH_LIB_DIR} \ + find -L $${ARCH_LIB_DIR} usr/$${ARCH_LIB_DIR} usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/$${ARCH_LIB_DIR} $${ARCH_LIB_DIR}/$(TOOLCHAIN_EXTERNAL_PREFIX) \ -maxdepth 1 -name "$${LIB}.*" 2>/dev/null \ )` ; \ for FILE in $${LIBS} ; do \ diff --git a/toolchain/toolchain-external/Config.in b/toolchain/toolchain-external/Config.in index f3f49e93a..9db5cb64e 100644 --- a/toolchain/toolchain-external/Config.in +++ b/toolchain/toolchain-external/Config.in @@ -3,6 +3,20 @@ if BR2_TOOLCHAIN_EXTERNAL choice prompt "Toolchain" +config BR2_TOOLCHAIN_EXTERNAL_LINARO_2012_01 + bool "Linaro 2012.01" + depends on BR2_arm + depends on BR2_cortex_a8 || BR2_cortex_a9 + select BR2_TOOLCHAIN_EXTERNAL_GLIBC + select BR2_INSTALL_LIBSTDCPP + help + Linaro toolchain for the ARM architecture. It uses Linaro + GCC 2012.01 (based on gcc 4.6), Linaro GDB 2011.12, eglibc + 2.13. It generates code that runs on all Cortex-A profile + devices, but tuned for the Cortex-A9. The code generated is + Thumb 2, with the softfp calling convention, and uses the + VFPv3-D16 FPU instructions. + config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201109 bool "Sourcery CodeBench ARM 2011.09" depends on BR2_arm @@ -433,6 +447,7 @@ config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX config BR2_TOOLCHAIN_EXTERNAL_PREFIX string + default "arm-linux-gnueabi" if BR2_TOOLCHAIN_EXTERNAL_LINARO_2012_01 default "arm-none-linux-gnueabi" if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM2009Q3 default "arm-none-linux-gnueabi" if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM2010Q1 default "arm-none-linux-gnueabi" if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201009 diff --git a/toolchain/toolchain-external/ext-tool.mk b/toolchain/toolchain-external/ext-tool.mk index 8132caa4f..a638381d1 100644 --- a/toolchain/toolchain-external/ext-tool.mk +++ b/toolchain/toolchain-external/ext-tool.mk @@ -187,6 +187,9 @@ TOOLCHAIN_EXTERNAL_SOURCE=arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gn else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201109),y) TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/ TOOLCHAIN_EXTERNAL_SOURCE=arm-2011.09-70-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 +else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_2012_01),y) +TOOLCHAIN_EXTERNAL_SITE=http://launchpad.net/linaro-toolchain-binaries/trunk/2012.01/+download/ +TOOLCHAIN_EXTERNAL_SOURCE=gcc-linaro-arm-linux-gnueabi-2012.01-20120125_linux.tar.bz2 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS44),y) TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/mips/portal/package7401/public/mips-linux-gnu/ TOOLCHAIN_EXTERNAL_SOURCE=mips-4.4-303-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2 @@ -286,7 +289,7 @@ $(STAMP_DIR)/ext-toolchain-checked: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES) @echo "Checking external toolchain settings" $(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC)) $(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \ - SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/libc\.a::'` ; \ + SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/(.*/)?libc\.a::'` ; \ if test -z "$${SYSROOT_DIR}" ; then \ @echo "External toolchain doesn't support --sysroot. Cannot use." ; \ exit 1 ; \ @@ -343,14 +346,14 @@ $(STAMP_DIR)/ext-toolchain-checked: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES) $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked $(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \ - SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/libc\.a::'` ; \ + SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/(.*/)?libc\.a::'` ; \ if test -z "$${SYSROOT_DIR}" ; then \ @echo "External toolchain doesn't support --sysroot. Cannot use." ; \ exit 1 ; \ fi ; \ ARCH_LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libc.a)` ; \ - ARCH_SYSROOT_DIR=`echo $${ARCH_LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/libc\.a::'` ; \ - ARCH_LIB_DIR=`echo $${ARCH_LIBC_A_LOCATION} | sed -r -e 's:.*/usr/(lib(64)?)/libc.a:\1:'` ; \ + ARCH_SYSROOT_DIR=`echo $${ARCH_LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/(.*/)?libc\.a::'` ; \ + ARCH_LIB_DIR=`echo $${ARCH_LIBC_A_LOCATION} | sed -r -e 's:.*/usr/(lib(64)?)/(.*/)?libc.a:\1:'` ; \ ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \ mkdir -p $(TARGET_DIR)/lib ; \ echo "Copy external toolchain libraries to target..." ; \ -- cgit v1.2.3