toolchain/helper: check for symlink from lib to lib64
RFC PATCH v2 1/2 toolchain/helper: check for symlink from lib to lib64
Buildroot picks up libc/lib64 and all its contents, but does not pickup libc/lib to populate the staging and target directories.
With the CodeSourcery AArch64 2014.05 toolchain the extracted sources contains a single symlink in the aarch64-linux-gnu/libc/lib directory which is lost during Buildroot staging import.
aarch64-linux-gnu/libc/lib/ld-linux-aarch64.so.1 -> ../lib64/ld-2.18.so
So, if we use a 64 bits toolchain we also look at "lib" directory to see if there are some symlink to libraries belonging to "lib64". If yes, we create the corresponding symlink in STAGING_DIR in copy_toolchain_sysroot()
The same kind of change should be done in copy_toolchain_lib_root() to copy the dynamic loader.
In the common case, we expect that it match this pattern: ld*.so.* But it's not the case here because the symlink to the dynamic loader is in another directory (lib) and we are looking for it in (lib64). So the LIB_EXTERNAL_LIBS += ld*.so.* doesn't match any library during the copy to TARGET_DIR.
That's why the system doesn't boot at runtime.
If the path to the dynamic loader is found in lib directory, it's appended to LIBSPATH.
--- toolchain/helpers.mk | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
toolchain/helpers.mk +23 -0
@@ -61,6 +61,17 @@ copy_toolchain_lib_root = \ fi \ done ; \ mkdir -p $(TARGET_DIR)/$${DESTDIR}; \ + if [ $${ARCH_LIB_DIR} = "lib64" ] ; then \ + if [ -d $${ARCH_SYSROOT_DIR}/lib ] ; then \ + SYMLINKS=`find $${ARCH_SYSROOT_DIR}/lib -maxdepth 1 -type l 2>/dev/null` ; \ + for i in $${SYMLINKS} ; do \ + relpath=`readlink -f $${i}` ; \ + if [ "`dirname $${relpath}`" = "$${ARCH_SYSROOT_DIR}lib64" ] ; then \ + LIBSPATH="$${LIBSPATH} $${i}" ; \ + fi ; \ + done ; \ + fi ; \ + fi ; \ for LIBPATH in $${LIBSPATH} ; do \ while true ; do \ LIBNAME=`basename $${LIBPATH}`; \
@@ -142,6 +153,18 @@ copy_toolchain_sysroot = \ $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \ fi ; \ done ; \ + if [ $${ARCH_LIB_DIR} = "lib64" ] ; then \ + if [ -d $${ARCH_SYSROOT_DIR}/lib ] ; then \ + mkdir -p `dirname $(STAGING_DIR)/lib` ; \ + SYMLINKS=`find $${ARCH_SYSROOT_DIR}/lib -maxdepth 1 -type l 2>/dev/null` ; \ + for i in $${SYMLINKS} ; do \ + relpath=`readlink -f $${i}` ; \ + if [ "`dirname $${relpath}`" = "$${ARCH_SYSROOT_DIR}lib64" ] ; then \ + ln -sf `basename $${relpath}` $(STAGING_DIR)/lib/`basename $${i}` ; \ + fi ; \ + done ; \ + fi ; \ + fi ; \ 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 ; \
Signature · 1 line
2.4.3
RFC PATCH v2 2/2 toolchain-external: bump CodeSourcery aarch64 to 2014.11
Like for 2014.05, this toolchain need a small fixup to import correcly the dynamic loader.
Runtime tested using qemu_aarch64_virt_defconfig.
---
v2: fix typo s/2015.11/2014.11/ (Vicente)
remove the custom fixup now that the specific handling is in the toolchain helpers. (ThomasP)
--- toolchain/toolchain-external/Config.in | 13 +++++++------ toolchain/toolchain-external/toolchain-external.hash | 2 +- toolchain/toolchain-external/toolchain-external.mk | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-)
toolchain/toolchain-external/Config.in +7 -6
@@ -429,7 +429,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64 http://www.linaro.org/engineering/armv8/ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64 - bool "CodeSourcery AArch64 2014.05" + bool "CodeSourcery AArch64 2014.11" depends on BR2_aarch64 depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86" depends on !BR2_STATIC_LIBS
@@ -437,12 +437,13 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64 select BR2_INSTALL_LIBSTDCPP select BR2_HOSTARCH_NEEDS_IA32_LIBS select BR2_TOOLCHAIN_HAS_NATIVE_RPC - select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_13 - select BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 + select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_16 + select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 help Sourcery CodeBench toolchain for the AArch64 architecture, - from Mentor Graphics. It uses gcc 4.8.3, binutils 2.24, - glibc 2.18, gdb 7.7.50 and kernel headers 3.13. + from Mentor Graphics. It uses gcc 4.9.1, binutils + 2.24.51.20140217, glibc 2.20, gdb 7.7.50 and kernel headers + 3.16.2. config BR2_TOOLCHAIN_EXTERNAL_MUSL_CROSS bool "Musl 1.1.6 toolchain (experimental)"
@@ -549,7 +550,7 @@ config BR2_TOOLCHAIN_EXTERNAL_PREFIX default "arm-arago-linux-gnueabi" if BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV7A default "arm-arago-linux-gnueabi" if BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV5TE default "aarch64-linux-gnu" if BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64 - default "aarch64-linux-gnu" if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64 + default "aarch64-amd-linux-gnu" if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64 default "mips-linux-gnu" if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS default "nios2-linux-gnu" if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII default "powerpc-mentor-linux-gnu" if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC
toolchain/toolchain-external/toolchain-external.hash +1 -1
@@ -23,7 +23,7 @@ sha256 ea804cf02014369da52abc4f64e91e96bde2dd2230aca96109459013d4545458 ia32-20 # AMD64 sha256 cb4d071db8aefb8005fe72824b96568d93a50f5acd85bacf505a34fe2f265f70 amd-2015.11-36-x86_64-amd-linux-gnu-i686-pc-linux-gnu.tar.bz2 # Aarch64 -sha256 8ea78c5988b2bb507534f1ad46aa46659f66b39d55f2fc40e163a90b4195e70f aarch64-2014.05-30-aarch64-linux-gnu-i686-pc-linux-gnu.tar.bz2 +sha256 405aada821146755c5f2df566375c2a682456d6b8451ee47b88cf1a52b093676 aarch64-amd-2014.11-95-aarch64-amd-linux-gnu-i686-pc-linux-gnu.tar.bz2 # ARM toolchains from Texas Instrument's Arago project sha256 f2febf3b3c565536461ad4405f1bcb835d75a6afb2a8bec958a1248cb4b81fc7 arago-2011.09-armv7a-linux-gnueabi-sdk.tar.bz2
toolchain/toolchain-external/toolchain-external.mk +2 -2
@@ -345,8 +345,8 @@ TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.1-2015.08-x86_64_aarch64-linux-gnu.tar. endif TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64),y) -TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/aarch64-linux-gnu -TOOLCHAIN_EXTERNAL_SOURCE = aarch64-2014.05-30-aarch64-linux-gnu-i686-pc-linux-gnu.tar.bz2 +TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/aarch64-amd-linux-gnu +TOOLCHAIN_EXTERNAL_SOURCE = aarch64-amd-2014.11-95-aarch64-amd-linux-gnu-i686-pc-linux-gnu.tar.bz2 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL_CROSS),y) TOOLCHAIN_EXTERNAL_VERSION = 1.1.6 TOOLCHAIN_EXTERNAL_SITE = https://googledrive.com/host/0BwnS5DMB0YQ6bDhPZkpOYVFhbk0/musl-$(TOOLCHAIN_EXTERNAL_VERSION)
Signature · 1 line
2.4.3
Thomas Petazzoni
AppliedRFC PATCH v2 2/2 toolchain-external: bump CodeSourcery aarch64 to 2014.11
Hello,
Quoted 12 lines · Romain Naour
Like for 2014.05, this toolchain need a small fixup to import correcly the dynamic loader.
Runtime tested using
qemu_aarch64_virt_defconfig.Signed-off-by Romain Naour <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Vicente Olivert Riera <[email protected]>---
v2: fix typo s/2015.11/2014.11/ (Vicente)
remove the custom fixup now that the specific handling is in the toolchain helpers. (ThomasP)
Quoted 5 lines
--- toolchain/toolchain-external/Config.in | 13 +++++++------ toolchain/toolchain-external/toolchain-external.hash | 2 +- toolchain/toolchain-external/toolchain-external.mk | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-)
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
RFC PATCH v2 1/2 toolchain/helper: check for symlink from lib to lib64
In reply to Romain NaourHello,
Quoted 23 lines · Romain Naour
Buildroot picks up libc/lib64 and all its contents, but does not pickup libc/lib to populate the staging and target directories.
With the CodeSourcery AArch64 2014.05 toolchain the extracted sources contains a single symlink in the aarch64-linux-gnu/libc/lib directory which is lost during Buildroot staging import.
aarch64-linux-gnu/libc/lib/ld-linux-aarch64.so.1 -> ../lib64/ld-2.18.so
So, if we use a 64 bits toolchain we also look at "lib" directory to see if there are some symlink to libraries belonging to "lib64". If yes, we create the corresponding symlink in
STAGING_DIRincopy_toolchain_sysroot()The same kind of change should be done in
copy_toolchain_lib_root()to copy the dynamic loader.
In the common case, we expect that it match this pattern: ld*.so.* But it's not the case here because the symlink to the dynamic loader is in another directory (lib) and we are looking for it in (lib64). So theLIB_EXTERNAL_LIBS+= ld*.so.* doesn't match any library during the copy toTARGET_DIR.
That's why the system doesn't boot at runtime.
Quoted 4 lines
If the path to the dynamic loader is found in lib directory, it's appended to LIBSPATH.
Signed-off-by Romain Naour <[email protected]>
In the end, I found this solution to be really complicated, just to solve the use case of one specific toolchain. So instead, I've applied your original fix which is just a one line tweak only for the CodeSourcery AArch64 toolchain. If we see more toolchains with the same issue, we will revisit this.
See:
https://git.busybox.net/buildroot/commit/?id=4d39ca1c2ab19766abf0430abe9b65ba0e16602b
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com