Skip to contentSkip to conversation

toolchain: expose BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS for all toolchain types

PATCH New Matt Weber 3 participants 3 messages Oct 27, 2019 – Oct 31, 2019

lore
Share & tools
lore

Matt Weber

author
#0 lore raw

PATCH v3 1/1 toolchain: expose BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS for all toolchain types

This patch extends the "copy extra GCC libraries to target" feature to also work for internal toolchains. The variable has been renamed to be BR2_TOOLCHAIN_EXTRA_LIBS and the configuration option moved under the generic toolchain package. For external toolchains, the step that does the copy is still in the copy_toolchain_lib_root() helper which copies from the sysroot to the target. For the internal toolchain, the host gcc-final package does a post install hook to copy the libraries from the toolchain build folders to both the sysroot and target(!static).

Examples where this can be useful is for adding debug libraries to the target like the GCC libsanitizer (libasan/liblsan/...).

---
Note: this generic extra library copy is proposed as an alternative to
http://patchwork.ozlabs.org/patch/1110787/

Changes
v2 -> v3
- Fixed external toolchain needing a suffix with wildcard. (Was missed because the interal toolchain wants just the library name).
[Arnout
- Updated help text on BR2_TOOLCHAIN_EXTRA_LIBS to give an example
[Peter
- Added !BR2_STATIC_LIBS dependency

v1 -> v2
[Thomas P
- Added Config.in.legacy logic for BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS

---
 Config.in.legacy                                   | 11 +++++++++++
 package/gcc/gcc-final/gcc-final.mk                 |  2 ++
 toolchain/Config.in                                | 14 ++++++++++++++
 .../toolchain-external/pkg-toolchain-external.mk   |  2 +-
 .../toolchain-external-custom/Config.in.options    |  8 --------
 5 files changed, 28 insertions(+), 9 deletions(-)
Config.in.legacy +11 -0
index d4f3d04062..b3086300e6 100644
@@ -146,6 +146,17 @@ endif
 
 comment "Legacy options removed in 2019.11"
 
+config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
+	string "toolchain-external extra libs option has been renamed"
+	help
+	  The option BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS has
+	  been renamed to BR2_TOOLCHAIN_EXTRA_LIBS.
+
+config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS_WRAP
+	bool
+	default y if BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS != ""
+	select BR2_LEGACY
+
 config BR2_PACKAGE_PYTHON_PYSNMP_APPS
 	bool "python-pysnmp-apps was removed"
 	select BR2_LEGACY
package/gcc/gcc-final/gcc-final.mk +2 -0
index 30fb87856c..24d034b720 100644
@@ -187,6 +187,8 @@ ifeq ($(BR2_GCC_ENABLE_OPENMP),y)
 HOST_GCC_FINAL_USR_LIBS += libgomp
 endif
 
+HOST_GCC_FINAL_USR_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_LIBS))
+
 ifneq ($(HOST_GCC_FINAL_USR_LIBS),)
 define HOST_GCC_FINAL_INSTALL_STATIC_LIBS
 	for i in $(HOST_GCC_FINAL_USR_LIBS) ; do \
toolchain/Config.in +14 -0
index c9aa95985f..a6442bbd97 100644
@@ -221,6 +221,20 @@ config BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_LIST
 
 	  Note: the full set of gconv libs are ~8MiB (on ARM).
 
+config BR2_TOOLCHAIN_EXTRA_LIBS
+	string "Extra toolchain libraries to be copied to target"
+	default BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS if BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS != "" # legacy
+	depends on !BR2_STATIC_LIBS
+	help
+	  If your toolchain provides extra libraries that need to be
+	  copied to the target filesystem, enter them here, separated
+	  by spaces. The library should not include a suffix or any
+	  type of pre/post wildcard.
+
+	  Examples where this can be useful is for adding debug libraries
+	  to the target like the GCC libsanitizer.
+	  e.g. "libasan liblsan libtsan libubsan"
+
 # This boolean is true if the toolchain provides a built-in full
 # featured gettext implementation (glibc), and false if only a stub
 # gettext implementation is provided (uclibc, musl)
toolchain/toolchain-external/pkg-toolchain-external.mk +1 -1
index 5147da0104..4bae2ff412 100644
@@ -156,7 +156,7 @@ ifeq ($(BR2_TOOLCHAIN_HAS_DLANG),y)
 TOOLCHAIN_EXTERNAL_LIBS += libgdruntime.so* libgphobos.so*
 endif
 
-TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
+TOOLCHAIN_EXTERNAL_LIBS += $(addsuffix .so*,$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_LIBS)))
 
 
 #
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +0 -8
index a36747f490..fd95f8201b 100644
@@ -438,12 +438,4 @@ config BR2_TOOLCHAIN_EXTERNAL_OPENMP
 	  support. If you don't know, leave the default value,
 	  Buildroot will tell you if it's correct or not.
 
-config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
-	string "Extra toolchain libraries to be copied to target"
-	help
-	  If your external toolchain provides extra libraries that
-	  need to be copied to the target filesystem, enter them
-	  here, separated by spaces. They will be copied to the
-	  target's /lib directory.
-
 endif
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/1 toolchain: expose BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS for all toolchain types

Quoted 9 lines · Matt Weber

This patch extends the "copy extra GCC libraries to target" feature to also work for internal toolchains. The variable has been renamed to be BR2_TOOLCHAIN_EXTRA_LIBS and the configuration option moved under the generic toolchain package. For external toolchains, the step that does the copy is still in the copy_toolchain_lib_root() helper which copies from the sysroot to the target. For the internal toolchain, the host gcc-final package does a post install hook to copy the libraries from the toolchain build folders to both the sysroot and target(!static).

Quoted 5 lines

Examples where this can be useful is for adding debug libraries to the target like the GCC libsanitizer (libasan/liblsan/...).

Applied to master, thanks.

[snip]

toolchain/Config.in config BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_LIST · line 234

Quoted 1 line
toolchain/Config.in +1 -0
+	  Examples where this can be useful is for adding debug libraries

This line is too long. As reported by check-package. Fortunately, I check for
that in a post-apply hook :-)

If you want to do the same, use this as your .git/hooks/post-commit:

#! /bin/sh

# check-package on added/changed files
git show HEAD | \
        lsdiff -s | \
        awk '{ if ($1 != "-") print substr($2, 3) }' | \
        xargs -r ./utils/check-package

(note that you need to install lsdiff, and it barfs on renamed or removed files)

Regards,
Arnout

Quoted 37 lines
toolchain/Config.in +3 -0
+	  to the target like the GCC libsanitizer.
+	  e.g. "libasan liblsan libtsan libubsan"
+
 # This boolean is true if the toolchain provides a built-in full
 # featured gettext implementation (glibc), and false if only a stub
 # gettext implementation is provided (uclibc, musl)
toolchain/toolchain-external/pkg-toolchain-external.mk +1 -1
index 5147da0104..4bae2ff412 100644
@@ -156,7 +156,7 @@ ifeq ($(BR2_TOOLCHAIN_HAS_DLANG),y)
 TOOLCHAIN_EXTERNAL_LIBS += libgdruntime.so* libgphobos.so*
 endif
 
-TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
+TOOLCHAIN_EXTERNAL_LIBS += $(addsuffix .so*,$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_LIBS)))
 
 
 #
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +0 -8
index a36747f490..fd95f8201b 100644
@@ -438,12 +438,4 @@ config BR2_TOOLCHAIN_EXTERNAL_OPENMP
 	  support. If you don't know, leave the default value,
 	  Buildroot will tell you if it's correct or not.
 
-config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
-	string "Extra toolchain libraries to be copied to target"
-	help
-	  If your external toolchain provides extra libraries that
-	  need to be copied to the target filesystem, enter them
-	  here, separated by spaces. They will be copied to the
-	  target's /lib directory.
-
 endif
#2 lore raw

PATCH v3 1/1 toolchain: expose BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS for all toolchain types

Quoted 30 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Quoted 9 lines · Matt Weber

This patch extends the "copy extra GCC libraries to target" feature to also work for internal toolchains. The variable has been renamed to be BR2_TOOLCHAIN_EXTRA_LIBS and the configuration option moved under the generic toolchain package. For external toolchains, the step that does the copy is still in the copy_toolchain_lib_root() helper which copies from the sysroot to the target. For the internal toolchain, the host gcc-final package does a post install hook to copy the libraries from the toolchain build folders to both the sysroot and target(!static).

Quoted 5 lines

Examples where this can be useful is for adding debug libraries to the target like the GCC libsanitizer (libasan/liblsan/...).

Applied to master, thanks.

[snip]

toolchain/Config.in config BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_LIST · line 234

Quoted 1 line
toolchain/Config.in +1 -0
+	  Examples where this can be useful is for adding debug libraries

This line is too long. As reported by check-package. Fortunately, I check for
that in a post-apply hook :-)

If you want to do the same, use this as your .git/hooks/post-commit:

#! /bin/sh

Quoted 8 lines
# check-package on added/changed files
git show HEAD | \
        lsdiff -s | \
        awk '{ if ($1 != "-") print substr($2, 3) }' | \
        xargs -r ./utils/check-package

(note that you need to install lsdiff, and it barfs on renamed or removed files)

Really? We explicitly filter out removed files (the "-" logic). For renamed files we could probably use git show --no-renamed to have them listed as a removal + addition.

Signature · 1 line
Bye, Peter Korsgaard