summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-07-02 13:39:35 +0200
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-07-05 12:20:05 +0200
commitb3cc7e65ee53a0413dca074259b80425f6102d03 (patch)
tree89afd959b0853181b4902be8cf548714d88a6f44
parent8bbc37e933e93742f5e9cb7d4571667a44bcbbd7 (diff)
downloadbuildroot-b3cc7e65ee53a0413dca074259b80425f6102d03.tar.gz
buildroot-b3cc7e65ee53a0413dca074259b80425f6102d03.zip
toolchain/helpers.mk: re-evaluate DESTDIR in copy_toolchain_lib_root
copy_toolchain_lib_root copies libraries from staging to target, resolving and copying symbolic links along the way. The most inner loop, a "while" loop, starts from an initial name, and if it's a symbolic link, gets resolved to the target, and the loop iterates until we reach a real file. However, the destination folder where the symbolic link or real file is created is computed in DESTDIR only once, before this loop starts. Therefore, this loop works fine when all symbolic links in the chain, and the real file all belong to the same directory. But it doesn't do the correct thing when the symbolic link and/or real file are in different folder. An example is Crosstool-NG musl toolchains, where the dynamic loader is in /lib/ld-musl*.so but points to ../usr/lib/libc.so. With the current logic, we copy /lib/ld-musl*.so to /lib, but we also copy libc.so to /lib instead of the expected /usr/lib. This currently doesn't cause any problem because the musl dynamic linker is manually created by the TOOLCHAIN_EXTERNAL_MUSL_LD_LINK hook. However, this logic has a number of problems, so in a followup commit, we are going to put the musl dynamic linker in TOOLCHAIN_EXTERNAL_LIBS, which will cause it to be copied by copy_toolchain_lib_root. But we obviously want the link and its target to be copied to the right place, hence this fix. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-rw-r--r--toolchain/helpers.mk2
1 files changed, 1 insertions, 1 deletions
diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 90834f4dc8..fe2b4b9d5c 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -13,10 +13,10 @@ copy_toolchain_lib_root = \
\
LIBPATHS=`find $(STAGING_DIR)/ -name "$${LIBPATTERN}" 2>/dev/null` ; \
for LIBPATH in $${LIBPATHS} ; do \
- DESTDIR=`echo $${LIBPATH} | sed "s,^$(STAGING_DIR)/,," | xargs dirname` ; \
mkdir -p $(TARGET_DIR)/$${DESTDIR}; \
while true ; do \
LIBNAME=`basename $${LIBPATH}`; \
+ DESTDIR=`echo $${LIBPATH} | sed "s,^$(STAGING_DIR)/,," | xargs dirname` ; \
rm -fr $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME}; \
if test -h $${LIBPATH} ; then \
cp -d $${LIBPATH} $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME}; \
OpenPOWER on IntegriCloud