Skip to contentSkip to conversation

toolchain-external: Commonize /lib/<tuple> symlinks

PATCH Superseded Matthew Fornero 3 participants 6 messages Mar 30, 2016 – Jul 5, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 toolchain-external: Commonize /lib/<tuple> symlinks

Commonize the creation of symlinks from {/usr}/lib to {/usr}/lib/<tuple>.

These were originally defined on a per-toolchain basis for the Linaro toolchains, but there is currently no support for creating symlinks for custom toolchains that may have been based on Linaro (or older versions of the Linaro toolchain).

Add common code for all supported Linaro toolchains and add a new config option, BR2_TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK to enable custom toolchains to enable the symbolic link creation.

---
v3: Invert Kconfig and cleanup as suggested by Arnout and Baruch Siach
v2: Cleanup as suggested by Arnout Vandecappelle

---
 toolchain/toolchain-external/Config.in             |   17 +++++++++++++
 toolchain/toolchain-external/toolchain-external.mk |   26 ++++++--------------
 2 files changed, 25 insertions(+), 18 deletions(-)
toolchain/toolchain-external/Config.in +17 -0
index ff759a0..b69f86d 100644
@@ -23,6 +23,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_1
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
@@ -45,6 +46,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
@@ -67,6 +69,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_1
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
@@ -89,6 +92,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
@@ -574,6 +578,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_7
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
 	help
@@ -589,6 +594,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
 	help
@@ -745,6 +751,9 @@ config BR2_TOOLCHAIN_EXTERNAL_PREFIX
 	default BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX \
 					 if BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
+config BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
+	bool
+
 config BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	bool
 	select BR2_TOOLCHAIN_USES_GLIBC
@@ -1055,6 +1064,14 @@ config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
 	  here, separated by spaces. They will be copied to the
 	  target's /lib directory.
 
+config BR2_TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+	bool "Symlink /lib/<tuple>"
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
+	help
+	  Select this option if your external toolchain needs a symlink
+	  from {/usr}/lib to {/usr}/lib/<tuple>. This may be required if
+	  your toolchain is based on one from Linaro.
+
 endif # BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
 config BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
toolchain/toolchain-external/toolchain-external.mk +8 -18
index ff4ae5e..0d28f3f 100644
@@ -244,23 +244,16 @@ ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
 TOOLCHAIN_EXTERNAL_DEPENDENCIES += netbsd-queue
 endif
 
-# The Linaro ARMhf toolchain expects the libraries in
-# {/usr,}/lib/arm-linux-gnueabihf, but Buildroot copies them to
+# Some toolchains, such as Linaro, expect the libraries in
+# {/usr,}/lib/<tuple>, but Buildroot copies them to
 # {/usr,}/lib, so we need to create a symbolic link.
-define TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/arm-linux-gnueabihf
-	ln -snf . $(TARGET_DIR)/usr/lib/arm-linux-gnueabihf
-endef
-
-define TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/armeb-linux-gnueabihf
-	ln -snf . $(TARGET_DIR)/usr/lib/armeb-linux-gnueabihf
-endef
-
-define TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/aarch64-linux-gnu
-	ln -snf . $(TARGET_DIR)/usr/lib/aarch64-linux-gnu
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK),y)
+define TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+	ln -snf . $(TARGET_DIR)/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
+	ln -snf . $(TARGET_DIR)/usr/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
 endef
+TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+endif
 
 # Special fixup for Codescape MIPS toolchains, that have bin-<abi> and
 # sbin-<abi> directories. We create symlinks bin -> bin-<abi> and sbin
@@ -318,7 +311,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.2-2015.11-2/arm-linux-gnueabihf
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf.tar.xz
@@ -328,7 +320,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.2-2015.11-2/armeb-linux-gnueabihf
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.2-2015.11-2-x86_64_armeb-linux-gnueabihf.tar.xz
@@ -375,7 +366,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.2-2015.11-2/aarch64-linux-gnu
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.2-2015.11-2-x86_64_aarch64-linux-gnu.tar.xz
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v4 1/1 toolchain-external: Commonize /lib/<tuple> symlinks

Commonize the creation of symlinks from {/usr}/lib to {/usr}/lib/<tuple>.

These were originally defined on a per-toolchain basis for the Linaro toolchains, but there is currently no support for creating symlinks for custom toolchains that may have been based on Linaro (or older versions of the Linaro toolchain).

Add common code for all supported Linaro toolchains and add a new config option, BR2_TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK to enable custom toolchains to enable the symbolic link creation.

---
v4: Rebase to current master
v3: Invert Kconfig and cleanup as suggested by Arnout and Baruch Siach
v2: Cleanup as suggested by Arnout Vandecappelle

---
 toolchain/toolchain-external/Config.in             |   17 +++++++++++++
 toolchain/toolchain-external/toolchain-external.mk |   26 ++++++--------------
 2 files changed, 25 insertions(+), 18 deletions(-)
toolchain/toolchain-external/Config.in +17 -0
index b7f9241..fa698b1 100644
@@ -23,6 +23,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_1
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
@@ -45,6 +46,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
@@ -67,6 +69,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_1
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
@@ -89,6 +92,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
@@ -523,6 +527,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_7
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
 	help
@@ -538,6 +543,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
 	help
@@ -692,6 +698,9 @@ config BR2_TOOLCHAIN_EXTERNAL_PREFIX
 	default BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX \
 					 if BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
+config BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
+	bool
+
 config BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	bool
 	select BR2_TOOLCHAIN_USES_GLIBC
@@ -1005,6 +1014,14 @@ config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
 	  need to be copied to the target filesystem, enter them
 	  here, separated by spaces.
 
+config BR2_TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+	bool "Symlink /lib/<tuple>"
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
+	help
+	  Select this option if your external toolchain needs a symlink
+	  from {/usr}/lib to {/usr}/lib/<tuple>. This may be required if
+	  your toolchain is based on one from Linaro.
+
 endif # BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
 config BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
toolchain/toolchain-external/toolchain-external.mk +8 -18
index 34217c0..6706fbf 100644
@@ -244,23 +244,16 @@ ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
 TOOLCHAIN_EXTERNAL_DEPENDENCIES += netbsd-queue
 endif
 
-# The Linaro ARMhf toolchain expects the libraries in
-# {/usr,}/lib/arm-linux-gnueabihf, but Buildroot copies them to
+# Some toolchains, such as Linaro, expect the libraries in
+# {/usr,}/lib/<tuple>, but Buildroot copies them to
 # {/usr,}/lib, so we need to create a symbolic link.
-define TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/arm-linux-gnueabihf
-	ln -snf . $(TARGET_DIR)/usr/lib/arm-linux-gnueabihf
-endef
-
-define TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/armeb-linux-gnueabihf
-	ln -snf . $(TARGET_DIR)/usr/lib/armeb-linux-gnueabihf
-endef
-
-define TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/aarch64-linux-gnu
-	ln -snf . $(TARGET_DIR)/usr/lib/aarch64-linux-gnu
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK),y)
+define TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+	ln -snf . $(TARGET_DIR)/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
+	ln -snf . $(TARGET_DIR)/usr/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
 endef
+TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+endif
 
 # Special fixup for Codescape MIPS toolchains, that have bin-<abi> and
 # sbin-<abi> directories. We create symlinks bin -> bin-<abi> and sbin
@@ -318,7 +311,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
@@ -328,7 +320,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/armeb-linux-gnueabihf
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_armeb-linux-gnueabihf.tar.xz
@@ -369,7 +360,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/aarch64-linux-gnu
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v4 1/1 toolchain-external: Commonize /lib/<tuple> symlinks

Hi Matthew,

Le 20/05/2016 ? 19:52, Matthew Fornero a ?crit :

Quoted 11 lines

Commonize the creation of symlinks from {/usr}/lib to {/usr}/lib/<tuple>.

These were originally defined on a per-toolchain basis for the Linaro toolchains, but there is currently no support for creating symlinks for custom toolchains that may have been based on Linaro (or older versions of the Linaro toolchain).

Add common code for all supported Linaro toolchains and add a new config option, BR2_TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK to enable custom toolchains to enable the symbolic link creation.

Since we don't support older Linaro toolchains which require these symlinks other than the latest supporting x86 host (i.e Linaro 2014.09), I'm agree to add a way to easily import them without having to change the toolchain-external code. On another side such Linaro specific symlinks are no longer needed and the option is no longer be necessary.

Quoted 24 lines

---
v4: Rebase to current master
v3: Invert Kconfig and cleanup as suggested by Arnout and Baruch Siach
v2: Cleanup as suggested by Arnout Vandecappelle

---
 toolchain/toolchain-external/Config.in             |   17 +++++++++++++
 toolchain/toolchain-external/toolchain-external.mk |   26 ++++++--------------
 2 files changed, 25 insertions(+), 18 deletions(-)
toolchain/toolchain-external/Config.in +1 -0
index b7f9241..fa698b1 100644
@@ -23,6 +23,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_1
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9

toolchain/toolchain-external/Config.in config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM · line 49

Quoted 4 lines
toolchain/toolchain-external/Config.in +1 -0
@@ -45,6 +46,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK

Not required for newer Linaro toolchain.

Quoted 12 lines
toolchain/toolchain-external/Config.in +1 -0
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
@@ -67,6 +69,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_1
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9

toolchain/toolchain-external/Config.in config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB · line 95

Quoted 4 lines
toolchain/toolchain-external/Config.in +1 -0
@@ -89,6 +92,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK

Not required for newer Linaro toolchain.

Quoted 12 lines
toolchain/toolchain-external/Config.in +1 -0
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
@@ -523,6 +527,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_7
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
 	help

toolchain/toolchain-external/Config.in config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64 · line 546

Quoted 4 lines
toolchain/toolchain-external/Config.in +1 -0
@@ -538,6 +543,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK

Not required for newer Linaro toolchain.

With that fixed:

Best regards,
Romain

Quoted 89 lines
toolchain/toolchain-external/Config.in +11 -0
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
 	help
@@ -692,6 +698,9 @@ config BR2_TOOLCHAIN_EXTERNAL_PREFIX
 	default BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX \
 					 if BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
+config BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
+	bool
+
 config BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	bool
 	select BR2_TOOLCHAIN_USES_GLIBC
@@ -1005,6 +1014,14 @@ config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
 	  need to be copied to the target filesystem, enter them
 	  here, separated by spaces.
 
+config BR2_TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+	bool "Symlink /lib/<tuple>"
+	select BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK
+	help
+	  Select this option if your external toolchain needs a symlink
+	  from {/usr}/lib to {/usr}/lib/<tuple>. This may be required if
+	  your toolchain is based on one from Linaro.
+
 endif # BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
 config BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
toolchain/toolchain-external/toolchain-external.mk +8 -18
index 34217c0..6706fbf 100644
@@ -244,23 +244,16 @@ ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
 TOOLCHAIN_EXTERNAL_DEPENDENCIES += netbsd-queue
 endif
 
-# The Linaro ARMhf toolchain expects the libraries in
-# {/usr,}/lib/arm-linux-gnueabihf, but Buildroot copies them to
+# Some toolchains, such as Linaro, expect the libraries in
+# {/usr,}/lib/<tuple>, but Buildroot copies them to
 # {/usr,}/lib, so we need to create a symbolic link.
-define TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/arm-linux-gnueabihf
-	ln -snf . $(TARGET_DIR)/usr/lib/arm-linux-gnueabihf
-endef
-
-define TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/armeb-linux-gnueabihf
-	ln -snf . $(TARGET_DIR)/usr/lib/armeb-linux-gnueabihf
-endef
-
-define TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/aarch64-linux-gnu
-	ln -snf . $(TARGET_DIR)/usr/lib/aarch64-linux-gnu
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK),y)
+define TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+	ln -snf . $(TARGET_DIR)/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
+	ln -snf . $(TARGET_DIR)/usr/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
 endef
+TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+endif
 
 # Special fixup for Codescape MIPS toolchains, that have bin-<abi> and
 # sbin-<abi> directories. We create symlinks bin -> bin-<abi> and sbin
@@ -318,7 +311,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
@@ -328,7 +320,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/armeb-linux-gnueabihf
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_armeb-linux-gnueabihf.tar.xz
@@ -369,7 +360,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/aarch64-linux-gnu
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz
#3 lore raw

PATCH v4 1/1 toolchain-external: Commonize /lib/<tuple> symlinks

Hi Matthew,

Le 04/07/2016 ? 15:35, Romain Naour a ?crit :

Quoted 15 lines

Hi Matthew,

Le 20/05/2016 ? 19:52, Matthew Fornero a ?crit :

Quoted 11 lines

Commonize the creation of symlinks from {/usr}/lib to {/usr}/lib/<tuple>.

These were originally defined on a per-toolchain basis for the Linaro toolchains, but there is currently no support for creating symlinks for custom toolchains that may have been based on Linaro (or older versions of the Linaro toolchain).

Add common code for all supported Linaro toolchains and add a new config option, BR2_TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK to enable custom toolchains to enable the symbolic link creation.

Quoted 5 lines

Since we don't support older Linaro toolchains which require these symlinks other than the latest supporting x86 host (i.e Linaro 2014.09), I'm agree to add a way to easily import them without having to change the toolchain-external code. On another side such Linaro specific symlinks are no longer needed and the option is no longer be necessary.

After some discussion with other developers, I suggest you to register the TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS from BR2_EXTERNAL instead of adding a new configuration option to Buildroot. That way you can customize easily what should be done for your specific toolchain.

I'm doing this for my CodeSourcery x86 standard toolchain which require another symlink in staging directory.

Quoted 8 lines
Quoted 8 lines

---
v4: Rebase to current master
v3: Invert Kconfig and cleanup as suggested by Arnout and Baruch Siach
v2: Cleanup as suggested by Arnout Vandecappelle
---

[snip]

Quoted 18 lines
Quoted 18 lines
toolchain/toolchain-external/toolchain-external.mk +2 -14
-# The Linaro ARMhf toolchain expects the libraries in
-# {/usr,}/lib/arm-linux-gnueabihf, but Buildroot copies them to
+# Some toolchains, such as Linaro, expect the libraries in
+# {/usr,}/lib/<tuple>, but Buildroot copies them to
 # {/usr,}/lib, so we need to create a symbolic link.
-define TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/arm-linux-gnueabihf
-	ln -snf . $(TARGET_DIR)/usr/lib/arm-linux-gnueabihf
-endef
-
-define TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/armeb-linux-gnueabihf
-	ln -snf . $(TARGET_DIR)/usr/lib/armeb-linux-gnueabihf
-endef
-
-define TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
-	ln -snf . $(TARGET_DIR)/lib/aarch64-linux-gnu
Quoted 8 lines

toolchain/toolchain-external/toolchain-external.mk ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y) · line 256

Quoted 8 lines
toolchain/toolchain-external/toolchain-external.mk +6 -1
-	ln -snf . $(TARGET_DIR)/usr/lib/aarch64-linux-gnu
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_NEEDS_PREFIX_SYMLINK),y)
+define TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+	ln -snf . $(TARGET_DIR)/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
+	ln -snf . $(TARGET_DIR)/usr/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
 endef
+TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_PREFIX_SYMLINK
+endif

I would like to keep this part for our Linaro 14.09 support. I'll send a patch with only this part.

In the same time, I'll mark your patch as rejected in the patchwork.

Thanks!

Best regards,
Romain

Quoted 29 lines
Quoted 28 lines

# Special fixup for Codescape MIPS toolchains, that have bin-<abi> and # sbin-<abi> directories. We create symlinks bin -> bin-<abi> and sbin

toolchain/toolchain-external/toolchain-external.mk +0 -3
@@ -318,7 +311,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
@@ -328,7 +320,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/armeb-linux-gnueabihf
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_armeb-linux-gnueabihf.tar.xz
@@ -369,7 +360,6 @@ ifeq ($(HOSTARCH),x86)
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
 TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_src.tar.bz2
-TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
 else
 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/aarch64-linux-gnu
 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz
#4 lore raw

PATCH v4 1/1 toolchain-external: Commonize /lib/<tuple> symlinks

Quoted 8 lines

-----Original Message-----
From: Romain Naour [mailto:romain.naour at gmail.com]
Sent: Monday, July 04, 2016 7:18 AM
To: Matt Fornero <[email protected]>; buildroot at busybox.net
Subject: Re: [Buildroot] [PATCH v4] toolchain-external: Commonize /lib/<tuple> symlinks

[snip]

Quoted 9 lines

After some discussion with other developers, I suggest you to register the TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS from BR2_EXTERNAL instead of adding a new configuration option to Buildroot. That way you can customize easily what should be done for your specific toolchain.

I'm doing this for my CodeSourcery x86 standard toolchain which require another symlink in staging directory.

Hi Romain,

If I understand this correctly, I would simply define a new package in the BR2_EXTERNAL directory that was responsible for creating the symlinks as a _POST_INSTALL_STAGING_HOOKS action, and then enable this package for configurations that used the "custom" Linaro toolchains?

-Matt

#5 lore raw

PATCH v4 1/1 toolchain-external: Commonize /lib/<tuple> symlinks

Hi Matt,

Le 05/07/2016 ? 17:16, Matt Fornero a ?crit :

Quoted 16 lines
Quoted 8 lines

-----Original Message-----
From: Romain Naour [mailto:romain.naour at gmail.com]
Sent: Monday, July 04, 2016 7:18 AM
To: Matt Fornero <[email protected]>; buildroot at busybox.net
Subject: Re: [Buildroot] [PATCH v4] toolchain-external: Commonize /lib/<tuple> symlinks

[snip]

Quoted 6 lines

After some discussion with other developers, I suggest you to register the TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS from BR2_EXTERNAL instead of adding a new configuration option to Buildroot. That way you can customize easily what should be done for your specific toolchain.

Quoted 7 lines
Quoted 3 lines

I'm doing this for my CodeSourcery x86 standard toolchain which require another symlink in staging directory.

Hi Romain,

If I understand this correctly, I would simply define a new package in the BR2_EXTERNAL directory that was responsible for creating the symlinks as a _POST_INSTALL_STAGING_HOOKS action, and then enable this package for configurations that used the "custom" Linaro toolchains?

Yes, but the hook should be TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS in order to be done during toolchain install.

Best regards,
Romain

Quoted 3 lines

-Matt