toolchain-external-custom: Fix support lib dir
PATCH 1/1 toolchain-external-custom: Fix support lib dir
There is currently a hardcoded way to get a separate lib directory by looking for libstdc++.a. This is a flawed approach because it assumes that the toolchain has libstdc++.a, and it assumes that this library is not in the sysroot. When using crosstool-ng, neither of these conditions are guaranteed to be satisfied. The libc directories for crosstool-ng are placed in /lib64, but libraries like libatomic, libgcc_s, and libstdc++ are placed in /lib.
Remove the condition expecting the libraries to not be in the sysroot, and look for libgcc_s instead of libstdc++.a to support toolchains without c++ support.
---
Related patch to fix crosstool-ng support [1]. Both this patch and the linked patch are *required* to have crosstool-ng work with buildroot (at least for riscv).
[1] https://lore.kernel.org/all/[email protected]/
--- toolchain/toolchain-external/pkg-toolchain-external.mk | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
toolchain/toolchain-external/pkg-toolchain-external.mk +6 -4
@@ -451,10 +451,12 @@ define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \ ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \ SUPPORT_LIB_DIR="" ; \ - if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \ - LIBSTDCPP_A_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \ - if [ -e "$${LIBSTDCPP_A_LOCATION}" ]; then \ - SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \ + if test `find $${ARCH_LIB_DIR} -name 'libgcc_s.so' | wc -l` -eq 0 ; then \ + LIBGCC_SO_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libgcc_s.so) ; \ + echo "LIBGCC_SO_LOCATION_RESULT: $${LIBGCC_SO_LOCATION}" ; \ + if [ -e "$${LIBGCC_SO_LOCATION}" ]; then \ + SUPPORT_LIB_DIR=`readlink -f $${LIBGCC_SO_LOCATION} | sed -r -e 's:libgcc_s.so::'` ; \ + echo "SUPPORT_LIB_DIR: $${SUPPORT_LIB_DIR}" ; \ fi ; \ fi ; \ if [ "$${SYSROOT_DIR}" == "$${ARCH_SYSROOT_DIR}" ] ; then \
---
base-commit: bd9a6c2b36d92dd38fb3b537ac9645344bec76ac
change-id: 20250527-fix_support_lib-ba555aa44f86
Signature · 6 lines
- Charlie _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot