Skip to contentSkip to conversation

systemd: allow to build with uClibc toolchains

PATCH Superseded Waldemar Brodkorb 2 participants 2 messages Feb 12, 2018

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

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

We need to disable any systemd parts using either IDN, NSS or gshadow. IDN is only disabled in C library function call to getnameinfo(), it does not effect libidn/libidn2 usage in systemd.

While trying to disable resolve functionality, a typo was recognized.

Tested with 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
v2 -> v3:
- sync to latest master changes
- remove patches included upstream
- disable features not usable with uClibc-ng lacking nss.h
v3 -> v4:
- add comment about missing nss suggested by Arnout
- add extra parenthesis suggested by Arnout
v4 -> v5:
- update after switch to meson
- fix typo for resolve option

---
 package/systemd/Config.in  |  3 +++
 package/systemd/systemd.mk | 15 +++++++++++++--
 system/Config.in           |  6 +++---
 3 files changed, 19 insertions(+), 5 deletions(-)
package/systemd/Config.in +3 -0
index 661f40d..81eee96 100644
@@ -190,6 +190,7 @@ config BR2_PACKAGE_SYSTEMD_MACHINED
 
 config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
 	bool "enable myhostname NSS plugin"
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC # needs nss.h
 	default y
 	help
 	  nss-myhostname is a plug-in module for the GNU Name Service
@@ -245,6 +246,7 @@ config BR2_PACKAGE_SYSTEMD_RANDOMSEED
 
 config BR2_PACKAGE_SYSTEMD_RESOLVED
 	bool "enable resolve daemon"
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC # needs nss.h
 	default y
 	help
 	  systemd-resolved is a system service that provides network
@@ -278,6 +280,7 @@ config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
 
 config BR2_PACKAGE_SYSTEMD_SYSUSERS
 	bool "enable sysusers support"
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC # needs gshadow.h
 	help
 	  systemd-sysusers creates system users and groups, based on
 	  the file format and location specified in sysusers.d(5).
package/systemd/systemd.mk +13 -2
index 1c31ebb..2bc665e 100644
@@ -48,6 +48,17 @@ SYSTEMD_CONF_OPTS += \
 	-Dmount-path=/usr/bin/mount \
 	-Dumount-path=/usr/bin/umount
 
+# disable unsupported features for non-glibc toolchains
+ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
+SYSTEMD_CONF_OPTS += \
+	-Didn=true \
+	-Dnss-systemd=true
+else
+SYSTEMD_CONF_OPTS += \
+	-Didn=false \
+	-Dnss-systemd=false
+endif
+
 ifeq ($(BR2_PACKAGE_ACL),y)
 SYSTEMD_DEPENDENCIES += acl
 SYSTEMD_CONF_OPTS += -Dacl=true
@@ -287,10 +298,10 @@ SYSTEMD_CONF_OPTS += -Dnetworkd=false
 endif
 
 ifeq ($(BR2_PACKAGE_SYSTEMD_RESOLVED),y)
-SYSTEMD_CONF_OPTS += -Dresolved=true
+SYSTEMD_CONF_OPTS += -Dresolve=true
 SYSTEMD_RESOLVED_USER = systemd-resolve -1 systemd-resolve -1 * - - - Network Name Resolution Manager
 else
-SYSTEMD_CONF_OPTS += -Dresolved=false
+SYSTEMD_CONF_OPTS += -Dresolve=false
 endif
 
 ifeq ($(BR2_PACKAGE_SYSTEMD_TIMESYNCD),y)
system/Config.in +3 -3
index d48cf8d..7b36516 100644
@@ -127,7 +127,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
@@ -137,8 +137,8 @@ config BR2_INIT_SYSTEMD
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
 
-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 v5 1/1 systemd: allow to build with uClibc toolchains

Hello,

package/systemd/systemd.mk SYSTEMD_CONF_OPTS += -Dnetworkd=false · line 305

Quoted 8 lines · Waldemar Brodkorb

ifeq ($(BR2_PACKAGE_SYSTEMD_RESOLVED),y)

package/systemd/systemd.mk +2 -2
-SYSTEMD_CONF_OPTS += -Dresolved=true
+SYSTEMD_CONF_OPTS += -Dresolve=true
 SYSTEMD_RESOLVED_USER = systemd-resolve -1 systemd-resolve -1 * - - - Network Name Resolution Manager
 else
-SYSTEMD_CONF_OPTS += -Dresolved=false
+SYSTEMD_CONF_OPTS += -Dresolve=false
 endif

This should be a separate patch, to be applied on the master branch, while the rest (enabling on uClibc) is for the next branch. Could you make two separate patches ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com