toolchain: improving lib{32,64} symlinks
PATCH 1/1 toolchain: improving lib{32,64} symlinks
Usually 64-bit toolchains have a couple of lib64 directory containing all the 64-bit stuff.
Some of them provide 32-bit ABI, and may store this stuff in lib32 directory, this lib32 directory may be a mandatory at runtime for the libc interp (e.g. mips/n32-uClibc).
This patch ensures that:
- only things corresponding to the selected ABI is copied from the external toolchain into the Buildroot sysroot;
- the lib and lib64 (respectively lib32) directories point to the same location (in the sysroot and the target tree), so there is no confusion at buildtime for the compiler, and at runtime for the libc interp;
To achieve this, a new symbol - BR2_ARCH_64_NEEDS_LIB32 - has been introduce. It is only available for 64-bit toolchain and should be selected whenever the toolchain provides a 32-bit ABI and expect a lib32 directory exists (and this directory is a mandatory).
A couple of things have also been reworked:
- the symlinks lib -> lib64 and lib64 -> lib are now always created if BR2_ARCH_IS_64 and !BR2_ARCH_64_NEEDS_LIB32, respectively the symlinks lib -> lib32 and lib32 -> lib, if BR2_ARCH_IS_64 and BR2_ARCH_64_NEEDS_LIB32 (only available for the Buildroot and external toolchain backends);
- the libs directories (in the sysroot an the target tree) are no longer created by the dirs targets, but are deferred the toolchain backend which will populate them accordingly, and create the symlinks.
Before this patch:
<snip>
$ cd output-x86_64
$ ls -ld host/usr/x86_64-buildroot-linux-gnu/sysroot/{,usr/}lib* target/{usr/,}lib*
drwxr-xr-x 2 samuel users 4.0K Aug 12 22:26 host/usr/x86_64-buildroot-linux-gnu/sysroot/lib/
drwxr-xr-x 2 samuel users 4.0K Aug 12 22:27 host/usr/x86_64-buildroot-linux-gnu/sysroot/lib64/
drwxr-xr-x 5 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/
drwxr-xr-x 5 samuel users 4.0K Aug 12 22:27 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib64/
drwxr-xr-x 3 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/libexec/
drwxr-xr-x 2 samuel users 4.0K Aug 12 22:27 target/lib/
lrwxrwxrwx 1 samuel users 3 Aug 12 22:27 target/lib64 -> lib/
drwxr-xr-x 2 samuel users 4.0K Aug 12 22:27 target/usr/lib/
lrwxrwxrwx 1 samuel users 3 Aug 12 22:27 target/usr/lib64 -> lib/
$ find . -type l -xtype l # find broken symlinks
find: `./host/usr/x86_64-buildroot-linux-gnu/sysroot/lib64/lib': Too many levels of symbolic links
find: `./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib64/lib': Too many levels of symbolic links
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_files.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_nis.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_compat.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_nisplus.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libutil.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libthread_db.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libcidn.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libcrypt.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libm.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_hesiod.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnsl.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/librt.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_db.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libanl.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libBrokenLocale.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_dns.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libresolv.so
./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libdl.so
./target/etc/resolv.conf
./target/dev/log$ cd output-mips-n32
$ ls -ld host/usr/mips64el-buildroot-linux-uclibc/sysroot/{,usr/}lib* target/{usr/,}lib*
drwxr-xr-x 2 samuel users 4.0K Aug 13 17:27 host/usr/mips64el-buildroot-linux-uclibc/sysroot/lib/
drwxr-xr-x 2 samuel users 4.0K Aug 13 17:27 host/usr/mips64el-buildroot-linux-uclibc/sysroot/usr/lib/
drwxr-xr-x 2 samuel users 4.0K Aug 14 14:05 target/lib/
drwxr-xr-x 2 samuel users 4.0K Aug 14 14:05 target/usr/lib/
$ find . -type l -xtype l # find broken symlinks
./target/etc/resolv.conf
./target/dev/log
</snip>After this patch:
<snip>
$ cd output-x86_64
$ ls -ld host/usr/x86_64-buildroot-linux-gnu/sysroot/{,usr/}lib* target/{usr/,}lib*
lrwxrwxrwx 1 samuel users 5 Aug 12 22:36 host/usr/x86_64-buildroot-linux-gnu/sysroot/lib -> lib64/
drwxr-xr-x 2 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/lib64/
lrwxrwxrwx 1 samuel users 5 Aug 12 22:36 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib -> lib64/
drwxr-xr-x 5 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib64/
drwxr-xr-x 3 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/libexec/
drwxr-xr-x 2 samuel users 4.0K Aug 12 22:36 target/lib/
lrwxrwxrwx 1 samuel users 3 Aug 12 22:36 target/lib64 -> lib/
drwxr-xr-x 2 samuel users 4.0K Aug 12 22:36 target/usr/lib/
lrwxrwxrwx 1 samuel users 3 Aug 12 22:36 target/usr/lib64 -> lib/
$ find . -type l -xtype l # find broken symlinks
./target/etc/resolv.conf
./target/dev/log$ cd output-mips-n32
$ ls -ld host/usr/mips64el-buildroot-linux-uclibc/sysroot/{,usr/}lib* target/{usr/,}lib*
drwxr-xr-x 2 samuel users 4.0K Aug 13 17:27 host/usr/mips64el-buildroot-linux-uclibc/sysroot/lib/
lrwxrwxrwx 1 samuel users 3 Aug 14 13:55 host/usr/mips64el-buildroot-linux-uclibc/sysroot/lib32 -> lib/
drwxr-xr-x 2 samuel users 4.0K Aug 13 17:27 host/usr/mips64el-buildroot-linux-uclibc/sysroot/usr/lib/
lrwxrwxrwx 1 samuel users 3 Aug 14 13:55 host/usr/mips64el-buildroot-linux-uclibc/sysroot/usr/lib32 -> lib/
drwxr-xr-x 2 samuel users 4.0K Aug 14 13:55 target/lib/
lrwxrwxrwx 1 samuel users 3 Aug 14 13:55 target/lib32 -> lib/
drwxr-xr-x 2 samuel users 4.0K Aug 14 13:55 target/usr/lib/
lrwxrwxrwx 1 samuel users 3 Aug 14 13:55 target/usr/lib32 -> lib/
$ find . -type l -xtype l # find broken symlinks
./target/etc/resolv.conf
./target/dev/log
</snip>Fixes http://autobuild.buildroot.net/results/23fb6b1479d2b5906b72c9437b06ab4700ff246d
---
changes v1 -> v2
- add BR2_ARCH_64_NEEDS_LIB32 symbol (suggested by Thomas P. and Markos C.);
- add create_lib32_symlinks helper;
- more mkdir cleanup;
- mips/n32 toolchain now selects BR2_ARCH_64_NEEDS_LIB32;
* external toolchain backend:
- update the lib(32|64) symlink creation;
* buildroot toolchain backend:
-rework HOST_GCC_FINAL_HANDLE_LIB64 hook (suggested by Markos C.).
--- Makefile | 2 -- arch/Config.in | 4 +++ arch/Config.in.mips | 1 + package/gcc/gcc-final/gcc-final.mk | 12 +++----- toolchain/helpers.mk | 52 ++++++++++++++++++++++++++------ toolchain/toolchain-external/ext-tool.mk | 8 ++--- 6 files changed, 55 insertions(+), 24 deletions(-)
Makefile +0 -2
@@ -424,8 +424,6 @@ $(BUILD_DIR) $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR) $(LEGAL_INFO_DIR) $(REDIST $(STAGING_DIR): @mkdir -p $(STAGING_DIR)/bin - @mkdir -p $(STAGING_DIR)/lib - @mkdir -p $(STAGING_DIR)/usr/lib @mkdir -p $(STAGING_DIR)/usr/include @mkdir -p $(STAGING_DIR)/usr/bin @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
arch/Config.in +4 -0
@@ -1,6 +1,10 @@ config BR2_ARCH_IS_64 bool +config BR2_ARCH_64_NEEDS_LIB32 + bool + depends on BR2_ARCH_IS_64 + config BR2_SOFT_FLOAT bool
arch/Config.in.mips +1 -0
@@ -47,6 +47,7 @@ config BR2_MIPS_OABI32 config BR2_MIPS_NABI32 bool "n32" depends on BR2_ARCH_IS_64 + select BR2_ARCH_64_NEEDS_LIB32 config BR2_MIPS_NABI64 bool "n64" depends on BR2_ARCH_IS_64
package/gcc/gcc-final/gcc-final.mk +4 -8
@@ -57,14 +57,10 @@ HOST_GCC_FINAL_CONF_OPT += \ # Handle lib64 define HOST_GCC_FINAL_HANDLE_LIB64 - if [ -d "$(STAGING_DIR)/lib64" ]; then \ - if [ ! -e "$(STAGING_DIR)/lib" ]; then \ - mkdir -p "$(STAGING_DIR)/lib"; \ - fi; \ - mv "$(STAGING_DIR)/lib64/"* "$(STAGING_DIR)/lib/"; \ - rmdir "$(STAGING_DIR)/lib64"; \ - rm "$(STAGING_DIR)/usr/$(GNU_TARGET_NAME)/lib64";\ - fi + case "$(BR2_ARCH_IS_64)-$(BR2_ARCH_64_NEEDS_LIB32)" in \ + y-) $(call create_lib64_symlinks) ;; \ + y-y) $(call create_lib32_symlinks) ;; \ + esac ; endef HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_HANDLE_LIB64
toolchain/helpers.mk +42 -10
72 lines not on this page · raw message
toolchain/toolchain-external/ext-tool.mk +4 -4
@@ -449,7 +449,6 @@ $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked fi ; \ fi ; \ ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \ - mkdir -p $(TARGET_DIR)/lib ; \ if test -z "$(BR2_PREFER_STATIC_LIB)" ; then \ $(call MESSAGE,"Copying external toolchain libraries to target...") ; \ for libs in $(LIB_EXTERNAL_LIBS); do \
@@ -461,9 +460,10 @@ $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked fi ; \ $(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \ $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR}) ; \ - if [ -L $${ARCH_SYSROOT_DIR}/lib64 -o -d $${ARCH_SYSROOT_DIR}/lib64 ] ; then \ - $(call create_lib64_symlinks) ; \ - fi ; \ + case "$(BR2_ARCH_IS_64)-$(BR2_ARCH_64_NEEDS_LIB32)" in \ + y-) $(call create_lib64_symlinks) ;; \ + y-y) $(call create_lib32_symlinks) ;; \ + esac ; \ if test "$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY)" = "y"; then \ $(call MESSAGE,"Copying gdbserver") ; \ gdbserver_found=0 ; \
Signature · 1 line
1.8.3.4
PATCH 1/1 toolchain: improving lib{32,64} symlinks
Quoted 116 lines · Samuel Martin
Usually 64-bit toolchains have a couple of lib64 directory containing all the 64-bit stuff.
Some of them provide 32-bit ABI, and may store this stuff in lib32 directory, this lib32 directory may be a mandatory at runtime for the libc interp (e.g. mips/n32-uClibc).This patch ensures that:
- only things corresponding to the selected ABI is copied from the external toolchain into the Buildroot sysroot;
- the lib and lib64 (respectively lib32) directories point to the same location (in the sysroot and the target tree), so there is no confusion at buildtime for the compiler, and at runtime for the libc interp;To achieve this, a new symbol -
BR2_ARCH_64_NEEDS_LIB32- has been introduce. It is only available for 64-bit toolchain and should be selected whenever the toolchain provides a 32-bit ABI and expect a lib32 directory exists (and this directory is a mandatory).A couple of things have also been reworked:
- the symlinks lib -> lib64 and lib64 -> lib are now always created ifBR2_ARCH_IS_64and !BR2_ARCH_64_NEEDS_LIB32, respectively the symlinks lib -> lib32 and lib32 -> lib, ifBR2_ARCH_IS_64andBR2_ARCH_64_NEEDS_LIB32(only available for the Buildroot and external toolchain backends);
- the libs directories (in the sysroot an the target tree) are no longer created by the dirs targets, but are deferred the toolchain backend which will populate them accordingly, and create the symlinks.Before this patch:
<snip>$ cd output-x86_64 $ ls -ld host/usr/x86_64-buildroot-linux-gnu/sysroot/{,usr/}lib* target/{usr/,}lib* drwxr-xr-x 2 samuel users 4.0K Aug 12 22:26 host/usr/x86_64-buildroot-linux-gnu/sysroot/lib/ drwxr-xr-x 2 samuel users 4.0K Aug 12 22:27 host/usr/x86_64-buildroot-linux-gnu/sysroot/lib64/ drwxr-xr-x 5 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/ drwxr-xr-x 5 samuel users 4.0K Aug 12 22:27 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib64/ drwxr-xr-x 3 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/libexec/ drwxr-xr-x 2 samuel users 4.0K Aug 12 22:27 target/lib/ lrwxrwxrwx 1 samuel users 3 Aug 12 22:27 target/lib64 -> lib/ drwxr-xr-x 2 samuel users 4.0K Aug 12 22:27 target/usr/lib/ lrwxrwxrwx 1 samuel users 3 Aug 12 22:27 target/usr/lib64 -> lib/ $ find . -type l -xtype l # find broken symlinks find: `./host/usr/x86_64-buildroot-linux-gnu/sysroot/lib64/lib': Too many levels of symbolic links find: `./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib64/lib': Too many levels of symbolic links ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_files.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_nis.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_compat.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_nisplus.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libutil.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libthread_db.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libcidn.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libcrypt.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libm.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_hesiod.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnsl.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/librt.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_db.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libanl.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libBrokenLocale.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libnss_dns.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libresolv.so ./host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib/libdl.so ./target/etc/resolv.conf ./target/dev/log$ cd output-mips-n32 $ ls -ld host/usr/mips64el-buildroot-linux-uclibc/sysroot/{,usr/}lib* target/{usr/,}lib* drwxr-xr-x 2 samuel users 4.0K Aug 13 17:27 host/usr/mips64el-buildroot-linux-uclibc/sysroot/lib/ drwxr-xr-x 2 samuel users 4.0K Aug 13 17:27 host/usr/mips64el-buildroot-linux-uclibc/sysroot/usr/lib/ drwxr-xr-x 2 samuel users 4.0K Aug 14 14:05 target/lib/ drwxr-xr-x 2 samuel users 4.0K Aug 14 14:05 target/usr/lib/ $ find . -type l -xtype l # find broken symlinks ./target/etc/resolv.conf ./target/dev/log </snip>After this patch:
<snip>$ cd output-x86_64 $ ls -ld host/usr/x86_64-buildroot-linux-gnu/sysroot/{,usr/}lib* target/{usr/,}lib* lrwxrwxrwx 1 samuel users 5 Aug 12 22:36 host/usr/x86_64-buildroot-linux-gnu/sysroot/lib -> lib64/ drwxr-xr-x 2 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/lib64/ lrwxrwxrwx 1 samuel users 5 Aug 12 22:36 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib -> lib64/ drwxr-xr-x 5 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/lib64/ drwxr-xr-x 3 samuel users 4.0K Oct 30 2012 host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/libexec/ drwxr-xr-x 2 samuel users 4.0K Aug 12 22:36 target/lib/ lrwxrwxrwx 1 samuel users 3 Aug 12 22:36 target/lib64 -> lib/ drwxr-xr-x 2 samuel users 4.0K Aug 12 22:36 target/usr/lib/ lrwxrwxrwx 1 samuel users 3 Aug 12 22:36 target/usr/lib64 -> lib/ $ find . -type l -xtype l # find broken symlinks ./target/etc/resolv.conf ./target/dev/log$ cd output-mips-n32 $ ls -ld host/usr/mips64el-buildroot-linux-uclibc/sysroot/{,usr/}lib* target/{usr/,}lib* drwxr-xr-x 2 samuel users 4.0K Aug 13 17:27 host/usr/mips64el-buildroot-linux-uclibc/sysroot/lib/ lrwxrwxrwx 1 samuel users 3 Aug 14 13:55 host/usr/mips64el-buildroot-linux-uclibc/sysroot/lib32 -> lib/ drwxr-xr-x 2 samuel users 4.0K Aug 13 17:27 host/usr/mips64el-buildroot-linux-uclibc/sysroot/usr/lib/ lrwxrwxrwx 1 samuel users 3 Aug 14 13:55 host/usr/mips64el-buildroot-linux-uclibc/sysroot/usr/lib32 -> lib/ drwxr-xr-x 2 samuel users 4.0K Aug 14 13:55 target/lib/ lrwxrwxrwx 1 samuel users 3 Aug 14 13:55 target/lib32 -> lib/ drwxr-xr-x 2 samuel users 4.0K Aug 14 13:55 target/usr/lib/ lrwxrwxrwx 1 samuel users 3 Aug 14 13:55 target/usr/lib32 -> lib/ $ find . -type l -xtype l # find broken symlinks ./target/etc/resolv.conf ./target/dev/log </snip>Fixes http://autobuild.buildroot.net/results/23fb6b1479d2b5906b72c9437b06ab4700ff246d
Signed-off-by Samuel Martin <[email protected]>Cc Markos Chandras <[email protected]>---
changes v1 -> v2
Quoted 9 lines
- add
BR2_ARCH_64_NEEDS_LIB32symbol (suggested by Thomas P. and Markos C.);
- addcreate_lib32_symlinkshelper;
- more mkdir cleanup;
- mips/n32 toolchain now selectsBR2_ARCH_64_NEEDS_LIB32;
* external toolchain backend:
- update the lib(32|64) symlink creation;
* buildroot toolchain backend:
-reworkHOST_GCC_FINAL_HANDLE_LIB64hook (suggested by Markos C.).
---
Hi Samuel,
I've tested this patch for MIPS, MIPS64 o32 and n32 in both BR and Sourcery Codebench toolchains and it seems to work fine. It certainly fixes the n32 interp issue for MIPS. You have my
Tested-by/Reviewed-by: Markos Chandras <[email protected]>
Thank you!
ps: The http://autobuild.buildroot.net/results/23fb6b1479d2b5906b72c9437b06ab4700ff246d
returns 404 for me
Signature · 2 lines
Regards, Markos Chandras
PATCH 1/1 toolchain: improving lib{32,64} symlinks
2013/8/14 Markos Chandras <[email protected]>:
Quoted 8 lines
Hi Samuel,
I've tested this patch for MIPS, MIPS64 o32 and n32 in both BR and Sourcery Codebench toolchains and it seems to work fine. It certainly fixes the n32 interp issue for MIPS. You have my
Tested-by/Reviewed-by: Markos Chandras <[email protected]>
Great! Thanks.
Quoted 5 lines
Thank you!
ps: The http://autobuild.buildroot.net/results/23fb6b1479d2b5906b72c9437b06ab4700ff246d
returns 404 for me
arf... I forgot the trailing slash! The redirection does not work without :-( Anyway, the actual url is:
http://autobuild.buildroot.net/results/23f/23fb6b1479d2b5906b72c9437b06ab4700ff246d
Regards,
Signature · 1 line
Samuel