From a110d195c0e3ac16ffc63538c1ff617551d0c8fa Mon Sep 17 00:00:00 2001 From: Frank Hunleth Date: Tue, 21 Jun 2016 13:08:17 -0400 Subject: [PATCH] toolchain: allow crosstool-ng musl toolchains Currently, if using a crosstool-ng-generated external musl toolchain, Buildroot exits with "Incorrect selection of the C library". The musl.codu.org cross-compilers put their libraries in /lib while crosstool-ng uses /usr/lib. This change checks that location for libc.so and updates the ld-musl-$ARCH.so.1 symlink. Signed-off-by: Frank Hunleth --- toolchain/toolchain-external/pkg-toolchain-external.mk | 6 +++++- toolchain/toolchain/toolchain.mk | 14 ++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk index 856be65..cc30eed 100644 --- a/toolchain/toolchain-external/pkg-toolchain-external.mk +++ b/toolchain/toolchain-external/pkg-toolchain-external.mk @@ -491,7 +491,11 @@ else MUSL_ARCH = $(ARCH) endif define TOOLCHAIN_EXTERNAL_MUSL_LD_LINK - ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-$(MUSL_ARCH).so.1 + if [ -e $(STAGING_DIR)/usr/lib/libc.so ]; then \ + ln -sf ../usr/lib/libc.so $(TARGET_DIR)/lib/ld-musl-$(MUSL_ARCH).so.1 ; \ + else \ + ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-$(MUSL_ARCH).so.1 ; \ + fi endef endif diff --git a/toolchain/toolchain/toolchain.mk b/toolchain/toolchain/toolchain.mk index e15ceeb..b72ce6c 100644 --- a/toolchain/toolchain/toolchain.mk +++ b/toolchain/toolchain/toolchain.mk @@ -26,12 +26,14 @@ TOOLCHAIN_ADD_TOOLCHAIN_DEPENDENCY = NO # [1] http://www.openwall.com/lists/musl/2015/10/08/2 ifeq ($(BR2_TOOLCHAIN_USES_MUSL)$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12),yy) define TOOLCHAIN_MUSL_KERNEL_HEADERS_COMPATIBILITY_HACK - $(SED) 's/^#if defined(__GLIBC__)$$/#if 1/' \ - $(STAGING_DIR)/usr/include/linux/libc-compat.h - $(SED) '1s/^/#define __USE_MISC\n/' \ - $(STAGING_DIR)/usr/include/linux/libc-compat.h - $(SED) '1s/^/#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0\n/' \ - $(STAGING_DIR)/usr/include/linux/libc-compat.h + if [ -e $(STAGING_DIR)/usr/include/linux/libc-compat.h ]; then \ + $(SED) 's/^#if defined(__GLIBC__)$$/#if 1/' \ + $(STAGING_DIR)/usr/include/linux/libc-compat.h; \ + $(SED) '1s/^/#define __USE_MISC\n/' \ + $(STAGING_DIR)/usr/include/linux/libc-compat.h; \ + $(SED) '1s/^/#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0\n/' \ + $(STAGING_DIR)/usr/include/linux/libc-compat.h; \ + fi endef TOOLCHAIN_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_MUSL_KERNEL_HEADERS_COMPATIBILITY_HACK TOOLCHAIN_INSTALL_STAGING = YES -- 2.7.4