summaryrefslogtreecommitdiffstats
path: root/toolchain/toolchain-external
diff options
context:
space:
mode:
authorThomas De Schampheleire <thomas.de.schampheleire@gmail.com>2016-02-12 20:20:25 +0100
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2016-04-25 22:46:28 +0200
commit2a87b64f8e8a832a351f8552eb032e4b18431949 (patch)
tree9083da562a131dee495ce4f6a50c99dc2f04ac69 /toolchain/toolchain-external
parent10e905f83dd4aebdea4c51ccbe4260f5adc6748c (diff)
downloadbuildroot-2a87b64f8e8a832a351f8552eb032e4b18431949.tar.gz
buildroot-2a87b64f8e8a832a351f8552eb032e4b18431949.zip
toolchain-external: align library locations in target and staging dir
The toolchain-external logic is roughly: - populate the staging dir by rsyncing the entire ${ARCH_LIB_DIR} and usr/${ARCH_LIB_DIR} from sysroot. - populate the target dir by explictly copying some libraries from sysroot into target/lib and some other libraries in target/usr/lib, the split being hardcoded into buildroot regardless of the location in the sysroot. This means that a library libfoo could be located in: staging/lib/libfoo.so target/usr/lib/libfoo.so When debugging an application that links against this library, gdb will fruitlessly search for 'usr/lib/libfoo.so' in staging, and then suggest to use 'set solib-search-path' which is a hack, really. To solve the problem, we need to make sure that libraries from the toolchain are installed in the same relative location in staging and target. Achieve this by: - replacing the convoluted search for libraries using for+find in sysroot with a simple find in staging. - determining DESTDIR for each library individually based on the location in staging. - treating LIB_EXTERNAL_LIBS and USR_LIB_EXTERNAL_LIBS equivalently These changes also allow for the removal of most arguments to copy_toolchain_lib_root in the method itself and their callers. Test procedure: - set configuration for a given toolchain - make clean toolchain - find output/target | sort > /tmp/out-before - apply patch - make clean toolchain - find output/target | sort > /tmp/out-after - diff -u /tmp/out-before /tmp/out-after The only changes should be some libraries moving from lib to usr/lib or vice versa. Notable examples being libstdc++ and libatomic. Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> Reviewed-by: Romain Naour <romain.naour@gmail.com> Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> [Thomas: - use -L instead of -follow in the find invocation, as suggested by Arnout. - move the BR2_STATIC_LIBS condition as a make condition rather than a shell condition, as suggested by Arnout.] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'toolchain/toolchain-external')
-rw-r--r--toolchain/toolchain-external/toolchain-external.mk45
1 files changed, 12 insertions, 33 deletions
diff --git a/toolchain/toolchain-external/toolchain-external.mk b/toolchain/toolchain-external/toolchain-external.mk
index d989e5e9c5..906001ad7e 100644
--- a/toolchain/toolchain-external/toolchain-external.mk
+++ b/toolchain/toolchain-external/toolchain-external.mk
@@ -615,27 +615,19 @@ endef
# our sysroot, and the directory will also be
# considered when searching libraries for copy
# to the target filesystem.
+#
+# Please be very careful to check the major toolchain sources:
+# Buildroot, Crosstool-NG, CodeSourcery and Linaro
+# before doing any modification on the below logic.
+ifeq ($(BR2_STATIC_LIBS),)
define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS
- $(Q)ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
- ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
- SUPPORT_LIB_DIR="" ; \
- if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
- LIBSTDCPP_A_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
- if [ -e "$${LIBSTDCPP_A_LOCATION}" ]; then \
- SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
- fi ; \
- fi ; \
- if test -z "$(BR2_STATIC_LIBS)" ; then \
- $(call MESSAGE,"Copying external toolchain libraries to target...") ; \
- for libs in $(LIB_EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/lib); \
- done ; \
- for libs in $(USR_LIB_EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
- done ; \
- fi
+ $(Q)$(call MESSAGE,"Copying external toolchain libraries to target...") ; \
+ for libs in $(LIB_EXTERNAL_LIBS) $(USR_LIB_EXTERNAL_LIBS); do \
+ $(call copy_toolchain_lib_root,$$libs); \
+ done
endef
+endif
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),y)
define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER
@@ -701,21 +693,8 @@ define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS_BFIN_FDPIC
endef
define TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC
$(Q)$(call MESSAGE,"Install external toolchain FDPIC libraries to target...") ; \
- FDPIC_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))/../../bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc ; \
- FDPIC_SYSROOT_DIR="$(call toolchain_find_sysroot,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
- FDPIC_LIB_DIR="$(call toolchain_find_libdir,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
- FDPIC_SUPPORT_LIB_DIR="" ; \
- if test `find $${FDPIC_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
- FDPIC_LIBSTDCPP_A_LOCATION=$$(LANG=C $${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
- if [ -e "$${FDPIC_LIBSTDCPP_A_LOCATION}" ]; then \
- FDPIC_SUPPORT_LIB_DIR=`readlink -f $${FDPIC_LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
- fi ; \
- fi ; \
- for libs in $(LIB_EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/lib); \
- done ; \
- for libs in $(USR_LIB_EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/usr/lib); \
+ for libs in $(LIB_EXTERNAL_LIBS) $(USR_LIB_EXTERNAL_LIBS); do \
+ $(call copy_toolchain_lib_root,$$libs); \
done
endef
endif
OpenPOWER on IntegriCloud