All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root
@ 2017-02-07 21:56 Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 01/12] toolchain-external: reduce nesting in copy_toolchain_sysroot Thomas De Schampheleire
                   ` (12 more replies)
  0 siblings, 13 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Hi,

This toolchain patch series started out to fix the handling of the Cavium Octeon
2 toolchain (see patch "cover multilib toolchains with lib/<variant>/layout")
but along the way I fixed/improved a few other things.
Details are found in the commit messages of these patches.

I tested a number of external toolchains and arches available in Buildroot, as
well as the Octeon SDK toolchain.  I think I understand the situation
sufficiently well to get some confidence, but this is the type of
change that is difficult to get 100% certainty about.

Best regards,
Thomas

v3: after live review by ThomasP and Romain:
- reduce nesting level of copy_toolchain_sysroot
- remove unnecessarily added exclude of ARCH_LIB_DIR in rsync
- fix locale exclude
v2:
- fix broken symlinks in patch "cover multilib toolchains ..."
- simplification of fixed broken symlinks
- improvements in copy_toolchain_lib_root

Thomas De Schampheleire (12):
  toolchain-external: reduce nesting in copy_toolchain_sysroot
  toolchain-external: fix broken handling of 'usr/lib/locale'
  toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
  toolchain-external: handle ld.so fixups centrally
  toolchain helpers: introduce function relpath_prefix
  toolchain-external: cover multilib toolchains with lib/<variant>
    layout
  toolchain helpers: introduce simplify_symlink
  toolchain-external: simplify previously-broken symbolic links
  toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR
  toolchain: copy_toolchain_lib_root: clarify logic
  toolchain: copy_toolchain_lib_root: clarify input parameter
  toolchain: copy_toolchain_lib_root: copy symlinks instead of
    recreating them

 package/glibc/glibc.mk                             |   4 +-
 toolchain/helpers.mk                               | 124 +++++++++++++++++----
 .../toolchain-external/pkg-toolchain-external.mk   |  14 ++-
 .../toolchain-external-codesourcery-aarch64.mk     |  10 --
 4 files changed, 113 insertions(+), 39 deletions(-)

-- 
2.10.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 01/12] toolchain-external: reduce nesting in copy_toolchain_sysroot
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-03-01 22:22   ` Thomas Petazzoni
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 02/12] toolchain-external: fix broken handling of 'usr/lib/locale' Thomas De Schampheleire
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

As discussed with Thomas Petazzoni, we can reduce the nesting level by early
returning on an invalid iteration.

I did not move the 'else' case (the common case) outside the if-else because
it would make the code less symmetrical and IMO makes it _less_ clear.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: new patch

 toolchain/helpers.mk | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 72e7292..8cae996 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -89,11 +89,12 @@ copy_toolchain_sysroot = \
 	ARCH_LIB_DIR="$(strip $4)" ; \
 	SUPPORT_LIB_DIR="$(strip $5)" ; \
 	for i in etc $${ARCH_LIB_DIR} sbin usr usr/$${ARCH_LIB_DIR}; do \
-		if [ -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
-			rsync -au --chmod=u=rwX,go=rX --exclude 'usr/lib/locale' \
-				--include '/libexec*/' --exclude '/lib*/' \
-				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
+		if [ ! -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
+			continue ; \
 		fi ; \
+		rsync -au --chmod=u=rwX,go=rX --exclude 'usr/lib/locale' \
+			--include '/libexec*/' --exclude '/lib*/' \
+			$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
 	done ; \
 	if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
 		if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 02/12] toolchain-external: fix broken handling of 'usr/lib/locale'
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 01/12] toolchain-external: reduce nesting in copy_toolchain_sysroot Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-03-01 22:34   ` Thomas Petazzoni
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 03/12] toolchain-external: clarify rsync excludes in copy_toolchain_sysroot Thomas De Schampheleire
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Function copy_toolchain_sysroot, which is in charge of copying the relevant
bits from the external toolchain to the staging directory, performs an rsync
loop of various directories and excludes the pattern 'usr/lib/locale' with
the intention of skipping the directory <toolchain>/usr/lib/locale.

However, while this worked in the original commit, commit
5628776c4a4d29d0715633ea463b64cc19e19c5a broke it inadvertently. The
relevant part of the diff:

-    rsync -au --chmod=Du+w --exclude 'usr/lib/locale' \
-          $${ARCH_SYSROOT_DIR}/$$i $(STAGING_DIR)/ ; \
+    rsync -au --chmod=Du+w --exclude 'usr/lib/locale' \
+          --exclude lib --exclude lib32 --exclude lib64 \
+          $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \

Notice how the source directory now contains a trailing slash, which impacts
the way the exclude rules are interpreted. Previously, when 'i' was 'usr',
the exclude of 'usr/lib/locale' would find a match. With the trailing slash,
there will never be a match, unless for a directory 'usr/usr/lib/locale'.
The right rule would have been '--exclude lib/locale'.

However, just that fix does not solve the problem in all cases, in
particular in the (common) case where ARCH_LIB_DIR is 'lib'. This is due
another change in that commit, changing the iterated values of the above
rsync:

- for i in etc $${ARCH_LIB_DIR} sbin usr ; do \
+ for i in etc $${ARCH_LIB_DIR} sbin usr usr/$${ARCH_LIB_DIR}; do \

Due to the fact that we rsync both 'usr' as 'usr/lib' (assuming ARCH_LIB_DIR
is 'lib') we need to add the correct exclude in both cases. But the exclude
is different for both. When i == 'usr', the correct exclude rule would be
'--exclude lib/locale' while when i == 'usr/lib' the correct rule would be
'--exclude locale'.

Since we would like to avoid separate cases for this, use the following
exclude: '--exclude locale/'. The trailing slash will make sure only
directories called 'locale' will match. The targeted directories are then
usr/lib/locale and usr/share/locale. The latter directory was not matched
originally, but it should not hurt changing that.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: new patch

 toolchain/helpers.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 8cae996..6f87230 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -92,7 +92,7 @@ copy_toolchain_sysroot = \
 		if [ ! -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
 			continue ; \
 		fi ; \
-		rsync -au --chmod=u=rwX,go=rX --exclude 'usr/lib/locale' \
+		rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
 			--include '/libexec*/' --exclude '/lib*/' \
 			$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
 	done ; \
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 03/12] toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 01/12] toolchain-external: reduce nesting in copy_toolchain_sysroot Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 02/12] toolchain-external: fix broken handling of 'usr/lib/locale' Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 23:03   ` Romain Naour
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 04/12] toolchain-external: handle ld.so fixups centrally Thomas De Schampheleire
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

The copy_toolchain_sysroot helper features a complex rsync loop that copies
various directories from the extracted toolchain to the staging directory.
The complexity mainly stems from the fact that we support multilib toolchain
tarballs but only copy one of the multilib variants into staging.

Increase understandability of this logic by explicitly restricting the
rsync excludes to the iteration of the for loop they are relevant for.
Additionally, update the function comment.

Note: all attempts to reduce duplication between both rsync while keeping
things nice and readable failed. One has to be extremely careful regarding
line continuation, indentation, and single vs double quoting. In the end, a
split up rsync seemed most clean.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v2,v3: no changes other than rebase

 toolchain/helpers.mk | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 6f87230..33f6213 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -39,11 +39,16 @@ copy_toolchain_lib_root = \
 # dir. The operation of this function is rendered a little bit
 # complicated by the support for multilib toolchains.
 #
-# We start by copying etc, lib, sbin and usr from the sysroot of the
-# selected architecture variant (as pointed by ARCH_SYSROOT_DIR). This
-# allows to import into the staging directory the C library and
-# companion libraries for the correct architecture variant. We
-# explictly only copy etc, lib, sbin and usr since other directories
+# We start by copying etc, 'lib', sbin, usr and usr/'lib' from the
+# sysroot of the selected architecture variant (as pointed to by
+# ARCH_SYSROOT_DIR). This allows to import into the staging directory
+# the C library and companion libraries for the correct architecture
+# variant. 'lib' may not be literally 'lib' but could be something else,
+# e.g. lib32-fp (as determined by ARCH_LIB_DIR) and we only want to copy
+# that lib directory and no other. When copying usr, we therefore need
+# to be extra careful not to include usr/lib* but we _do_ want to
+# include usr/libexec.
+# We are selective in the directories we copy since other directories
 # might exist for other architecture variants (on Codesourcery
 # toolchain, the sysroot for the default architecture variant contains
 # the armv4t and thumb2 subdirectories, which are the sysroot for the
@@ -92,9 +97,14 @@ copy_toolchain_sysroot = \
 		if [ ! -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
 			continue ; \
 		fi ; \
-		rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
-			--include '/libexec*/' --exclude '/lib*/' \
-			$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
+		if [ "$$i" = "usr" ]; then \
+			rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
+				--include '/libexec*/' --exclude '/lib*/' \
+				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
+		else \
+			rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
+				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
+		fi ; \
 	done ; \
 	if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
 		if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 04/12] toolchain-external: handle ld.so fixups centrally
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (2 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 03/12] toolchain-external: clarify rsync excludes in copy_toolchain_sysroot Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 05/12] toolchain helpers: introduce function relpath_prefix Thomas De Schampheleire
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Normally, the Buildroot toolchain logic copies all required libraries from
the external toolchain to the staging directory, including the dynamic
loader ld-*.so.
There are cases, however, where the dynamic loader is _not_ automatically
copied to staging. This happens when the dynamic loader is not inside
ARCH_LIB_DIR itself (e.g. lib64), but instead resides in 'lib' (assume, of
course, that ARCH_LIB_DIR != 'lib').

Currently, this is fixed in a toolchain-specific fixup, e.g. by recreating a
missing symlink or copying over a missing file. Such toolchain specific
fixups are not very nice.

Moreover, in a subsequent patch, the value of ARCH_LIB_DIR changes for some
toolchains, causing them to have the same problem of a missing dynamic
loader. This used to be the case for older Linaro toolchains with libraries
in 'lib/<tuple>': Buildroot used to set ARCH_LIB_DIR=lib but the mentioned
patch changes it to 'lib/<tuple>' instead. As a result, the files directly
under 'lib/' will no longer be copied. There should be none, but the dynamic
loader is a notable exception.
[Note: support for these older Linaro toolchain has been removed in 2016.11]

Instead, copy over the ld.so file(s)/link(s) from the extracted toolchain
into staging, in the central copy_toolchain_sysroot function. The existing
toolchain logic will then handle the copy of these files from staging to
target.
This means the toolchain-specific fixups can be removed.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v2,v3: no changes

 toolchain/helpers.mk                                          | 11 +++++++++++
 .../toolchain-external-codesourcery-aarch64.mk                | 10 ----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 33f6213..27a7334 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -55,6 +55,11 @@ copy_toolchain_lib_root = \
 # corresponding architecture variants), and we don't want to import
 # them.
 #
+# It is possible that ARCH_LIB_DIR does not contain the dynamic loader
+# (ld*.so or similar) because it (or the main symlink to it) normally
+# resides in /lib while ARCH_LIB_DIR may be something else (e.g. lib64).
+# Therefore, copy the dynamic loader separately.
+#
 # Then, if the selected architecture variant is not the default one
 # (i.e, if SYSROOT_DIR != ARCH_SYSROOT_DIR), then we :
 #
@@ -106,6 +111,12 @@ copy_toolchain_sysroot = \
 				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
 		fi ; \
 	done ; \
+	if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so ]; then \
+		cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so $(STAGING_DIR)/lib/ ; \
+	fi ; \
+	if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so.* ]; then \
+		cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so.* $(STAGING_DIR)/lib/ ; \
+	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 ; \
diff --git a/toolchain/toolchain-external/toolchain-external-codesourcery-aarch64/toolchain-external-codesourcery-aarch64.mk b/toolchain/toolchain-external/toolchain-external-codesourcery-aarch64/toolchain-external-codesourcery-aarch64.mk
index bc58c44..5f4453a 100644
--- a/toolchain/toolchain-external/toolchain-external-codesourcery-aarch64/toolchain-external-codesourcery-aarch64.mk
+++ b/toolchain/toolchain-external/toolchain-external-codesourcery-aarch64/toolchain-external-codesourcery-aarch64.mk
@@ -9,14 +9,4 @@ TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_VERSION = 2014.11-95
 TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_SOURCE = aarch64-amd-$(TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_VERSION)-$(TOOLCHAIN_EXTERNAL_PREFIX)-i686-pc-linux-gnu.tar.bz2
 TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_ACTUAL_SOURCE_TARBALL = aarch64-amd-$(TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_VERSION)-$(TOOLCHAIN_EXTERNAL_PREFIX).src.tar.bz2
 
-define TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_STAGING_FIXUP
-	ln -sf ld-2.20.so $(STAGING_DIR)/lib/ld-linux-aarch64.so.1
-endef
-TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_STAGING_FIXUP
-
-define TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_TARGET_FIXUP
-	ln -sf ld-2.20.so $(TARGET_DIR)/lib/ld-linux-aarch64.so.1
-endef
-TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_POST_INSTALL_TARGET_HOOKS += TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_TARGET_FIXUP
-
 $(eval $(toolchain-external-package))
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 05/12] toolchain helpers: introduce function relpath_prefix
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (3 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 04/12] toolchain-external: handle ld.so fixups centrally Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 06/12] toolchain-external: cover multilib toolchains with lib/<variant> layout Thomas De Schampheleire
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

The helper function copy_toolchain_sysroot has some logic to transform a
path into a number of '../' components based on the depth of that path.

As this same logic will be needed in another place in a subsequent patch,
extract it into a separate helper relpath_prefix.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v2,v3: no changes

 toolchain/helpers.mk | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 27a7334..36bad03 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -122,11 +122,7 @@ copy_toolchain_sysroot = \
 			cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
 		fi ; \
 		mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \
-		relpath="./" ; \
-		nbslashs=`printf $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \
-		for slash in `seq 1 $${nbslashs}` ; do \
-			relpath=$${relpath}"../" ; \
-		done ; \
+		relpath="$(call relpath_prefix,$${ARCH_SUBDIR})./" ; \
 		ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
 		echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
 	fi ; \
@@ -425,3 +421,22 @@ check_toolchain_ssp = \
 gen_gdbinit_file = \
 	mkdir -p $(STAGING_DIR)/usr/share/buildroot/ ; \
 	echo "set sysroot $(STAGING_DIR)" > $(STAGING_DIR)/usr/share/buildroot/gdbinit
+
+# Given a path, determine the relative prefix (../) needed to return to the
+# root level. Note that the last component is treated as a file component; use a
+# trailing slash to force treating it as a directory. Examples:
+#     relpath_prefix(lib32) = ""
+#     relpath_prefix(lib32/octeon2) = "../"
+#     relpath_prefix(lib32/octeon2/) = "../../"
+#
+# $1: input path
+define relpath_prefix
+$$( \
+	prefix="" ; \
+	nbslashs=`printf $1 | sed 's%[^/]%%g' | wc -c` ; \
+	for slash in `seq 1 $${nbslashs}` ; do \
+		prefix=$${prefix}"../" ; \
+	done ; \
+	printf "$$prefix" ; \
+)
+endef
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 06/12] toolchain-external: cover multilib toolchains with lib/<variant> layout
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (4 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 05/12] toolchain helpers: introduce function relpath_prefix Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 07/12] toolchain helpers: introduce simplify_symlink Thomas De Schampheleire
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

The toolchain from the Cavium Octeon SDK has a sysroot layout as follows:

./lib32
./lib32/octeon2
./lib32-fp
./lib64
./lib64/octeon2
./lib64-fp
./usr
./usr/lib
./usr/lib32
./usr/lib32/octeon2
./usr/lib32-fp
./usr/lib64
./usr/lib64/octeon2
./usr/lib64-fp
./usr/bin
./usr/bin32
./usr/bin32-fp
./usr/bin64-fp
./usr/libexec
./usr/libexec32
./usr/libexec32-fp
./usr/libexec64-fp
./usr/sbin
./usr/sbin32
./usr/sbin32-fp
./usr/sbin64-fp
./usr/include
./usr/share
./sbin
./sbin32
./sbin32-fp
./sbin64-fp
./etc
./var

with the following selections:
- lib64          : default
- lib64/octeon2  : -march=octeon2
- lib64-fp       : -march=octeon3
- lib32          : -mabi=n32
- lib32/octeon2  : -mabi=n32 -march=octeon2
- lib32-fp       : -mabi=n32 -march=octeon3

In case of '-mabi=n32 -march=octeon2' (but same is true for n64+octeon2)the
original Buildroot toolchain logic would copy both the libraries in
lib32 as the subdirectory lib32/octeon2, which means that every library is
installed twice (but only one of each is really needed).

While ARCH_LIB_DIR is determined by the location of libc.a, which in this
case is effectively:
    <sysroot>/usr/lib32/octeon2/libc.a
the variable only retains 'lib32' and not 'lib32/octeon2' as expected.

To make Buildroot cope with this style of toolchain layout, we need to adapt
the calculation of ARCH_LIB_DIR to also include the second part.
This, in turn, means that ARCH_LIB_DIR is no longer guaranteed to be a
singular path component, resulting in some additional changes.

Certain older Linaro toolchains actually had the same layout. Libraries were
located in lib/<tuple> rather than lib directly. Previously, this was
handled by adding a toolchain-specific fixup that creates a symlink
lib/<tuple> -> lib, but with this patch this would no longer be needed.
Note that one difference with the Octeon case is that these Linaro
toolchains are not actually multilib, i.e. there is just one location with
the libraries and thus there is no problem with duplicated libraries.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: remove unnecessarily added exclude of ARCH_LIB_DIR in rsync
v2: fix broken symbolic links in usr/lib/octeon2/

 toolchain/helpers.mk                                | 21 +++++++++++++++++++--
 .../toolchain-external/pkg-toolchain-external.mk    | 10 +++++++---
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 36bad03..4534516 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -55,10 +55,19 @@ copy_toolchain_lib_root = \
 # corresponding architecture variants), and we don't want to import
 # them.
 #
+# If ARCH_LIB_DIR is not a singular directory component, e.g.
+# 'lib32/octeon2', then symbolic links in ARCH_LIB_DIR and
+# usr/ARCH_LIB_DIR may be broken because Buildroot will flatten the
+# directory structure (e.g. lib32/octeon2/foo is actually stored in
+# lib/foo). This is only relevant for links that contain one or more ../
+# components, as links to the current directory are always fine.
+# We need to fix the broken links by removing the right amount of ../
+# dots from the link destination.
+#
 # It is possible that ARCH_LIB_DIR does not contain the dynamic loader
 # (ld*.so or similar) because it (or the main symlink to it) normally
-# resides in /lib while ARCH_LIB_DIR may be something else (e.g. lib64).
-# Therefore, copy the dynamic loader separately.
+# resides in /lib while ARCH_LIB_DIR may be something else (e.g. lib64,
+# lib/<tuple>, ...). Therefore, copy the dynamic loader separately.
 #
 # Then, if the selected architecture variant is not the default one
 # (i.e, if SYSROOT_DIR != ARCH_SYSROOT_DIR), then we :
@@ -111,6 +120,14 @@ copy_toolchain_sysroot = \
 				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
 		fi ; \
 	done ; \
+	relpath="$(call relpath_prefix,$${ARCH_LIB_DIR})" ; \
+	if [ "$${relpath}" != "" ]; then \
+		for i in $$(find -H $(STAGING_DIR)/$${ARCH_LIB_DIR} $(STAGING_DIR)/usr/$${ARCH_LIB_DIR} -type l -xtype l); do \
+			LINKTARGET=`readlink $$i` ; \
+			NEWLINKTARGET=$${LINKTARGET\#$$relpath} ; \
+			ln -sf $${NEWLINKTARGET} $$i ; \
+		done ; \
+	fi ; \
 	if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so ]; then \
 		cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so $(STAGING_DIR)/lib/ ; \
 	fi ; \
diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk
index 6658875..ada767e 100644
--- a/toolchain/toolchain-external/pkg-toolchain-external.mk
+++ b/toolchain/toolchain-external/pkg-toolchain-external.mk
@@ -332,7 +332,7 @@ endef
 # Returns the lib subdirectory for the given compiler + flags (i.e
 # typically lib32 or lib64 for some toolchains)
 define toolchain_find_libdir
-$$(printf $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:.*/(usr/)?(lib(32|64)?([^/]*)?)/([^/]*/)?libc.a:\2:')
+$$(printf $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:.*/(usr/)?(lib(32|64)?([^/]*)?(/[^/]*)?)/libc.a:\2:')
 endef
 
 # Returns the location of the libc.a file for the given compiler + flags
@@ -442,14 +442,18 @@ endef
 # Create a symlink from (usr/)$(ARCH_LIB_DIR) to lib.
 # Note: the skeleton package additionally creates lib32->lib or lib64->lib
 # (as appropriate)
+# The relpath handling is needed in case ARCH_LIB_DIR is not a singular path
+# like 'lib32-foo' but a composite one, like 'lib/foo'. In either case, we need
+# to link to the top-level 'lib'.
 #
 # $1: destination directory (TARGET_DIR / STAGING_DIR)
 create_lib_symlinks = \
        $(Q)DESTDIR="$(strip $1)" ; \
        ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
        if [ ! -e "$${DESTDIR}/$${ARCH_LIB_DIR}" -a ! -e "$${DESTDIR}/usr/$${ARCH_LIB_DIR}" ]; then \
-               ln -snf lib "$${DESTDIR}/$${ARCH_LIB_DIR}" ; \
-               ln -snf lib "$${DESTDIR}/usr/$${ARCH_LIB_DIR}" ; \
+               relpath="$(call relpath_prefix,$${ARCH_LIB_DIR})" ; \
+               ln -snf $${relpath}lib "$${DESTDIR}/$${ARCH_LIB_DIR}" ; \
+               ln -snf $${relpath}lib "$${DESTDIR}/usr/$${ARCH_LIB_DIR}" ; \
        fi
 
 define TOOLCHAIN_EXTERNAL_CREATE_STAGING_LIB_SYMLINK
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 07/12] toolchain helpers: introduce simplify_symlink
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (5 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 06/12] toolchain-external: cover multilib toolchains with lib/<variant> layout Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 08/12] toolchain-external: simplify previously-broken symbolic links Thomas De Schampheleire
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

The external toolchain logic flattens the directory layout in the staging
directory.  Regardless of the number of levels present in the extracted
toolchain, libraries are always copied to lib/ and usr/lib/, and directory
symbolic links are provided to make the original paths available as well.

Due to this, the same library may be reachable through a number of paths:
one path without any symbolic link, and one or more paths using directory
symlinks.

Using a direct path in a symlink destination is generally preferred because
it is clearer, but it is also more robust against accidental removal of an
intermediate directory symlink.

Introduce a helper function to simplify a symlink's destination to such a
direct path. This function will be used in a subsequent patch.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: no changes
v2: new patch

 toolchain/helpers.mk | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 4534516..7bc5498 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -457,3 +457,30 @@ $$( \
 	printf "$$prefix" ; \
 )
 endef
+
+# Replace the destination of a symbolic link with a simpler version
+# For example,
+#     usr/lib/libfoo.so -> ../../lib32/libfoo.so.1
+# becomes
+#     usr/lib/libfoo.so -> ../../lib/libfoo.so.1
+# since 'lib32' is a symlink to 'lib'.
+#
+# Likewise,
+#     usr/lib/octeon2/libbar.so -> ../../../lib32/octeon2/libbar.so.1
+# becomes
+#     usr/lib/octeon2/libbar.so -> ../../lib/libbar.so.1
+# assuming lib32->lib and lib/octeon2->lib.
+#
+# $1: symlink
+# $2: base path
+define simplify_symlink
+( \
+	FULL_SRC="$$(readlink -f $$(dirname $1))/$$(basename $1)" ; \
+	FULL_DEST="$$(readlink -f $1)" ; \
+	FULL_BASE="$$(readlink -f $2)" ; \
+	REL_SRC="$${FULL_SRC#$${FULL_BASE}/}" ; \
+	REL_DEST="$${FULL_DEST#$${FULL_BASE}/}" ; \
+	DOTS="$(call relpath_prefix,$${REL_SRC})" ; \
+	ln -sf "$${DOTS}$${REL_DEST}" "$${FULL_SRC}" ; \
+)
+endef
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 08/12] toolchain-external: simplify previously-broken symbolic links
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (6 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 07/12] toolchain helpers: introduce simplify_symlink Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 09/12] toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR Thomas De Schampheleire
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

A previous commit rewrote broken symbolic links in staging, caused by a
non-singular ARCH_LIB_DIR. In this case, the symbolic links are typically
using one or more intermediate directory symlinks, which can be simplified
using the newly introduced simplify_symlink helper.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: no changes
v2: new patch

 toolchain/helpers.mk | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 7bc5498..fda6146 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -63,6 +63,8 @@ copy_toolchain_lib_root = \
 # components, as links to the current directory are always fine.
 # We need to fix the broken links by removing the right amount of ../
 # dots from the link destination.
+# Once the link destination is valid again, it can be simplified to
+# remove the dependency on intermediate directory symlinks.
 #
 # It is possible that ARCH_LIB_DIR does not contain the dynamic loader
 # (ld*.so or similar) because it (or the main symlink to it) normally
@@ -126,6 +128,7 @@ copy_toolchain_sysroot = \
 			LINKTARGET=`readlink $$i` ; \
 			NEWLINKTARGET=$${LINKTARGET\#$$relpath} ; \
 			ln -sf $${NEWLINKTARGET} $$i ; \
+			$(call simplify_symlink,$$i,$(STAGING_DIR)) ; \
 		done ; \
 	fi ; \
 	if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so ]; then \
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 09/12] toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (7 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 08/12] toolchain-external: simplify previously-broken symbolic links Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 10/12] toolchain: copy_toolchain_lib_root: clarify logic Thomas De Schampheleire
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: no changes
v2: new patch

 toolchain/helpers.mk | 1 -
 1 file changed, 1 deletion(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index fda6146..6b32a25 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -17,7 +17,6 @@ copy_toolchain_lib_root = \
 		mkdir -p $(TARGET_DIR)/$${DESTDIR}; \
 		while true ; do \
 			LIBNAME=`basename $${LIBPATH}`; \
-			LIBDIR=`dirname $${LIBPATH}` ; \
 			LINKTARGET=`readlink $${LIBPATH}` ; \
 			rm -fr $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME}; \
 			if test -h $${LIBPATH} ; then \
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 10/12] toolchain: copy_toolchain_lib_root: clarify logic
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (8 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 09/12] toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 11/12] toolchain: copy_toolchain_lib_root: clarify input parameter Thomas De Schampheleire
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

copy_toolchain_lib_root has slightly different logic depending on the type
of library object: file or link. All actions related to links are not
relevant in case you are working with a file. Hence, try to increase clarity
by not executing unnecessary lines in the 'file' case.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: no changes
v2: new patch

 toolchain/helpers.mk | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 6b32a25..87733be 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -17,19 +17,17 @@ copy_toolchain_lib_root = \
 		mkdir -p $(TARGET_DIR)/$${DESTDIR}; \
 		while true ; do \
 			LIBNAME=`basename $${LIBPATH}`; \
-			LINKTARGET=`readlink $${LIBPATH}` ; \
 			rm -fr $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME}; \
 			if test -h $${LIBPATH} ; then \
+				LINKTARGET=`readlink $${LIBPATH}` ; \
 				ln -sf `basename $${LINKTARGET}` $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME} ; \
+				LIBPATH="`readlink -f $${LIBPATH}`"; \
 			elif test -f $${LIBPATH}; then \
 				$(INSTALL) -D -m0755 $${LIBPATH} $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME}; \
+				break ; \
 			else \
 				exit -1; \
 			fi; \
-			if test -z "$${LINKTARGET}" ; then \
-				break ; \
-			fi ; \
-			LIBPATH="`readlink -f $${LIBPATH}`"; \
 		done; \
 	done
 
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 11/12] toolchain: copy_toolchain_lib_root: clarify input parameter
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (9 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 10/12] toolchain: copy_toolchain_lib_root: clarify logic Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 12/12] toolchain: copy_toolchain_lib_root: copy symlinks instead of recreating them Thomas De Schampheleire
  2017-04-05 19:54 ` [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas Petazzoni
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

The input to copy_toolchain_lib_root is not one library, not a list of
libraries, but a library name pattern with glob wildcards.
This pattern is then passed to 'find' to get the actual list of libraries
matching the pattern. Reflect this using an appropriate variable name.

Note: if the root of the buildroot tree contains a file matching one of
these library patterns, the copying of libraries from staging to target will
not be correct. It is not impossible to fix that, e.g. using 'set -f', but
maybe it's not worth it.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: no changes
v2: new patch

 package/glibc/glibc.mk                                 | 4 ++--
 toolchain/helpers.mk                                   | 6 +++---
 toolchain/toolchain-external/pkg-toolchain-external.mk | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/package/glibc/glibc.mk b/package/glibc/glibc.mk
index c11f7cd..2da9606 100644
--- a/package/glibc/glibc.mk
+++ b/package/glibc/glibc.mk
@@ -110,8 +110,8 @@ GLIBC_LIBS_LIB += libthread_db.so.*
 endif
 
 define GLIBC_INSTALL_TARGET_CMDS
-	for libs in $(GLIBC_LIBS_LIB); do \
-		$(call copy_toolchain_lib_root,$$libs) ; \
+	for libpattern in $(GLIBC_LIBS_LIB); do \
+		$(call copy_toolchain_lib_root,$$libpattern) ; \
 	done
 endef
 
diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 87733be..95505aa 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -6,12 +6,12 @@
 # toolchain logic, and the glibc package, so care must be taken when
 # changing this function.
 #
-# $1: library name
+# $1: library name pattern (can include glob wildcards)
 #
 copy_toolchain_lib_root = \
-	LIB="$(strip $1)"; \
+	LIBPATTERN="$(strip $1)"; \
 \
-	LIBPATHS=`find $(STAGING_DIR)/ -name "$${LIB}" 2>/dev/null` ; \
+	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}; \
diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk
index ada767e..d62e2cf 100644
--- a/toolchain/toolchain-external/pkg-toolchain-external.mk
+++ b/toolchain/toolchain-external/pkg-toolchain-external.mk
@@ -387,8 +387,8 @@ endef
 ifeq ($(BR2_STATIC_LIBS),)
 define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS
 	$(Q)$(call MESSAGE,"Copying external toolchain libraries to target...")
-	$(Q)for libs in $(TOOLCHAIN_EXTERNAL_LIBS); do \
-		$(call copy_toolchain_lib_root,$$libs); \
+	$(Q)for libpattern in $(TOOLCHAIN_EXTERNAL_LIBS); do \
+		$(call copy_toolchain_lib_root,$$libpattern); \
 	done
 endef
 endif
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 12/12] toolchain: copy_toolchain_lib_root: copy symlinks instead of recreating them
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (10 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 11/12] toolchain: copy_toolchain_lib_root: clarify input parameter Thomas De Schampheleire
@ 2017-02-07 21:56 ` Thomas De Schampheleire
  2017-04-05 19:54 ` [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas Petazzoni
  12 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-07 21:56 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

copy_toolchain_lib_root handles symlinks by recreating them, disregarding
the original destination and assuming the destination is in the same
directory as the link itself.
When a library link points to the real library file in another directory,
for example:
    usr/lib/octeon2/libcrypt.so -> ../../../lib32/octeon2/libcrypt.so.1
then the link created by copy_toolchain_lib_root is broken.

It is more robust to copy the symlink to keep the destination intact. The
destination path should be present, possibly through other symbolic links.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
v3: no changes
v2: new patch

 toolchain/helpers.mk | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 95505aa..f97b060 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -19,8 +19,7 @@ copy_toolchain_lib_root = \
 			LIBNAME=`basename $${LIBPATH}`; \
 			rm -fr $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME}; \
 			if test -h $${LIBPATH} ; then \
-				LINKTARGET=`readlink $${LIBPATH}` ; \
-				ln -sf `basename $${LINKTARGET}` $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME} ; \
+				cp -d $${LIBPATH} $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME}; \
 				LIBPATH="`readlink -f $${LIBPATH}`"; \
 			elif test -f $${LIBPATH}; then \
 				$(INSTALL) -D -m0755 $${LIBPATH} $(TARGET_DIR)/$${DESTDIR}/$${LIBNAME}; \
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 03/12] toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 03/12] toolchain-external: clarify rsync excludes in copy_toolchain_sysroot Thomas De Schampheleire
@ 2017-02-07 23:03   ` Romain Naour
  2017-02-08  9:22     ` Thomas De Schampheleire
  0 siblings, 1 reply; 22+ messages in thread
From: Romain Naour @ 2017-02-07 23:03 UTC (permalink / raw)
  To: buildroot

Le 07/02/2017 ? 22:56, Thomas De Schampheleire a ?crit :
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> 
> The copy_toolchain_sysroot helper features a complex rsync loop that copies
> various directories from the extracted toolchain to the staging directory.
> The complexity mainly stems from the fact that we support multilib toolchain
> tarballs but only copy one of the multilib variants into staging.
> 
> Increase understandability of this logic by explicitly restricting the
> rsync excludes to the iteration of the for loop they are relevant for.
> Additionally, update the function comment.
> 
> Note: all attempts to reduce duplication between both rsync while keeping
> things nice and readable failed. One has to be extremely careful regarding
> line continuation, indentation, and single vs double quoting. In the end, a
> split up rsync seemed most clean.
> 
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
> v2,v3: no changes other than rebase
> 
>  toolchain/helpers.mk | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
> index 6f87230..33f6213 100644
> --- a/toolchain/helpers.mk
> +++ b/toolchain/helpers.mk
> @@ -39,11 +39,16 @@ copy_toolchain_lib_root = \
>  # dir. The operation of this function is rendered a little bit
>  # complicated by the support for multilib toolchains.
>  #
> -# We start by copying etc, lib, sbin and usr from the sysroot of the
> -# selected architecture variant (as pointed by ARCH_SYSROOT_DIR). This
> -# allows to import into the staging directory the C library and
> -# companion libraries for the correct architecture variant. We
> -# explictly only copy etc, lib, sbin and usr since other directories
> +# We start by copying etc, 'lib', sbin, usr and usr/'lib' from the
> +# sysroot of the selected architecture variant (as pointed to by
> +# ARCH_SYSROOT_DIR). This allows to import into the staging directory
> +# the C library and companion libraries for the correct architecture
> +# variant. 'lib' may not be literally 'lib' but could be something else,
> +# e.g. lib32-fp (as determined by ARCH_LIB_DIR) and we only want to copy
> +# that lib directory and no other. When copying usr, we therefore need
> +# to be extra careful not to include usr/lib* but we _do_ want to
> +# include usr/libexec.
> +# We are selective in the directories we copy since other directories
>  # might exist for other architecture variants (on Codesourcery
>  # toolchain, the sysroot for the default architecture variant contains
>  # the armv4t and thumb2 subdirectories, which are the sysroot for the
> @@ -92,9 +97,14 @@ copy_toolchain_sysroot = \
>  		if [ ! -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
>  			continue ; \
>  		fi ; \
> -		rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
> -			--include '/libexec*/' --exclude '/lib*/' \
> -			$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
> +		if [ "$$i" = "usr" ]; then \
> +			rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
> +				--include '/libexec*/' --exclude '/lib*/' \
> +				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
> +		else \
> +			rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
> +				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \

With the current CodeSourcery NiosII toolchain, this change have a weird side
effect...

If you look at "host/opt/ext-toolchain/nios2-linux-gnu/libc/usr/lib/", you will
find a directory named "libffi-3.2.1". This directory contain the libffi headers !?

ls libffi-3.2.1/include
ffi.h  ffitarget.h

So this directory is now present in STAGING_DIR:
ls staging/usr/lib/libffi-3.2.1

I think it's a mistake in the toolchain itself...

Best regards,
Romain

> +		fi ; \
>  	done ; \
>  	if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
>  		if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 03/12] toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
  2017-02-07 23:03   ` Romain Naour
@ 2017-02-08  9:22     ` Thomas De Schampheleire
  2017-02-08  9:45       ` Thomas Petazzoni
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-02-08  9:22 UTC (permalink / raw)
  To: buildroot

Hi Romain,

On Wed, Feb 8, 2017 at 12:03 AM, Romain Naour <romain.naour@gmail.com> wrote:
> Le 07/02/2017 ? 22:56, Thomas De Schampheleire a ?crit :
>> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>>
>> The copy_toolchain_sysroot helper features a complex rsync loop that copies
>> various directories from the extracted toolchain to the staging directory.
>> The complexity mainly stems from the fact that we support multilib toolchain
>> tarballs but only copy one of the multilib variants into staging.
>>
>> Increase understandability of this logic by explicitly restricting the
>> rsync excludes to the iteration of the for loop they are relevant for.
>> Additionally, update the function comment.
>>
>> Note: all attempts to reduce duplication between both rsync while keeping
>> things nice and readable failed. One has to be extremely careful regarding
>> line continuation, indentation, and single vs double quoting. In the end, a
>> split up rsync seemed most clean.
>>
>> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>> ---
>> v2,v3: no changes other than rebase
>>
>>  toolchain/helpers.mk | 26 ++++++++++++++++++--------
>>  1 file changed, 18 insertions(+), 8 deletions(-)
>>
>> diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
>> index 6f87230..33f6213 100644
>> --- a/toolchain/helpers.mk
>> +++ b/toolchain/helpers.mk
>> @@ -39,11 +39,16 @@ copy_toolchain_lib_root = \
>>  # dir. The operation of this function is rendered a little bit
>>  # complicated by the support for multilib toolchains.
>>  #
>> -# We start by copying etc, lib, sbin and usr from the sysroot of the
>> -# selected architecture variant (as pointed by ARCH_SYSROOT_DIR). This
>> -# allows to import into the staging directory the C library and
>> -# companion libraries for the correct architecture variant. We
>> -# explictly only copy etc, lib, sbin and usr since other directories
>> +# We start by copying etc, 'lib', sbin, usr and usr/'lib' from the
>> +# sysroot of the selected architecture variant (as pointed to by
>> +# ARCH_SYSROOT_DIR). This allows to import into the staging directory
>> +# the C library and companion libraries for the correct architecture
>> +# variant. 'lib' may not be literally 'lib' but could be something else,
>> +# e.g. lib32-fp (as determined by ARCH_LIB_DIR) and we only want to copy
>> +# that lib directory and no other. When copying usr, we therefore need
>> +# to be extra careful not to include usr/lib* but we _do_ want to
>> +# include usr/libexec.
>> +# We are selective in the directories we copy since other directories
>>  # might exist for other architecture variants (on Codesourcery
>>  # toolchain, the sysroot for the default architecture variant contains
>>  # the armv4t and thumb2 subdirectories, which are the sysroot for the
>> @@ -92,9 +97,14 @@ copy_toolchain_sysroot = \
>>               if [ ! -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
>>                       continue ; \
>>               fi ; \
>> -             rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
>> -                     --include '/libexec*/' --exclude '/lib*/' \
>> -                     $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
>> +             if [ "$$i" = "usr" ]; then \
>> +                     rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
>> +                             --include '/libexec*/' --exclude '/lib*/' \
>> +                             $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
>> +             else \
>> +                     rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
>> +                             $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
>
> With the current CodeSourcery NiosII toolchain, this change have a weird side
> effect...
>
> If you look at "host/opt/ext-toolchain/nios2-linux-gnu/libc/usr/lib/", you will
> find a directory named "libffi-3.2.1". This directory contain the libffi headers !?
>
> ls libffi-3.2.1/include
> ffi.h  ffitarget.h
>
> So this directory is now present in STAGING_DIR:
> ls staging/usr/lib/libffi-3.2.1
>
> I think it's a mistake in the toolchain itself...

Yes, I think so too. It is very weird that headers would be placed in
usr/lib/something. Are they also present elsewhere, like in
usr/include ?

In any case, the fact that these files are now present in staging
should not hurt. Also for target it will not make a difference.

Also, the fact that they used to be skipped with the original code is
more of an accident, than actual intention.

Thanks,
Thomas

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 03/12] toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
  2017-02-08  9:22     ` Thomas De Schampheleire
@ 2017-02-08  9:45       ` Thomas Petazzoni
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Petazzoni @ 2017-02-08  9:45 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 8 Feb 2017 10:22:14 +0100, Thomas De Schampheleire wrote:

> > With the current CodeSourcery NiosII toolchain, this change have a weird side
> > effect...
> >
> > If you look at "host/opt/ext-toolchain/nios2-linux-gnu/libc/usr/lib/", you will
> > find a directory named "libffi-3.2.1". This directory contain the libffi headers !?
> >
> > ls libffi-3.2.1/include
> > ffi.h  ffitarget.h
> >
> > So this directory is now present in STAGING_DIR:
> > ls staging/usr/lib/libffi-3.2.1
> >
> > I think it's a mistake in the toolchain itself...  
> 
> Yes, I think so too. It is very weird that headers would be placed in
> usr/lib/something. Are they also present elsewhere, like in
> usr/include ?
> 
> In any case, the fact that these files are now present in staging
> should not hurt. Also for target it will not make a difference.
> 
> Also, the fact that they used to be skipped with the original code is
> more of an accident, than actual intention.

Agreed. This is more a bug in the toolchain that anything else. We can
always add a custom toolchain hook to get rid of them. But since they
are only in staging, I don't think it's really worth the effort.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 01/12] toolchain-external: reduce nesting in copy_toolchain_sysroot
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 01/12] toolchain-external: reduce nesting in copy_toolchain_sysroot Thomas De Schampheleire
@ 2017-03-01 22:22   ` Thomas Petazzoni
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Petazzoni @ 2017-03-01 22:22 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue,  7 Feb 2017 22:56:38 +0100, Thomas De Schampheleire wrote:
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> 
> As discussed with Thomas Petazzoni, we can reduce the nesting level by early
> returning on an invalid iteration.
> 
> I did not move the 'else' case (the common case) outside the if-else because
> it would make the code less symmetrical and IMO makes it _less_ clear.
> 
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
> v3: new patch

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 02/12] toolchain-external: fix broken handling of 'usr/lib/locale'
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 02/12] toolchain-external: fix broken handling of 'usr/lib/locale' Thomas De Schampheleire
@ 2017-03-01 22:34   ` Thomas Petazzoni
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Petazzoni @ 2017-03-01 22:34 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue,  7 Feb 2017 22:56:39 +0100, Thomas De Schampheleire wrote:
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> 
> Function copy_toolchain_sysroot, which is in charge of copying the relevant
> bits from the external toolchain to the staging directory, performs an rsync
> loop of various directories and excludes the pattern 'usr/lib/locale' with
> the intention of skipping the directory <toolchain>/usr/lib/locale.
> 
> However, while this worked in the original commit, commit
> 5628776c4a4d29d0715633ea463b64cc19e19c5a broke it inadvertently. The
> relevant part of the diff:
> 
> -    rsync -au --chmod=Du+w --exclude 'usr/lib/locale' \
> -          $${ARCH_SYSROOT_DIR}/$$i $(STAGING_DIR)/ ; \
> +    rsync -au --chmod=Du+w --exclude 'usr/lib/locale' \
> +          --exclude lib --exclude lib32 --exclude lib64 \
> +          $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
> 
> Notice how the source directory now contains a trailing slash, which impacts
> the way the exclude rules are interpreted. Previously, when 'i' was 'usr',
> the exclude of 'usr/lib/locale' would find a match. With the trailing slash,
> there will never be a match, unless for a directory 'usr/usr/lib/locale'.
> The right rule would have been '--exclude lib/locale'.
> 
> However, just that fix does not solve the problem in all cases, in
> particular in the (common) case where ARCH_LIB_DIR is 'lib'. This is due
> another change in that commit, changing the iterated values of the above
> rsync:
> 
> - for i in etc $${ARCH_LIB_DIR} sbin usr ; do \
> + for i in etc $${ARCH_LIB_DIR} sbin usr usr/$${ARCH_LIB_DIR}; do \
> 
> Due to the fact that we rsync both 'usr' as 'usr/lib' (assuming ARCH_LIB_DIR
> is 'lib') we need to add the correct exclude in both cases. But the exclude
> is different for both. When i == 'usr', the correct exclude rule would be
> '--exclude lib/locale' while when i == 'usr/lib' the correct rule would be
> '--exclude locale'.
> 
> Since we would like to avoid separate cases for this, use the following
> exclude: '--exclude locale/'. The trailing slash will make sure only
> directories called 'locale' will match. The targeted directories are then
> usr/lib/locale and usr/share/locale. The latter directory was not matched
> originally, but it should not hurt changing that.
> 
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
> v3: new patch

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root
  2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
                   ` (11 preceding siblings ...)
  2017-02-07 21:56 ` [Buildroot] [PATCHv3 12/12] toolchain: copy_toolchain_lib_root: copy symlinks instead of recreating them Thomas De Schampheleire
@ 2017-04-05 19:54 ` Thomas Petazzoni
  2017-04-05 20:15   ` Thomas De Schampheleire
  12 siblings, 1 reply; 22+ messages in thread
From: Thomas Petazzoni @ 2017-04-05 19:54 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue,  7 Feb 2017 22:56:37 +0100, Thomas De Schampheleire wrote:

> Thomas De Schampheleire (12):
>   toolchain-external: reduce nesting in copy_toolchain_sysroot
>   toolchain-external: fix broken handling of 'usr/lib/locale'
>   toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
>   toolchain-external: handle ld.so fixups centrally
>   toolchain helpers: introduce function relpath_prefix
>   toolchain-external: cover multilib toolchains with lib/<variant>
>     layout
>   toolchain helpers: introduce simplify_symlink
>   toolchain-external: simplify previously-broken symbolic links
>   toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR
>   toolchain: copy_toolchain_lib_root: clarify logic
>   toolchain: copy_toolchain_lib_root: clarify input parameter
>   toolchain: copy_toolchain_lib_root: copy symlinks instead of
>     recreating them

I've now applied the remainder of the series, patches 3 to 12. I still
find this quite complicated overall, but I couldn't find any other
solution and nobody else did, and the problem scope is complicated
anyway.

Let's see the feedback we get from users :)

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root
  2017-04-05 19:54 ` [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas Petazzoni
@ 2017-04-05 20:15   ` Thomas De Schampheleire
  2017-04-06 17:09     ` Thomas Petazzoni
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-04-05 20:15 UTC (permalink / raw)
  To: buildroot

On Apr 5, 2017 21:54, "Thomas Petazzoni" <
thomas.petazzoni@free-electrons.com> wrote:

Hello,

On Tue,  7 Feb 2017 22:56:37 +0100, Thomas De Schampheleire wrote:

> Thomas De Schampheleire (12):
>   toolchain-external: reduce nesting in copy_toolchain_sysroot
>   toolchain-external: fix broken handling of 'usr/lib/locale'
>   toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
>   toolchain-external: handle ld.so fixups centrally
>   toolchain helpers: introduce function relpath_prefix
>   toolchain-external: cover multilib toolchains with lib/<variant>
>     layout
>   toolchain helpers: introduce simplify_symlink
>   toolchain-external: simplify previously-broken symbolic links
>   toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR
>   toolchain: copy_toolchain_lib_root: clarify logic
>   toolchain: copy_toolchain_lib_root: clarify input parameter
>   toolchain: copy_toolchain_lib_root: copy symlinks instead of
>     recreating them

I've now applied the remainder of the series, patches 3 to 12. I still
find this quite complicated overall, but I couldn't find any other
solution and nobody else did, and the problem scope is complicated
anyway.

Let's see the feedback we get from users :)


Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170405/c5f5ae17/attachment.html>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root
  2017-04-05 20:15   ` Thomas De Schampheleire
@ 2017-04-06 17:09     ` Thomas Petazzoni
  2017-04-06 17:51       ` Thomas De Schampheleire
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas Petazzoni @ 2017-04-06 17:09 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 5 Apr 2017 22:15:40 +0200, Thomas De Schampheleire wrote:

> > Thomas De Schampheleire (12):
> >   toolchain-external: reduce nesting in copy_toolchain_sysroot
> >   toolchain-external: fix broken handling of 'usr/lib/locale'
> >   toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
> >   toolchain-external: handle ld.so fixups centrally
> >   toolchain helpers: introduce function relpath_prefix
> >   toolchain-external: cover multilib toolchains with lib/<variant>
> >     layout
> >   toolchain helpers: introduce simplify_symlink
> >   toolchain-external: simplify previously-broken symbolic links
> >   toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR
> >   toolchain: copy_toolchain_lib_root: clarify logic
> >   toolchain: copy_toolchain_lib_root: clarify input parameter
> >   toolchain: copy_toolchain_lib_root: copy symlinks instead of
> >     recreating them  
> 
> I've now applied the remainder of the series, patches 3 to 12. I still
> find this quite complicated overall, but I couldn't find any other
> solution and nobody else did, and the problem scope is complicated
> anyway.
> 
> Let's see the feedback we get from users :)

Unfortunately, this breaks the build with at least one toolchain: the
CodeSourcery MIPS toolchain. Try the following defconfig:

BR2_mips64el=y
BR2_mips_64r2=y
BR2_MIPS_NABI64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_ALLJOYN_TCL=y
# BR2_TARGET_ROOTFS_TAR is not set

At commit a4c4cecd87851bdb3cbd4803a94df7602b102c42 (right before your
patch series), it builds fine.

At commit 38b51739da7fa7b950bbc46c059fbbab465ba4cb (right after your
patch series), it no longer builds, with the following error:

/home/thomas/projets/buildroot/output/host/usr/mips64el-buildroot-linux-gnu/sysroot/soft-float/el/lib64/ld.so.1: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status

So it smells like the copying of libraries to staging no longer works
as it used to work for this toolchain.

This causes some build failures in the autobuilders:

  http://autobuild.buildroot.net/results/8bf/8bffe54032aad9cc710a22411ef3bff4a2c93e55/build-end.log

Could you have a look ?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root
  2017-04-06 17:09     ` Thomas Petazzoni
@ 2017-04-06 17:51       ` Thomas De Schampheleire
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas De Schampheleire @ 2017-04-06 17:51 UTC (permalink / raw)
  To: buildroot

On Apr 6, 2017 7:09 PM, "Thomas Petazzoni" <
thomas.petazzoni@free-electrons.com> wrote:

Hello,

On Wed, 5 Apr 2017 22:15:40 +0200, Thomas De Schampheleire wrote:

> > Thomas De Schampheleire (12):
> >   toolchain-external: reduce nesting in copy_toolchain_sysroot
> >   toolchain-external: fix broken handling of 'usr/lib/locale'
> >   toolchain-external: clarify rsync excludes in copy_toolchain_sysroot
> >   toolchain-external: handle ld.so fixups centrally
> >   toolchain helpers: introduce function relpath_prefix
> >   toolchain-external: cover multilib toolchains with lib/<variant>
> >     layout
> >   toolchain helpers: introduce simplify_symlink
> >   toolchain-external: simplify previously-broken symbolic links
> >   toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR
> >   toolchain: copy_toolchain_lib_root: clarify logic
> >   toolchain: copy_toolchain_lib_root: clarify input parameter
> >   toolchain: copy_toolchain_lib_root: copy symlinks instead of
> >     recreating them
>
> I've now applied the remainder of the series, patches 3 to 12. I still
> find this quite complicated overall, but I couldn't find any other
> solution and nobody else did, and the problem scope is complicated
> anyway.
>
> Let's see the feedback we get from users :)

Unfortunately, this breaks the build with at least one toolchain: the
CodeSourcery MIPS toolchain. Try the following defconfig:

BR2_mips64el=y
BR2_mips_64r2=y
BR2_MIPS_NABI64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_ALLJOYN_TCL=y
# BR2_TARGET_ROOTFS_TAR is not set

At commit a4c4cecd87851bdb3cbd4803a94df7602b102c42 (right before your
patch series), it builds fine.

At commit 38b51739da7fa7b950bbc46c059fbbab465ba4cb (right after your
patch series), it no longer builds, with the following error:

/home/thomas/projets/buildroot/output/host/usr/mips64el-buildroot-linux-gnu/
sysroot/soft-float/el/lib64/ld.so.1: error adding symbols: File in wrong
format
collect2: error: ld returned 1 exit status

So it smells like the copying of libraries to staging no longer works
as it used to work for this toolchain.

This causes some build failures in the autobuilders:

  http://autobuild.buildroot.net/results/8bf/8bffe54032aad9cc710a22411ef3bf
f4a2c93e55/build-end.log

Could you have a look ?


I noticed a problem today with the first patch in the series, related to
ld.so copying and have a fix ready, will test your use case to see if it's
the same.

Thanks,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170406/113cdfb5/attachment.html>

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-04-06 17:51 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 21:56 [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 01/12] toolchain-external: reduce nesting in copy_toolchain_sysroot Thomas De Schampheleire
2017-03-01 22:22   ` Thomas Petazzoni
2017-02-07 21:56 ` [Buildroot] [PATCHv3 02/12] toolchain-external: fix broken handling of 'usr/lib/locale' Thomas De Schampheleire
2017-03-01 22:34   ` Thomas Petazzoni
2017-02-07 21:56 ` [Buildroot] [PATCHv3 03/12] toolchain-external: clarify rsync excludes in copy_toolchain_sysroot Thomas De Schampheleire
2017-02-07 23:03   ` Romain Naour
2017-02-08  9:22     ` Thomas De Schampheleire
2017-02-08  9:45       ` Thomas Petazzoni
2017-02-07 21:56 ` [Buildroot] [PATCHv3 04/12] toolchain-external: handle ld.so fixups centrally Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 05/12] toolchain helpers: introduce function relpath_prefix Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 06/12] toolchain-external: cover multilib toolchains with lib/<variant> layout Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 07/12] toolchain helpers: introduce simplify_symlink Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 08/12] toolchain-external: simplify previously-broken symbolic links Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 09/12] toolchain: copy_toolchain_lib_root: remove unused variable LIBDIR Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 10/12] toolchain: copy_toolchain_lib_root: clarify logic Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 11/12] toolchain: copy_toolchain_lib_root: clarify input parameter Thomas De Schampheleire
2017-02-07 21:56 ` [Buildroot] [PATCHv3 12/12] toolchain: copy_toolchain_lib_root: copy symlinks instead of recreating them Thomas De Schampheleire
2017-04-05 19:54 ` [Buildroot] [PATCHv3 00/12] toolchain: improvements to copy_toolchain_sysroot and copy_toolchain_lib_root Thomas Petazzoni
2017-04-05 20:15   ` Thomas De Schampheleire
2017-04-06 17:09     ` Thomas Petazzoni
2017-04-06 17:51       ` Thomas De Schampheleire

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.