systemd: allow to build with uClibc toolchains
PATCH v2 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 is only disabled in C library function call to getnaminfo(), it does not effect libidn/libidn2 usage in systemd.
Tested in qemu-system-arm.
---
v1 -> v2:
- added Upstream commit URL suggested by Thomas Petazzoni
- rework enable/disable options suggested by Thomas Petazzoni
- extend commit message a little bit
--- .../0004-Make-IDN-support-conditional.patch | 74 ++++++++++++++++++++++ ...0005-make-nss-systemd-support-conditional.patch | 62 ++++++++++++++++++ package/systemd/Config.in | 2 + package/systemd/systemd.mk | 11 ++++ system/Config.in | 6 +- 5 files changed, 152 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 +74 -0
@@ -0,0 +1,74 @@ +Backported from: +https://github.com/systemd/systemd/commit/6326a143263fc460bbda871d6e74b1d7d2841ea1 + +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 +62 -0
62 lines not on this page · raw message
package/systemd/Config.in +2 -0
@@ -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 +11 -0
@@ -43,6 +43,17 @@ SYSTEMD_CONF_OPTS += \ --with-default-dnssec=no \ --without-python +# disable unsupported features for non-glibc toolchains +ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y) +SYSTEMD_CONF_OPTS += \ + --enable-idn \ + --enable-nss-systemd +else +SYSTEMD_CONF_OPTS += \ + --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
@@ -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
PATCH v2 1/1 systemd: allow to build with uClibc toolchains
Hello,
Quoted 13 lines · Waldemar Brodkorb
Both patches where applied upstream.
We need to disable any systemd parts using either IDN or NSS. IDN is only disabled in C library function call togetnaminfo(), it does not effect libidn/libidn2 usage in systemd.Tested in qemu-system-arm.
Signed-off-by Waldemar Brodkorb <[email protected]>---
v1 -> v2:
- added Upstream commit URL suggested by Thomas Petazzoni
- rework enable/disable options suggested by Thomas Petazzoni
- extend commit message a little bit
Quoted 9 lines
--- .../0004-Make-IDN-support-conditional.patch | 74 ++++++++++++++++++++++ ...0005-make-nss-systemd-support-conditional.patch | 62 ++++++++++++++++++ package/systemd/Config.in | 2 + package/systemd/systemd.mk | 11 ++++ system/Config.in | 6 +- 5 files changed, 152 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
I've applied this patch on top of systemd 234 (which is nice because the two patches you were adding can be dropped, as they are upstream).
Unfortunately, it fails to build:
In file included from src/libsystemd-network/sd-radv.c:23:0:/home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/linux/in6.h:30:8: error: redefinition of ?struct in6_addr?
struct in6_addr {
^In file included from /home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/netinet/icmp6.h:24:0,
from src/libsystemd-network/sd-radv.c:20:/home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/netinet/in.h:197:8: note: originally defined here
struct in6_addr
^
In file included from src/libsystemd-network/sd-radv.c:23:0:
/home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/linux/in6.h:41:8: error: redefinition of ?struct sockaddr_in6?
struct sockaddr_in6 {
^In file included from /home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/netinet/in.h:24:0,
from /home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/netinet/icmp6.h:24, from src/libsystemd-network/sd-radv.c:20:/home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sys/socket.h:91:17: note: originally defined here
typedef union { __SOCKADDR_ALLTYPES
^
In file included from src/libsystemd-network/sd-radv.c:23:0:
/home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/linux/in6.h:49:8: error: redefinition of ?struct ipv6_mreq?
struct ipv6_mreq {
^In file included from /home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/netinet/icmp6.h:24:0,
from src/libsystemd-network/sd-radv.c:20:/home/thomas/projets/outputs/TestInitSystemSystemdRwFull/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/netinet/in.h:278:8: note: originally defined here
struct ipv6_mreq
^
Makefile:18205: recipe for target 'src/libsystemd-network/libsystemd_network_la-sd-radv.lo' failed make[4]: *** [src/libsystemd-network/libsystemd_network_la-sd-radv.lo] Error 1
To produce this, I:
- Tweaked InitSystemSystemdBase in support/testing/tests/init/test_systemd.py to use a pre-built uClibc toolchain
- Removed the BR2_TOOLCHAIN_HAS_SSP dependency from INIT_SYSTEMD, because my pre-built uClibc does not have SSP support.
I believe this dependency is no longer needed. Indeed, it was added in Buildroot commit 2c66e4429d23c6e293f9789cdef01b760399fccb, which bumped systemd to v207. However, in version v208, systemd changed the configure logic to use AC_LINK_IFELSE() instead of AC_COMPILE_IFELSE() to test if a given compiler flag is supported or not (see systemd commit d8c8508bad097c5cc354b684866a5b7a83fce394). Thanks to that, the configure script now properly detects that -fstack-protector is not supported, and systemd does not use it. Therefore, this BR2_TOOLCHAIN_HAS_SSP dependency can be removed.
- Ran ./support/testing/run-tests -o ../outputs/ -k tests.init.test_systemd.TestInitSystemSystemdRwFull
And the build failed as shown above.
Could you have a look ?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 1/1 systemd: allow to build with uClibc toolchains
Hi Thomas,
Thomas Petazzoni wrote,
Quoted 26 lines
Hello,
Quoted 13 lines · Waldemar Brodkorb
Both patches where applied upstream.
We need to disable any systemd parts using either IDN or NSS. IDN is only disabled in C library function call togetnaminfo(), it does not effect libidn/libidn2 usage in systemd.Tested in qemu-system-arm.
Signed-off-by Waldemar Brodkorb <[email protected]>---
v1 -> v2:
- added Upstream commit URL suggested by Thomas Petazzoni
- rework enable/disable options suggested by Thomas Petazzoni
- extend commit message a little bitQuoted 9 lines
--- .../0004-Make-IDN-support-conditional.patch | 74 ++++++++++++++++++++++ ...0005-make-nss-systemd-support-conditional.patch | 62 ++++++++++++++++++ package/systemd/Config.in | 2 + package/systemd/systemd.mk | 11 ++++ system/Config.in | 6 +- 5 files changed, 152 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
Quoted 4 lines
I've applied this patch on top of systemd 234 (which is nice because the two patches you were adding can be dropped, as they are upstream).
Unfortunately, it fails to build:
I wasn't able to reproduce this issue with latest master. Can you provide a defconfig using internal toolchain?
I updated the patch so that we are using the same patchset. Maybe some issue resolved in the internal toolchain?
best regards
Waldemar