[Buildroot] [PATCH v3] toolchain-external: Fix external toolchains when BR2_ROOTFS_MERGED_USR
Charlie Jenkins
charlie at rivosinc.com
Wed Apr 16 00:10:32 UTC 2025
External toolchains like crosstool-ng place libraries at /usr/lib and /usr/lib64.
When BR2_ROOTFS_MERGED_USR is enabled, these libraries were not being
copied into the target. This caused these toolchains to be unusable with
this option.
When BR2_ROOTFS_MERGED_USR is selected, copy the /usr/lib and /usr/lib64
directories to the target respectively.
Signed-off-by: Charlie Jenkins <charlie at rivosinc.com>
---
I originally reported this issue here [1].
[1] https://lore.kernel.org/buildroot/Z86AGdrKHaUqgLVt@ghost/T/#t
---
Changes in v3:
- Simplify patch further to fix the core of the problem
- Link to v2: https://lore.kernel.org/r/20250411-fix_external_toolchains-v2-1-fdf1ca2ca849@rivosinc.com
Changes in v2:
- Reduce rsync to root cause. The previous solution was very
heavy-handed as pointed out by Arnout. This seems to be the proper way
of doing this.
- Link to v1: https://lore.kernel.org/r/20250310-fix_external_toolchains-v1-1-446f48af7cf7@rivosinc.com
---
toolchain/helpers.mk | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index f3fdaaec07c5a01688da685c4d0fd4e2cb357b95..7acb535cc4a6730c07487aec7e90cefd6a6202e9 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -55,6 +55,9 @@ copy_toolchain_lib_root = \
# corresponding architecture variants), and we don't want to import
# them.
#
+# Furthermore, when BR2_ROOTFS_MERGED_USR is enabled, the 'lib*' directories
+# need to be copied over to usr/'lib*'.
+#
# 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
@@ -113,7 +116,7 @@ copy_toolchain_sysroot = \
if [ ! -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
continue ; \
fi ; \
- if [ "$$i" = "usr" ]; then \
+ if [ "$$i" = "usr" ] && [ "$(BR2_ROOTFS_MERGED_USR)" != "y" ]; then \
rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
--include '/libexec*/' --exclude '/lib*/' \
$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
---
base-commit: 4809690d42f9b395ccb76ee7583c199fdd8d42c5
change-id: 20250310-fix_external_toolchains-d1b8c4da0be8
--
- Charlie
More information about the buildroot
mailing list