Skip to contentSkip to conversation

Support for musl based external toolchains

PATCH New Thomas Petazzoni 2 participants 9 messages Oct 5, 2013 – Oct 6, 2013

lore
Share & tools
lore
#0 lore raw

cover Support for musl based external toolchains

Hello,

The musl C library is an alternative C library available from
http://www.musl-libc.org, it is gaining popularity amongst the people interested in small root filesystem for embedded platforms.

The following set of commits add support for musl based external toolchains. As noted in PATCH 3, the pre-build musl toolchains available at musl.codu.org cannot be used for the moment, since they lack sysroot support, but I have already contacted the author, who has added sysroot support, that I've succesfully tested. The next release of the pre-built toolchains will therefore have sysroot support, and I'll be able to add them in the external toolchain profiles.

The last patch adds some minor fixes to Busybox to make it build properly, they have been submitted to upstream Busybox already. Some other packages will need a few minor fixes, of course.

In the future, I'm planning to add musl support to the internal toolchain backend as well, but that requires patches on binutils and gcc, which is a little bit annoying, even if the patches are quite small.

Best regards,

Thomas

Thomas Petazzoni (5):
toolchain-external: conditionalize the installation of libraries
toolchain-external: modify the wildcard logic for shared libraries
copying
toolchain-external: add support for musl C library
toolchain-external: improve help text of some options
busybox: add patches to fix build with the musl C library

 ...01-libbb-use-poll.h-instead-of-sys-poll.h.patch | 32 +++++++++++++++++++
 ...onfig-include-linux-if_slip.h-instead-of-.patch | 33 ++++++++++++++++++++
 ...libiproute-use-linux-if_packet.h-instead-.patch | 36 ++++++++++++++++++++++
 toolchain/Config.in                                |  9 ++++++
 toolchain/helpers.mk                               | 13 +++++++-
 toolchain/toolchain-external/Config.in             | 27 +++++++++++++---
 toolchain/toolchain-external/ext-tool.mk           | 34 +++++++++++++-------
 7 files changed, 168 insertions(+), 16 deletions(-)
 create mode 100644 package/busybox/1.21.1/0001-libbb-use-poll.h-instead-of-sys-poll.h.patch
 create mode 100644 package/busybox/1.21.1/0002-network-ifconfig-include-linux-if_slip.h-instead-of-.patch
 create mode 100644 package/busybox/1.21.1/0003-networking-libiproute-use-linux-if_packet.h-instead-.patch
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/5 toolchain-external: conditionalize the installation of libraries

The external toolchain code makes the assumption that all C libraries have a ld*.so, libc.so, libcrypt.so, libdl.so, libgcc_s.so, libm.so, libnsl.so, libresolv.so, libutil.so, and when thread support is enabled, libpthread.so, etc.

However, this is not the case with the musl C library, which integrates all the functionalities in a single libc.so file. In preparation of the support of the musl library, we make the current value of LIB_EXTERNAL_LIBS conditional to glibc or uClibc.

The addition of additional libraries through BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS is kept outside the condition, at the end.

---
 toolchain/toolchain-external/ext-tool.mk | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
toolchain/toolchain-external/ext-tool.mk +11 -8
index db2a99e..93f1c0f 100644
@@ -49,8 +49,16 @@
 #  $(HOST_DIR)/usr/bin like for the internal toolchains, and the rest
 #  of Buildroot is handled identical for the 2 toolchain types.
 
-LIB_EXTERNAL_LIBS=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
-LIB_EXTERNAL_LIBS+=$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC)$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC),y)
+LIB_EXTERNAL_LIBS+=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+LIB_EXTERNAL_LIBS+=libpthread.so
+ifneq ($(BR2_PACKAGE_GDB_SERVER)$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),)
+LIB_EXTERNAL_LIBS+=libthread_db.so
+endif # gdbserver
+endif # ! no threads
+endif
+
 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
 LIB_EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
 endif
@@ -59,12 +67,7 @@ ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
 USR_LIB_EXTERNAL_LIBS+=libstdc++.so
 endif
 
-ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
-LIB_EXTERNAL_LIBS+=libpthread.so
-ifneq ($(BR2_PACKAGE_GDB_SERVER)$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),)
-LIB_EXTERNAL_LIBS+=libthread_db.so
-endif # gdbserver
-endif # ! no threads
+LIB_EXTERNAL_LIBS+=$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
 
 # Details about sysroot directory selection.
 #
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 2/5 toolchain-external: modify the wildcard logic for shared libraries copying

In reply to Thomas Petazzoni

Until now, the copy_toolchain_lib_root function took as argument the base name of a library (e.g: libm.so), and was assuming that the usual scheme libm.so.<x> being a symbolic link to the real library was used.

However, with musl based toolchains, the C library is named libc.so directly, with no symbolic link at all. Therefore, this commit changes the copy_toolchain_lib_root to move the responsibility of using a wildcard or not after the library name the caller's responsibility.

So, all the existing LIB_EXTERNAL_LIBS values are modified to have a .* at the end, so that the behavior is effectively unchanged.

---
 toolchain/helpers.mk                     |  2 +-
 toolchain/toolchain-external/ext-tool.mk | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
toolchain/helpers.mk +1 -1
index 0e270ee..d5443b5 100644
@@ -56,7 +56,7 @@ copy_toolchain_lib_root = \
 		$${ARCH_SYSROOT_DIR}/$${ARCH_LIB_DIR} \
 		$${ARCH_SYSROOT_DIR}/usr/$${ARCH_LIB_DIR} \
 		$${SUPPORT_LIB_DIR} ; do \
-		LIBSPATH=`find $${dir} -maxdepth 1 -name "$${LIB}.*" 2>/dev/null` ; \
+		LIBSPATH=`find $${dir} -maxdepth 1 -name "$${LIB}" 2>/dev/null` ; \
 		if test -n "$${LIBSPATH}" ; then \
 			break ; \
 		fi \
toolchain/toolchain-external/ext-tool.mk +5 -5
index 93f1c0f..8762a46 100644
@@ -50,21 +50,21 @@
 #  of Buildroot is handled identical for the 2 toolchain types.
 
 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC)$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC),y)
-LIB_EXTERNAL_LIBS+=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
+LIB_EXTERNAL_LIBS+=ld*.so.* libc.so.* libcrypt.so.* libdl.so.* libgcc_s.so.* libm.so.* libnsl.so.* libresolv.so.* librt.so.* libutil.so.*
 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
-LIB_EXTERNAL_LIBS+=libpthread.so
+LIB_EXTERNAL_LIBS+=libpthread.so.*
 ifneq ($(BR2_PACKAGE_GDB_SERVER)$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),)
-LIB_EXTERNAL_LIBS+=libthread_db.so
+LIB_EXTERNAL_LIBS+=libthread_db.so.*
 endif # gdbserver
 endif # ! no threads
 endif
 
 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
-LIB_EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
+LIB_EXTERNAL_LIBS+=libnss_files.so.* libnss_dns.so.*
 endif
 
 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
-USR_LIB_EXTERNAL_LIBS+=libstdc++.so
+USR_LIB_EXTERNAL_LIBS+=libstdc++.so.*
 endif
 
 LIB_EXTERNAL_LIBS+=$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
Signature · 1 line
1.8.1.2
#3 lore raw

PATCH 3/5 toolchain-external: add support for musl C library

In reply to Thomas Petazzoni

This commit adds support for external toolchains based on the musl C library, as available from http://www.musl-libc.org.

Note that the pre-built musl toolchains available from
http://musl.codu.org/ are not working for the moment, since they lack sysroot support. However, this problem has been reported to the maintainer, who has already added sysroot support in his scripts at
https://bitbucket.org/GregorR/musl-cross, and therefore the next version of the pre-built toolchains should work with Buildroot out-of-the-box. In the mean time, the musl-cross script must be used to build the toolchain.

---
 toolchain/Config.in                      |  9 +++++++++
 toolchain/helpers.mk                     | 11 +++++++++++
 toolchain/toolchain-external/Config.in   | 12 ++++++++++++
 toolchain/toolchain-external/ext-tool.mk | 11 ++++++++++-
 4 files changed, 42 insertions(+), 1 deletion(-)
toolchain/Config.in +9 -0
index 17be32a..61eb520 100644
@@ -24,6 +24,15 @@ config BR2_TOOLCHAIN_USES_GLIBC
 config BR2_TOOLCHAIN_USES_UCLIBC
 	bool
 
+config BR2_TOOLCHAIN_USES_MUSL
+	bool
+	select BR2_LARGEFILE
+	select BR2_INET_IPV6
+	select BR2_USE_WCHAR
+	select BR2_ENABLE_LOCALE
+	select BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_TOOLCHAIN_HAS_THREADS_DEBUG
+
 choice
 	prompt "Toolchain type"
 	help
toolchain/helpers.mk +11 -0
index d5443b5..e8d4168 100644
@@ -214,6 +214,17 @@ check_glibc = \
 	$(call check_glibc_rpc_feature,$${SYSROOT_DIR})
 
 #
+# Check that the selected C library is really musl
+#
+# $1: sysroot directory
+check_musl = \
+	SYSROOT_DIR="$(strip $1)"; \
+	if test ! -f $${SYSROOT_DIR}/lib/libc.so -o -e $${SYSROOT_DIR}/lib/libm.so ; then \
+		echo "Incorrect selection of the C library" ; \
+		exit -1; \
+	fi
+
+#
 # Check the conformity of Buildroot configuration with regard to the
 # uClibc configuration of the external toolchain, for a particular
 # feature.
toolchain/toolchain-external/Config.in +12 -0
index c53577e..89c799e 100644
@@ -860,6 +860,10 @@ config BR2_TOOLCHAIN_EXTERNAL_UCLIBC
 	bool
 	select BR2_TOOLCHAIN_USES_UCLIBC
 
+config BR2_TOOLCHAIN_EXTERNAL_MUSL
+	bool
+	select BR2_TOOLCHAIN_USES_MUSL
+
 if BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
 choice
@@ -882,6 +886,13 @@ config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC
 	  eglibc configured to exclude key features may cause build failures to
 	  some packages.
 
+config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL
+	bool "musl"
+	select BR2_TOOLCHAIN_EXTERNAL_MUSL
+	help
+	  Select this option if your external toolchain uses the
+	  'musl' C library, available from http://www.musl-libc.org/.
+
 endchoice
 
 if BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC
@@ -952,6 +963,7 @@ endif # BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC
 config BR2_TOOLCHAIN_EXTERNAL_INET_RPC
 	bool "Toolchain has RPC support?"
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	depends on !BR2_TOOLCHAIN_EXTERNAL_MUSL
 	default y if BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	help
 	  Select this option if your external toolchain supports
toolchain/toolchain-external/ext-tool.mk +10 -1
index 8762a46..f642017 100644
@@ -63,6 +63,10 @@ ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
 LIB_EXTERNAL_LIBS+=libnss_files.so.* libnss_dns.so.*
 endif
 
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL),y)
+LIB_EXTERNAL_LIBS += libc.so libgcc_s.so.*
+endif
+
 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
 USR_LIB_EXTERNAL_LIBS+=libstdc++.so.*
 endif
@@ -369,7 +373,7 @@ $(STAMP_DIR)/ext-toolchain-checked: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES)
 	@$(call MESSAGE,"Checking external toolchain settings")
 	$(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
 	$(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
-	SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(32|64)?/(.*/)?libc\.a::'` ; \
+	SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:(usr/)?lib(32|64)?/(.*/)?libc\.a::'` ; \
 	if test -z "$${SYSROOT_DIR}" ; then \
 		@echo "External toolchain doesn't support --sysroot. Cannot use." ; \
 		exit 1 ; \
@@ -384,6 +388,8 @@ $(STAMP_DIR)/ext-toolchain-checked: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES)
 	fi ; \
 	if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
 		$(call check_uclibc,$${SYSROOT_DIR}) ; \
+	elif test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
+		$(call check_musl,$${SYSROOT_DIR}) ; \
 	else \
 		$(call check_glibc,$${SYSROOT_DIR}) ; \
 	fi
@@ -464,6 +470,9 @@ $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked
 			$(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
 		done ; \
 	fi ; \
+	if test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
+		ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-arm.so.1 ; \
+	fi ; \
 	$(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \
 	$(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR}) ; \
 	if test "$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY)" = "y"; then \
Signature · 1 line
1.8.1.2
#4 lore raw

PATCH 3/5 toolchain-external: add support for musl C library

Hello,

toolchain/toolchain-external/ext-tool.mk $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked · line 474

Quoted 2 lines · Thomas Petazzoni
toolchain/toolchain-external/ext-tool.mk +2 -0
+	if test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
+		ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-arm.so.1 ; \

Crap. This should indeed be conditional on the architecture. I'll fix that in v2 with the other comments that the patches will receive.

Thomas

Signature · 3 lines
Thomas Petazzoni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH 3/5 toolchain-external: add support for musl C library

Quoted 9 lines · Thomas Petazzoni

Hello,

toolchain/toolchain-external/ext-tool.mk $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked · line 474

Quoted 2 lines · Thomas Petazzoni
toolchain/toolchain-external/ext-tool.mk +2 -0
+	if test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
+		ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-arm.so.1 ; \

Crap. This should indeed be conditional on the architecture. I'll fix that in v2 with the other comments that the patches will receive.

Ah I hadn't seen this yet... please disregard my previous mail...

#6 lore raw

PATCH 3/5 toolchain-external: add support for musl C library

In reply to Thomas Petazzoni
Quoted 133 lines · Thomas Petazzoni

This commit adds support for external toolchains based on the musl C library, as available from http://www.musl-libc.org.

Note that the pre-built musl toolchains available from
http://musl.codu.org/ are not working for the moment, since they lack sysroot support. However, this problem has been reported to the maintainer, who has already added sysroot support in his scripts at
https://bitbucket.org/GregorR/musl-cross, and therefore the next version of the pre-built toolchains should work with Buildroot out-of-the-box. In the mean time, the musl-cross script must be used to build the toolchain.

---

toolchain/Config.in                      |  9 +++++++++
toolchain/helpers.mk                     | 11 +++++++++++
toolchain/toolchain-external/Config.in   | 12 ++++++++++++
toolchain/toolchain-external/ext-tool.mk | 11 ++++++++++-
4 files changed, 42 insertions(+), 1 deletion(-)
toolchain/Config.in +0 -0
index 17be32a..61eb520 100644
@@ -24,6 +24,15 @@ config BR2_TOOLCHAIN_USES_GLIBC

config BR2_TOOLCHAIN_USES_UCLIBC
bool

toolchain/Config.in +9 -0
+config BR2_TOOLCHAIN_USES_MUSL
+	bool
+	select BR2_LARGEFILE
+	select BR2_INET_IPV6
+	select BR2_USE_WCHAR
+	select BR2_ENABLE_LOCALE
+	select BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_TOOLCHAIN_HAS_THREADS_DEBUG
+

choice
prompt "Toolchain type"
help

toolchain/helpers.mk +11 -0
index d5443b5..e8d4168 100644
@@ -214,6 +214,17 @@ check_glibc = \
 	$(call check_glibc_rpc_feature,$${SYSROOT_DIR})
 
 #
+# Check that the selected C library is really musl
+#
+# $1: sysroot directory
+check_musl = \
+	SYSROOT_DIR="$(strip $1)"; \
+	if test ! -f $${SYSROOT_DIR}/lib/libc.so -o -e $${SYSROOT_DIR}/lib/libm.so ; then \
+		echo "Incorrect selection of the C library" ; \
+		exit -1; \
+	fi
+
+#
 # Check the conformity of Buildroot configuration with regard to the
 # uClibc configuration of the external toolchain, for a particular
 # feature.
toolchain/toolchain-external/Config.in +4 -0
index c53577e..89c799e 100644
@@ -860,6 +860,10 @@ config BR2_TOOLCHAIN_EXTERNAL_UCLIBC
 	bool
 	select BR2_TOOLCHAIN_USES_UCLIBC
 
+config BR2_TOOLCHAIN_EXTERNAL_MUSL
+	bool
+	select BR2_TOOLCHAIN_USES_MUSL
+

if BR2_TOOLCHAIN_EXTERNAL_CUSTOM

choice

toolchain/toolchain-external/Config.in +7 -0
@@ -882,6 +886,13 @@ config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC
 	  eglibc configured to exclude key features may cause build failures to
 	  some packages.
 
+config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL
+	bool "musl"
+	select BR2_TOOLCHAIN_EXTERNAL_MUSL
+	help
+	  Select this option if your external toolchain uses the
+	  'musl' C library, available from http://www.musl-libc.org/.
+

endchoice

if BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC

toolchain/toolchain-external/Config.in +0 -0
@@ -952,6 +963,7 @@ endif # BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC

config BR2_TOOLCHAIN_EXTERNAL_INET_RPC
bool "Toolchain has RPC support?"
select BR2_TOOLCHAIN_HAS_NATIVE_RPC

toolchain/toolchain-external/Config.in +1 -0
+	depends on !BR2_TOOLCHAIN_EXTERNAL_MUSL

default y if BR2_TOOLCHAIN_EXTERNAL_GLIBC
help
Select this option if your external toolchain supports

toolchain/toolchain-external/ext-tool.mk +0 -0
index 8762a46..f642017 100644
@@ -63,6 +63,10 @@ ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)

LIB_EXTERNAL_LIBS+=libnss_files.so.* libnss_dns.so.* endif

toolchain/toolchain-external/ext-tool.mk +4 -0
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL),y)
+LIB_EXTERNAL_LIBS += libc.so libgcc_s.so.*
+endif
+

ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
USR_LIB_EXTERNAL_LIBS+=libstdc++.so.*
endif

toolchain/toolchain-external/ext-tool.mk +3 -1
@@ -369,7 +373,7 @@ $(STAMP_DIR)/ext-toolchain-checked: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES)
 	@$(call MESSAGE,"Checking external toolchain settings")
 	$(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
 	$(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
-	SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(32|64)?/(.*/)?libc\.a::'` ; \
+	SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:(usr/)?lib(32|64)?/(.*/)?libc\.a::'` ; \
 	if test -z "$${SYSROOT_DIR}" ; then \
 		@echo "External toolchain doesn't support --sysroot. Cannot use." ; \
 		exit 1 ; \
@@ -384,6 +388,8 @@ $(STAMP_DIR)/ext-toolchain-checked: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES)
 	fi ; \
 	if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
 		$(call check_uclibc,$${SYSROOT_DIR}) ; \
+	elif test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
+		$(call check_musl,$${SYSROOT_DIR}) ; \
 	else \
 		$(call check_glibc,$${SYSROOT_DIR}) ; \
 	fi

toolchain/toolchain-external/ext-tool.mk $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked · line 475

Quoted 6 lines
toolchain/toolchain-external/ext-tool.mk +3 -0
@@ -464,6 +470,9 @@ $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked
 			$(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
 		done ; \
 	fi ; \
+	if test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
+		ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-arm.so.1 ; \
+	fi ; \

Is this intentionally arm-specific?

Quoted 3 lines
toolchain/toolchain-external/ext-tool.mk +0 -0
 	$(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \
 	$(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR}) ; \
 	if test "$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY)" = "y"; then \
#7 lore raw

PATCH 4/5 toolchain-external: improve help text of some options

In reply to Thomas Petazzoni
---
 toolchain/toolchain-external/Config.in | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
toolchain/toolchain-external/Config.in +11 -4
index 89c799e..67f4fc7 100644
@@ -876,15 +876,22 @@ config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC
 	# For the time being, we assume that all custom external
 	# toolchains have shadow password support.
 	select BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
+	help
+	  Select this option if your external toolchain uses the
+	  uClibc C library (available from http://www.uclibc.org/).
 
 config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC
 	bool "glibc/eglibc"
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	help
-	  Note: eglibc is a variant of glibc that (among other things) can be
-	  configured to exclude some of its features. Using a toolchain with
-	  eglibc configured to exclude key features may cause build failures to
-	  some packages.
+	  Select this option if your external toolchain uses the GNU C
+	  library (available from https://www.gnu.org/software/libc/)
+	  or its variant the eglibc library (http://www.eglibc.org/).
+
+	  Note: eglibc is a variant of glibc that (among other things)
+	  can be configured to exclude some of its features. Using a
+	  toolchain with eglibc configured to exclude key features may
+	  cause build failures to some packages.
 
 config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL
 	bool "musl"
Signature · 1 line
1.8.1.2
#8 lore raw

PATCH 5/5 busybox: add patches to fix build with the musl C library

In reply to Thomas Petazzoni

Those patches have been submitted upstream.

---
 ...01-libbb-use-poll.h-instead-of-sys-poll.h.patch | 32 +++++++++++++++++++
 ...onfig-include-linux-if_slip.h-instead-of-.patch | 33 ++++++++++++++++++++
 ...libiproute-use-linux-if_packet.h-instead-.patch | 36 ++++++++++++++++++++++
 3 files changed, 101 insertions(+)
 create mode 100644 package/busybox/1.21.1/0001-libbb-use-poll.h-instead-of-sys-poll.h.patch
 create mode 100644 package/busybox/1.21.1/0002-network-ifconfig-include-linux-if_slip.h-instead-of-.patch
 create mode 100644 package/busybox/1.21.1/0003-networking-libiproute-use-linux-if_packet.h-instead-.patch
package/busybox/1.21.1/0001-libbb-use-poll.h-instead-of-sys-poll.h.patch new file +32 -0
new file mode 100644
index 0000000..089d858
@@ -0,0 +1,32 @@
+From 676452a92d1fc4f85e8d89930d7729197c031026 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Sat, 5 Oct 2013 15:51:56 +0200
+Subject: [PATCH 1/3] libbb: use <poll.h> instead of <sys/poll.h>
+
+As the pol() manpage recommends, include the <poll.h> header instead
+of <sys/poll.h>. This allows to get rid of gazillions of warnings when
+building Busybox against the musl C library, which prints a warning
+when the internal header <sys/poll.h> is included directly instead of
+the <poll.h> header.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ include/libbb.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/libbb.h b/include/libbb.h
+index e520060..f03f454 100644
+--- a/include/libbb.h
++++ b/include/libbb.h
+@@ -37,7 +37,7 @@
+ #include <libgen.h> /* dirname,basename */
+ #undef basename
+ #define basename dont_use_basename
+-#include <sys/poll.h>
++#include <poll.h>
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
+ #include <sys/socket.h>
+-- 
+1.8.1.2
+
package/busybox/1.21.1/0002-network-ifconfig-include-linux-if_slip.h-instead-of-.patch new file +33 -0
new file mode 100644
index 0000000..ed35719
@@ -0,0 +1,33 @@
+From 5eae213031a3ef88fe8d9d0a387f44264ea635cc Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Sat, 5 Oct 2013 15:53:16 +0200
+Subject: [PATCH 2/3] network/ifconfig: include <linux/if_slip.h> instead of
+ <net/if_slip.h>
+
+The musl C library doesn't provide the <net/if_slip.h> since userspace
+applications can just as well use the <linux/if_slip.h> kernel header.
+
+This commit fixes the build of the ifconfig applet with the musl C
+library.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ networking/ifconfig.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/networking/ifconfig.c b/networking/ifconfig.c
+index 782374b..c90ed6b 100644
+--- a/networking/ifconfig.c
++++ b/networking/ifconfig.c
+@@ -56,7 +56,7 @@
+ #endif
+ 
+ #if ENABLE_FEATURE_IFCONFIG_SLIP
+-# include <net/if_slip.h>
++# include <linux/if_slip.h>
+ #endif
+ 
+ /* I don't know if this is needed for busybox or not.  Anyone? */
+-- 
+1.8.1.2
+
package/busybox/1.21.1/0003-networking-libiproute-use-linux-if_packet.h-instead-.patch new file +36 -0
new file mode 100644
index 0000000..7b74656
@@ -0,0 +1,36 @@
+From d4fec31889ad660a58dab633c511221feb66e817 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Sat, 5 Oct 2013 15:55:06 +0200
+Subject: [PATCH 3/3] networking/libiproute: use <linux/if_packet.h> instead of
+ <net/if_packet.h>
+
+The musl C library doesn't provide the <net/if_packet.h> since the
+corresponding kernel headers <linux/if_packet.h> already provides the
+necessary definitions. Replacing <net/if_packet.h> by
+<linux/if_packet.h> also removes the need to include
+<netpacket/packet.h>
+
+This commit fixes the build of iplink with the musl C library.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ networking/libiproute/iplink.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
+index bad2017..32ccb1c 100644
+--- a/networking/libiproute/iplink.c
++++ b/networking/libiproute/iplink.c
+@@ -5,8 +5,7 @@
+  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+  */
+ #include <net/if.h>
+-#include <net/if_packet.h>
+-#include <netpacket/packet.h>
++#include <linux/if_packet.h>
+ #include <netinet/if_ether.h>
+ 
+ #include "ip_common.h"  /* #include "libbb.h" is inside */
+-- 
+1.8.1.2
+
Signature · 1 line
1.8.1.2