Skip to contentSkip to conversation

systemd: allow to build with uClibc toolchains

PATCH Superseded Waldemar Brodkorb 2 participants 2 messages Jun 25, 2017

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 systemd: allow to build with uClibc toolchains

Both patches where applied upstream.
We need to disable any systemd parts using either IDN or NSS. (IDN in getaddrinfo()/getnaminfo())

Tested in qemu-system-arm using defconfig.

---
All required patches for systemd are included in uClibc-ng 1.0.25. So no need to rebuild the toolchains.
There might be open issues with some of the systemd parts and I am willing to fix any uClibc issues when reported back.

---
 .../0004-Make-IDN-support-conditional.patch        | 71 ++++++++++++++++++++++
 ...0005-make-nss-systemd-support-conditional.patch | 59 ++++++++++++++++++
 package/systemd/Config.in                          |  2 +
 package/systemd/systemd.mk                         |  9 +++
 system/Config.in                                   |  6 +-
 5 files changed, 144 insertions(+), 3 deletions(-)
 create mode 100644 package/systemd/0004-Make-IDN-support-conditional.patch
 create mode 100644 package/systemd/0005-make-nss-systemd-support-conditional.patch
package/systemd/0004-Make-IDN-support-conditional.patch new file +71 -0
new file mode 100644
index 0000000..29afe9c
@@ -0,0 +1,71 @@
+From 6326a143263fc460bbda871d6e74b1d7d2841ea1 Mon Sep 17 00:00:00 2001
+From: Waldemar Brodkorb <[email protected]>
+Date: Thu, 15 Jun 2017 17:44:59 +0200
+Subject: [PATCH] Make IDN support conditional
+
+[zj: rename HAVE_IDN to ENABLE_IDN]
+
+Signed-off-by: Waldemar Brodkorb <[email protected]>
+---
+ configure.ac            | 10 ++++++++++
+ src/basic/socket-util.c |  9 +++++++--
+ 2 files changed, 17 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index a47492d..3e7af76 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1050,6 +1050,15 @@ fi
+ AM_CONDITIONAL(HAVE_LIBIDN, [test "$have_libidn" = "yes"])
+ 
+ # ------------------------------------------------------------------------------
++have_idn=no
++AC_ARG_ENABLE(idn, AS_HELP_STRING([--disable-idn], [disable IDN when printing host names]))
++if test "x$enable_idn" != "xno"; then
++        have_idn=yes
++        AC_DEFINE(ENABLE_IDN, [1], [IDN is enabled])
++fi
++AM_CONDITIONAL(ENABLE_IDN, [test "$have_idn" = "yes"])
++
++# ------------------------------------------------------------------------------
+ have_libiptc=no
+ AC_ARG_ENABLE(libiptc, AS_HELP_STRING([--disable-libiptc], [disable optional LIBIPTC support]))
+ if test "x$enable_libiptc" != "xno"; then
+@@ -1742,6 +1751,7 @@ AC_MSG_RESULT([
+         libcurl:                           ${have_libcurl}
+         libidn2:                           ${have_libidn2}
+         libidn:                            ${have_libidn}
++        IDN:                               ${have_idn}
+         libiptc:                           ${have_libiptc}
+         ELFUTILS:                          ${have_elfutils}
+         binfmt:                            ${have_binfmt}
+diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
+index e5847dc..49642c2 100644
+--- a/src/basic/socket-util.c
++++ b/src/basic/socket-util.c
+@@ -48,6 +48,12 @@
+ #include "utf8.h"
+ #include "util.h"
+ 
++#ifdef ENABLE_IDN
++#  define IDN_FLAGS (NI_IDN|NI_IDN_USE_STD3_ASCII_RULES)
++#else
++#  define IDN_FLAGS 0
++#endif
++
+ int socket_address_parse(SocketAddress *a, const char *s) {
+         char *e, *n;
+         unsigned u;
+@@ -723,8 +729,7 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret)
+ 
+         assert(_ret);
+ 
+-        r = getnameinfo(&sa->sa, salen, host, sizeof(host), NULL, 0,
+-                        NI_IDN|NI_IDN_USE_STD3_ASCII_RULES);
++        r = getnameinfo(&sa->sa, salen, host, sizeof(host), NULL, 0, IDN_FLAGS);
+         if (r != 0) {
+                 int saved_errno = errno;
+ 
+-- 
+2.1.4
+
package/systemd/0005-make-nss-systemd-support-conditional.patch new file +59 -0

59 lines not on this page · raw message

package/systemd/Config.in +2 -0
index 478cc10..e1b66f9 100644
@@ -188,6 +188,7 @@ config BR2_PACKAGE_SYSTEMD_MACHINED
 
 config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
 	bool "enable myhostname NSS plugin"
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC
 	default y
 	help
 	  nss-myhostname is a plug-in module for the GNU Name Service
@@ -243,6 +244,7 @@ config BR2_PACKAGE_SYSTEMD_RANDOMSEED
 
 config BR2_PACKAGE_SYSTEMD_RESOLVED
 	bool "enable resolve daemon"
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC
 	default y
 	help
 	  systemd-resolved is a system service that provides network
package/systemd/systemd.mk +9 -0
index 153d615..e8731b6 100644
@@ -43,6 +43,15 @@ SYSTEMD_CONF_OPTS += \
 	--with-default-dnssec=no \
 	--without-python
 
+# disable unsupported features using NSS or IDN
+ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
+SYSTEMD_CONF_OPTS += \
+	--disable-resolved \
+	--disable-myhostname \
+	--disable-idn \
+	--disable-nss-systemd
+endif
+
 SYSTEMD_CFLAGS = $(TARGET_CFLAGS) -fno-lto
 
 # Override paths to a few utilities needed at runtime, to
system/Config.in +3 -3
index b47ae43..dc99b51 100644
@@ -118,7 +118,7 @@ config BR2_INIT_SYSV
 config BR2_INIT_SYSTEMD
 	bool "systemd"
 	depends on BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
-	depends on BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_TOOLCHAIN_USES_GLIBC || BR2_TOOLCHAIN_USES_UCLIBC
 	depends on BR2_USE_WCHAR
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	depends on BR2_TOOLCHAIN_HAS_SSP
@@ -129,8 +129,8 @@ config BR2_INIT_SYSTEMD
 	select BR2_PACKAGE_SYSTEMD
 	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW if BR2_ROOTFS_SKELETON_DEFAULT
 
-comment "systemd needs a glibc toolchain, headers >= 3.10"
-	depends on !(BR2_TOOLCHAIN_USES_GLIBC \
+comment "systemd needs a glibc or uClibc toolchain, headers >= 3.10"
+	depends on !(BR2_TOOLCHAIN_USES_GLIBC || BR2_TOOLCHAIN_USES_UCLIBC \
 		&& BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10)
 
 config BR2_INIT_NONE
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 systemd: allow to build with uClibc toolchains

Hello,

Quoted 7 lines · Waldemar Brodkorb

Both patches where applied upstream.
We need to disable any systemd parts using either IDN or NSS. (IDN in getaddrinfo()/getnaminfo())

Tested in qemu-system-arm using defconfig.

Nice! Thanks for working on this. A couple of questions/comments below, though.

Quoted 6 lines
package/systemd/0004-Make-IDN-support-conditional.patch new file +0 -0
new file mode 100644
index 0000000..29afe9c

package/systemd/0004-Make-IDN-support-conditional.patch line 8

Quoted 8 lines
package/systemd/0004-Make-IDN-support-conditional.patch new file +8 -0
@@ -0,0 +1,71 @@
+From 6326a143263fc460bbda871d6e74b1d7d2841ea1 Mon Sep 17 00:00:00 2001
+From: Waldemar Brodkorb <[email protected]>
+Date: Thu, 15 Jun 2017 17:44:59 +0200
+Subject: [PATCH] Make IDN support conditional
+
+[zj: rename HAVE_IDN to ENABLE_IDN]
+
+Signed-off-by: Waldemar Brodkorb <[email protected]>

If those patches are upstream, having the upstream URL in here is nice.

Quoted 25 lines
package/systemd/Config.in +2 -0
index 478cc10..e1b66f9 100644
@@ -188,6 +188,7 @@ config BR2_PACKAGE_SYSTEMD_MACHINED
 
 config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
 	bool "enable myhostname NSS plugin"
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC
 	default y
 	help
 	  nss-myhostname is a plug-in module for the GNU Name Service
@@ -243,6 +244,7 @@ config BR2_PACKAGE_SYSTEMD_RANDOMSEED
 
 config BR2_PACKAGE_SYSTEMD_RESOLVED
 	bool "enable resolve daemon"
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC
 	default y
 	help
 	  systemd-resolved is a system service that provides network
package/systemd/systemd.mk +0 -0
index 153d615..e8731b6 100644

package/systemd/systemd.mk SYSTEMD_CONF_OPTS += \ · line 52

Quoted 10 lines
package/systemd/systemd.mk +7 -0
@@ -43,6 +43,15 @@ SYSTEMD_CONF_OPTS += \
 	--with-default-dnssec=no \
 	--without-python
 
+# disable unsupported features using NSS or IDN
+ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
+SYSTEMD_CONF_OPTS += \
+	--disable-resolved \
+	--disable-myhostname \
+	--disable-idn \
+	--disable-nss-systemd

This is not really good.

First, --disable-resolved and --disable-myhostname are not needed, because you have added the "depends on !BR2_TOOLCHAIN_USES_UCLIBC" to those options. Therefore, they cannot be selected, which means the existing code:

ifeq ($(BR2_PACKAGE_SYSTEMD_MYHOSTNAME),y)
SYSTEMD_CONF_OPTS += --enable-myhostname
else
SYSTEMD_CONF_OPTS += --disable-myhostname
endif

ifeq ($(BR2_PACKAGE_SYSTEMD_RESOLVED),y)
SYSTEMD_CONF_OPTS += --enable-resolved
SYSTEMD_RESOLVED_USER = systemd-resolve -1 systemd-resolve -1 * - - - Network Name Resolution Manager else
SYSTEMD_CONF_OPTS += --disable-resolved
endif

will already pass --disable-resolved/--disable-myhostname.

For --disable-idn, I'm wondering about the interaction with --{enable,disable}-libidn that we already have. Are these independent?

Also, can we have both the enable/disable logic for those options, something like:

ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
... enable whatever requires glibc specific stuff
else
... disable whatever requires glibc specific stuff
endif

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com