package/systemd: use statically linked host tools
PATCH 1/1 package/systemd: use statically linked host tools
This lets us remove the HOST_SYSTEMD_FIX_RPATH hack.
--- ...nalctl-allow-statically-linked-build.patch | 68 +++++++++++++++++++ package/systemd/systemd.mk | 28 +++----- 2 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 package/systemd/0002-journalctl-allow-statically-linked-build.patch
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +68 -0
@@ -0,0 +1,68 @@ +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001 +From: James Hilliard <[email protected]> +Date: Wed, 27 Jul 2022 15:28:09 -0600 +Subject: [PATCH] journalctl: allow statically linked build + +The journalctl tool may be needed on cross compilation hosts in order +to run --update-catalog against a target rootfs. + +To avoid reliability issues caused by shared linking allow journalctl +to be linked statically. + +Signed-off-by: James Hilliard <[email protected]> +[Upstream status: +https://github.com/systemd/systemd/pull/24140] +--- + meson.build | 11 ++++++++++- + meson_options.txt | 2 ++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 692ee1ed4d..8cce19dce6 100644 +--- a/meson.build ++++ b/meson.build +@@ -2263,11 +2263,19 @@ public_programs += executable( + install_rpath : rootpkglibdir, + install : true) + ++if get_option('link-journalctl-shared') ++ journalctl_link_with = [libshared] ++else ++ journalctl_link_with = [libsystemd_static, ++ libshared_static, ++ libbasic_gcrypt] ++endif ++ + public_programs += executable( + 'journalctl', + journalctl_sources, + include_directories : includes, +- link_with : [libshared], ++ link_with : [journalctl_link_with], + dependencies : [threads, + libdl, + libxz, +@@ -4357,6 +4365,7 @@ foreach tuple : [ + ['link-systemctl-shared', get_option('link-systemctl-shared')], + ['link-networkd-shared', get_option('link-networkd-shared')], + ['link-timesyncd-shared', get_option('link-timesyncd-shared')], ++ ['link-journalctl-shared',get_option('link-journalctl-shared')], + ['link-boot-shared', get_option('link-boot-shared')], + ['first-boot-full-preset'], + ['fexecve'], +diff --git a/meson_options.txt b/meson_options.txt +index 628ca1d797..d8c0c581c2 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -25,6 +25,8 @@ option('link-networkd-shared', type: 'boolean', + description : 'link systemd-networkd and its helpers to libsystemd-shared.so') + option('link-timesyncd-shared', type: 'boolean', + description : 'link systemd-timesyncd and its helpers to libsystemd-shared.so') ++option('link-journalctl-shared', type: 'boolean', ++ description : 'link journalctl against libsystemd-shared.so') + option('link-boot-shared', type: 'boolean', + description : 'link bootctl and systemd-bless-boot against libsystemd-shared.so') + option('first-boot-full-preset', type: 'boolean', value: false, +-- +2.34.1 +
package/systemd/systemd.mk +8 -20
@@ -738,7 +738,7 @@ endef SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_RM_CATALOG_UPDATE_SERVICE define SYSTEMD_CREATE_TMPFILES_HOOK - HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles \ + HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles.standalone \ $(SYSTEMD_PKGDIR)/fakeroot_tmpfiles.sh $(TARGET_DIR) endef SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_CREATE_TMPFILES_HOOK
@@ -781,6 +781,13 @@ HOST_SYSTEMD_CONF_OPTS = \ --libdir=lib \ --sysconfdir=/etc \ --localstatedir=/var \ + -Dlink-udev-shared=false \ + -Dlink-systemctl-shared=false \ + -Dlink-networkd-shared=false \ + -Dlink-timesyncd-shared=false \ + -Dlink-journalctl-shared=false \ + -Dlink-boot-shared=false \ + -Dstandalone-binaries=true \ -Dmode=release \ -Dutmp=false \ -Dhibernate=false \
@@ -854,24 +861,5 @@ HOST_SYSTEMD_DEPENDENCIES = \ HOST_SYSTEMD_NINJA_ENV = DESTDIR=$(HOST_DIR) -# Fix RPATH After installation -# * systemd provides a install_rpath instruction to meson because the binaries -# need to link with libsystemd which is not in a standard path -# * meson can only replace the RPATH, not append to it -# * the original rpath is thus lost. -# * the original path had been tweaked by buildroot via LDFLAGS to add -# $(HOST_DIR)/lib -# * thus re-tweak rpath after the installation for all binaries that need it -HOST_SYSTEMD_HOST_TOOLS = busctl journalctl systemctl systemd-* udevadm - -define HOST_SYSTEMD_FIX_RPATH - for f in $(addprefix $(HOST_DIR)/bin/,$(HOST_SYSTEMD_HOST_TOOLS)); do \ - [ -e $$f ] || continue; \ - $(HOST_DIR)/bin/patchelf --set-rpath $(HOST_DIR)/lib:$(HOST_DIR)/lib/systemd $${f} \ - || exit 1; \ - done -endef -HOST_SYSTEMD_POST_INSTALL_HOOKS += HOST_SYSTEMD_FIX_RPATH - $(eval $(meson-package)) $(eval $(host-meson-package))
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Am Do., 28. Juli 2022 um 00:11 Uhr schrieb James Hilliard <[email protected]>:
Quoted 137 lines
This lets us remove the
HOST_SYSTEMD_FIX_RPATHhack.Signed-off-by James Hilliard <[email protected]>--- ...nalctl-allow-statically-linked-build.patch | 68 +++++++++++++++++++ package/systemd/systemd.mk | 28 +++----- 2 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 package/systemd/0002-journalctl-allow-statically-linked-build.patchpackage/systemd/0002-journalctl-allow-statically-linked-build.patch new file +68
-0@@ -0,0 +1,68 @@ +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001 +From: James Hilliard <[email protected]> +Date: Wed, 27 Jul 2022 15:28:09 -0600 +Subject: [PATCH] journalctl: allow statically linked build + +The journalctl tool may be needed on cross compilation hosts in order +to run --update-catalog against a target rootfs. + +To avoid reliability issues caused by shared linking allow journalctl +to be linked statically. + +Signed-off-by: James Hilliard <[email protected]> +[Upstream status: +https://github.com/systemd/systemd/pull/24140] +--- + meson.build | 11 ++++++++++- + meson_options.txt | 2 ++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 692ee1ed4d..8cce19dce6 100644 +--- a/meson.build ++++ b/meson.build +@@ -2263,11 +2263,19 @@ public_programs += executable( + install_rpath : rootpkglibdir, + install : true) + ++if get_option('link-journalctl-shared') ++ journalctl_link_with = [libshared] ++else ++ journalctl_link_with = [libsystemd_static, ++ libshared_static, ++ libbasic_gcrypt] ++endif ++ + public_programs += executable( + 'journalctl', + journalctl_sources, + include_directories : includes, +- link_with : [libshared], ++ link_with : [journalctl_link_with], + dependencies : [threads, + libdl, + libxz, +@@ -4357,6 +4365,7 @@ foreach tuple : [ + ['link-systemctl-shared', get_option('link-systemctl-shared')], + ['link-networkd-shared', get_option('link-networkd-shared')], + ['link-timesyncd-shared', get_option('link-timesyncd-shared')], ++ ['link-journalctl-shared',get_option('link-journalctl-shared')], + ['link-boot-shared', get_option('link-boot-shared')], + ['first-boot-full-preset'], + ['fexecve'], +diff --git a/meson_options.txt b/meson_options.txt +index 628ca1d797..d8c0c581c2 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -25,6 +25,8 @@ option('link-networkd-shared', type: 'boolean', + description : 'link systemd-networkd and its helpers to libsystemd-shared.so') + option('link-timesyncd-shared', type: 'boolean', + description : 'link systemd-timesyncd and its helpers to libsystemd-shared.so') ++option('link-journalctl-shared', type: 'boolean', ++ description : 'link journalctl against libsystemd-shared.so') + option('link-boot-shared', type: 'boolean', + description : 'link bootctl and systemd-bless-boot against libsystemd-shared.so') + option('first-boot-full-preset', type: 'boolean', value: false, +-- +2.34.1 +package/systemd/systemd.mk +8
-21@@ -738,7 +738,7 @@ endef SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_RM_CATALOG_UPDATE_SERVICE define SYSTEMD_CREATE_TMPFILES_HOOK - HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles \ + HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles.standalone \ $(SYSTEMD_PKGDIR)/fakeroot_tmpfiles.sh $(TARGET_DIR) endef SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_CREATE_TMPFILES_HOOK@@ -781,6 +781,13 @@ HOST_SYSTEMD_CONF_OPTS = \ --libdir=lib \ --sysconfdir=/etc \ --localstatedir=/var \ + -Dlink-udev-shared=false \ + -Dlink-systemctl-shared=false \ + -Dlink-networkd-shared=false \ + -Dlink-timesyncd-shared=false \ + -Dlink-journalctl-shared=false \ + -Dlink-boot-shared=false \ + -Dstandalone-binaries=true \ -Dmode=release \ -Dutmp=false \ -Dhibernate=false \@@ -854,24 +861,5 @@ HOST_SYSTEMD_DEPENDENCIES = \ HOST_SYSTEMD_NINJA_ENV = DESTDIR=$(HOST_DIR) -# Fix RPATH After installation -# * systemd provides a install_rpath instruction to meson because the binaries -# need to link with libsystemd which is not in a standard path -# * meson can only replace the RPATH, not append to it -# * the original rpath is thus lost. -# * the original path had been tweaked by buildroot via LDFLAGS to add -# $(HOST_DIR)/lib -# * thus re-tweak rpath after the installation for all binaries that need it -HOST_SYSTEMD_HOST_TOOLS = busctl journalctl systemctl systemd-* udevadm - -define HOST_SYSTEMD_FIX_RPATH - for f in $(addprefix $(HOST_DIR)/bin/,$(HOST_SYSTEMD_HOST_TOOLS)); do \ - [ -e $$f ] || continue; \ - $(HOST_DIR)/bin/patchelf --set-rpath $(HOST_DIR)/lib:$(HOST_DIR)/lib/systemd $${f} \ - || exit 1; \ - done -endef -HOST_SYSTEMD_POST_INSTALL_HOOKS += HOST_SYSTEMD_FIX_RPATH - $(eval $(meson-package)) $(eval $(host-meson-package)) --
Quoted 2 lines
2.34.1
Hello James,
what issues are you trying to prevent here? buildroot's host tools generally use the rpath to work,
static tools will just blow up filesize, and would only make sense if you want to copy a few of them
to another location.
Makes sense for example the bootctl tool when you want to re-use that in an initramfs,
but thats not buildroot's concern AFAIK.
Norbert
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 145 lines · Norbert Lange
Am Do., 28. Juli 2022 um 00:11 Uhr schrieb James Hilliard <[email protected]>:
Quoted 137 lines
This lets us remove the
HOST_SYSTEMD_FIX_RPATHhack.Signed-off-by James Hilliard <[email protected]>--- ...nalctl-allow-statically-linked-build.patch | 68 +++++++++++++++++++ package/systemd/systemd.mk | 28 +++----- 2 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 package/systemd/0002-journalctl-allow-statically-linked-build.patchpackage/systemd/0002-journalctl-allow-statically-linked-build.patch new file +68
-0@@ -0,0 +1,68 @@ +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001 +From: James Hilliard <[email protected]> +Date: Wed, 27 Jul 2022 15:28:09 -0600 +Subject: [PATCH] journalctl: allow statically linked build + +The journalctl tool may be needed on cross compilation hosts in order +to run --update-catalog against a target rootfs. + +To avoid reliability issues caused by shared linking allow journalctl +to be linked statically. + +Signed-off-by: James Hilliard <[email protected]> +[Upstream status: +https://github.com/systemd/systemd/pull/24140] +--- + meson.build | 11 ++++++++++- + meson_options.txt | 2 ++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 692ee1ed4d..8cce19dce6 100644 +--- a/meson.build ++++ b/meson.build +@@ -2263,11 +2263,19 @@ public_programs += executable( + install_rpath : rootpkglibdir, + install : true) + ++if get_option('link-journalctl-shared') ++ journalctl_link_with = [libshared] ++else ++ journalctl_link_with = [libsystemd_static, ++ libshared_static, ++ libbasic_gcrypt] ++endif ++ + public_programs += executable( + 'journalctl', + journalctl_sources, + include_directories : includes, +- link_with : [libshared], ++ link_with : [journalctl_link_with], + dependencies : [threads, + libdl, + libxz, +@@ -4357,6 +4365,7 @@ foreach tuple : [ + ['link-systemctl-shared', get_option('link-systemctl-shared')], + ['link-networkd-shared', get_option('link-networkd-shared')], + ['link-timesyncd-shared', get_option('link-timesyncd-shared')], ++ ['link-journalctl-shared',get_option('link-journalctl-shared')], + ['link-boot-shared', get_option('link-boot-shared')], + ['first-boot-full-preset'], + ['fexecve'], +diff --git a/meson_options.txt b/meson_options.txt +index 628ca1d797..d8c0c581c2 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -25,6 +25,8 @@ option('link-networkd-shared', type: 'boolean', + description : 'link systemd-networkd and its helpers to libsystemd-shared.so') + option('link-timesyncd-shared', type: 'boolean', + description : 'link systemd-timesyncd and its helpers to libsystemd-shared.so') ++option('link-journalctl-shared', type: 'boolean', ++ description : 'link journalctl against libsystemd-shared.so') + option('link-boot-shared', type: 'boolean', + description : 'link bootctl and systemd-bless-boot against libsystemd-shared.so') + option('first-boot-full-preset', type: 'boolean', value: false, +-- +2.34.1 +package/systemd/systemd.mk +8
-21@@ -738,7 +738,7 @@ endef SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_RM_CATALOG_UPDATE_SERVICE define SYSTEMD_CREATE_TMPFILES_HOOK - HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles \ + HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles.standalone \ $(SYSTEMD_PKGDIR)/fakeroot_tmpfiles.sh $(TARGET_DIR) endef SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_CREATE_TMPFILES_HOOK@@ -781,6 +781,13 @@ HOST_SYSTEMD_CONF_OPTS = \ --libdir=lib \ --sysconfdir=/etc \ --localstatedir=/var \ + -Dlink-udev-shared=false \ + -Dlink-systemctl-shared=false \ + -Dlink-networkd-shared=false \ + -Dlink-timesyncd-shared=false \ + -Dlink-journalctl-shared=false \ + -Dlink-boot-shared=false \ + -Dstandalone-binaries=true \ -Dmode=release \ -Dutmp=false \ -Dhibernate=false \@@ -854,24 +861,5 @@ HOST_SYSTEMD_DEPENDENCIES = \ HOST_SYSTEMD_NINJA_ENV = DESTDIR=$(HOST_DIR) -# Fix RPATH After installation -# * systemd provides a install_rpath instruction to meson because the binaries -# need to link with libsystemd which is not in a standard path -# * meson can only replace the RPATH, not append to it -# * the original rpath is thus lost. -# * the original path had been tweaked by buildroot via LDFLAGS to add -# $(HOST_DIR)/lib -# * thus re-tweak rpath after the installation for all binaries that need it -HOST_SYSTEMD_HOST_TOOLS = busctl journalctl systemctl systemd-* udevadm - -define HOST_SYSTEMD_FIX_RPATH - for f in $(addprefix $(HOST_DIR)/bin/,$(HOST_SYSTEMD_HOST_TOOLS)); do \ - [ -e $$f ] || continue; \ - $(HOST_DIR)/bin/patchelf --set-rpath $(HOST_DIR)/lib:$(HOST_DIR)/lib/systemd $${f} \ - || exit 1; \ - done -endef -HOST_SYSTEMD_POST_INSTALL_HOOKS += HOST_SYSTEMD_FIX_RPATH - $(eval $(meson-package)) $(eval $(host-meson-package)) --Quoted 2 lines
2.34.1
Hello James,
Quoted 5 lines
what issues are you trying to prevent here? buildroot's host tools generally use the rpath to work,
static tools will just blow up filesize, and would only make sense if you want to copy a few of them
to another location.
We don't normally need to use patchelf for host tools, figured it would be nice to drop that hack.
Size shouldn't really matter much for small host tools like these IMO, and we should be able to avoid having to install a host libsystemd-shared this way down the line(static binaries are often smaller than shared in aggregate if only a subset of the library functions get used).
Quoted 6 lines
Makes sense for example the bootctl tool when you want to re-use that in an initramfs,
but thats not buildroot's concern AFAIK.Norbert
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
James Hilliard <[email protected]> schrieb am Do., 28. Juli 2022, 11:01:
Quoted 163 lines · Norbert Lange
Quoted 12 lines
Am Do., 28. Juli 2022 um 00:11 Uhr schrieb James Hilliard <[email protected]>:
Quoted 9 lines
This lets us remove the
HOST_SYSTEMD_FIX_RPATHhack.Signed-off-by James Hilliard <[email protected]>--- ...nalctl-allow-statically-linked-build.patch | 68 +++++++++++++++++++ package/systemd/systemd.mk | 28 +++----- 2 files changed, 76 insertions(+), 20 deletions(-) create mode 100644
package/systemd/0002-journalctl-allow-statically-linked-build.patchQuoted 2 lines
Quoted 2 lines
diff --git
a/package/systemd/0002-journalctl-allow-statically-linked-build.patchb/package/systemd/0002-journalctl-allow-statically-linked-build.patchQuoted 4 lines
Quoted 4 lines
new file mode 100644
index 0000000000..98ffb72cca
---/dev/null
+++
b/package/systemd/0002-journalctl-allow-statically-linked-build.patchQuoted 39 lines
Quoted 39 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +38
-0@@ -0,0 +1,68 @@ +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001 +From: James Hilliard <[email protected]> +Date: Wed, 27 Jul 2022 15:28:09 -0600 +Subject: [PATCH] journalctl: allow statically linked build + +The journalctl tool may be needed on cross compilation hosts in order +to run --update-catalog against a target rootfs. + +To avoid reliability issues caused by shared linking allow journalctl +to be linked statically. + +Signed-off-by: James Hilliard <[email protected]> +[Upstream status: +https://github.com/systemd/systemd/pull/24140] +--- + meson.build | 11 ++++++++++- + meson_options.txt | 2 ++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 692ee1ed4d..8cce19dce6 100644 +--- a/meson.build ++++ b/meson.build +@@ -2263,11 +2263,19 @@ public_programs += executable( + install_rpath : rootpkglibdir, + install : true) + ++if get_option('link-journalctl-shared') ++ journalctl_link_with = [libshared] ++else ++ journalctl_link_with = [libsystemd_static, ++ libshared_static, ++ libbasic_gcrypt] ++endif ++ + public_programs += executable( + 'journalctl', + journalctl_sources,Quoted 8 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch
Quoted 8 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +8
-0+ include_directories : includes, +- link_with : [libshared], ++ link_with : [journalctl_link_with], + dependencies : [threads, + libdl, + libxz, +@@ -4357,6 +4365,7 @@ foreach tuple : [ + ['link-systemctl-shared',
get_option('link-systemctl-shared')],Quoted 1 line
Review line 47
Quoted 1 line
(quoted diff) +1
-0+ ['link-networkd-shared',
get_option('link-networkd-shared')],Quoted 1 line
Review line 48
Quoted 1 line
(quoted diff) +1
-0+ ['link-timesyncd-shared',
get_option('link-timesyncd-shared')],Quoted 1 line
package/systemd/0002-journalctl-allow-statically-linked-build.patch line 35
Quoted 1 line
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +1
-0++['link-journalctl-shared',get_option('link-journalctl-shared')],
Quoted 9 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch
Quoted 9 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +9
-0+ ['link-boot-shared', get_option('link-boot-shared')], + ['first-boot-full-preset'], + ['fexecve'], +diff --git a/meson_options.txt b/meson_options.txt +index 628ca1d797..d8c0c581c2 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -25,6 +25,8 @@ option('link-networkd-shared', type: 'boolean', + description : 'link systemd-networkd and its helpers tolibsystemd-shared.so')
Quoted 2 lines
Review line 60
Quoted 2 lines
(quoted diff) +2
-0+ option('link-timesyncd-shared', type: 'boolean', + description : 'link systemd-timesyncd and its helpers tolibsystemd-shared.so')
Quoted 4 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch
Quoted 4 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +4
-0++option('link-journalctl-shared', type: 'boolean', ++ description : 'link journalctl against libsystemd-shared.so') + option('link-boot-shared', type: 'boolean', + description : 'link bootctl and systemd-bless-boot againstlibsystemd-shared.so')
Quoted 11 lines
Quoted 11 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +4
-0+ option('first-boot-full-preset', type: 'boolean', value: false, +-- +2.34.1 +package/systemd/systemd.mk +0
-0@@ -738,7 +738,7 @@ endef SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_RM_CATALOG_UPDATE_SERVICEQuoted 3 lines
package/systemd/systemd.mk endef
Quoted 3 lines
package/systemd/systemd.mk +1
-1define SYSTEMD_CREATE_TMPFILES_HOOK - HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles \ +HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles.standalone \
Quoted 19 lines
Quoted 19 lines
package/systemd/systemd.mk +7
-0$(SYSTEMD_PKGDIR)/fakeroot_tmpfiles.sh $(TARGET_DIR) endef SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_CREATE_TMPFILES_HOOK@@ -781,6 +781,13 @@ HOST_SYSTEMD_CONF_OPTS = \ --libdir=lib \ --sysconfdir=/etc \ --localstatedir=/var \ + -Dlink-udev-shared=false \ + -Dlink-systemctl-shared=false \ + -Dlink-networkd-shared=false \ + -Dlink-timesyncd-shared=false \ + -Dlink-journalctl-shared=false \ + -Dlink-boot-shared=false \ + -Dstandalone-binaries=true \ -Dmode=release \ -Dutmp=false \ -Dhibernate=false \@@ -854,24 +861,5 @@ HOST_SYSTEMD_DEPENDENCIES = \Quoted 4 lines
package/systemd/systemd.mk HOST_SYSTEMD_DEPENDENCIES = \
Quoted 4 lines
package/systemd/systemd.mk +0
-2HOST_SYSTEMD_NINJA_ENV = DESTDIR=$(HOST_DIR) -# Fix RPATH After installation -# * systemd provides a install_rpath instruction to meson because thebinaries
Quoted 6 lines
package/systemd/systemd.mk HOST_SYSTEMD_DEPENDENCIES = \
Quoted 6 lines
package/systemd/systemd.mk +0
-6-# need to link with libsystemd which is not in a standard path -# * meson can only replace the RPATH, not append to it -# * the original rpath is thus lost. -# * the original path had been tweaked by buildroot via LDFLAGS to add -# $(HOST_DIR)/lib -# * thus re-tweak rpath after the installation for all binaries thatneed it
Quoted 1 line
package/systemd/systemd.mk HOST_SYSTEMD_DEPENDENCIES = \ · line 865
Quoted 1 line
package/systemd/systemd.mk +0
-1-HOST_SYSTEMD_HOST_TOOLS = busctl journalctl systemctl systemd-*udevadm
Quoted 3 lines
package/systemd/systemd.mk HOST_SYSTEMD_DEPENDENCIES = \
Quoted 3 lines
package/systemd/systemd.mk +0
-3- -define HOST_SYSTEMD_FIX_RPATH - for f in $(addprefix$(HOST_DIR)/bin/,$(HOST_SYSTEMD_HOST_TOOLS)); do \
Quoted 2 lines
package/systemd/systemd.mk HOST_SYSTEMD_DEPENDENCIES = \ · line 870
Quoted 2 lines
package/systemd/systemd.mk +0
-2- [ -e $$f ] || continue; \ - $(HOST_DIR)/bin/patchelf --set-rpath$(HOST_DIR)/lib:$(HOST_DIR)/lib/systemd $${f} \
Quoted 13 lines
Quoted 10 lines
package/systemd/systemd.mk +0
-6- || exit 1; \ - done -endef -HOST_SYSTEMD_POST_INSTALL_HOOKS += HOST_SYSTEMD_FIX_RPATH - $(eval $(meson-package)) $(eval $(host-meson-package)) --2.34.1
Hello James,
Quoted 9 lines
Quoted 5 lines
what issues are you trying to prevent here? buildroot's host tools generally use the rpath to work,
static tools will just blow up filesize, and would only make sense if you want to copy a few of them
to another location.We don't normally need to use patchelf for host tools, figured it would be nice to drop that hack.
The issue is meson not doing the right thing,
Unless you fix or drop meson (whatever is less unlikely), whatever you do is a workaround.
Size shouldn't really matter much for small host tools like these IMO,
Quoted 4 lines
and we should be able to avoid having to install a host libsystemd-shared this way down the line(static binaries are often smaller than shared in aggregate if only a subset of the library functions get used).
I believe systemctl uses almost the entire shared lib, so there aren't any savings likely.
As said I don't consider the patchelf step terrible, and way less intrusive.
Norbert
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
James, All,
On 2022-07-27 16:10 -0600, James Hilliard spake thusly:
Quoted 1 line
This lets us remove the
HOST_SYSTEMD_FIX_RPATHhack.
This will require a lot more explanations than just that.
Please, compare the length of the explanations in 35c11a027c88 (package/systemd: add host variant), that went to extra details about the issue, with your patch that has just one terse line that does not explain anything.
The commit log is not about stating _what_ is done, but _why_ it is. A small note about the _what_ can be needed to summarise it, and what you wrote is enough. But you need to really extend the explanations on _why_ it is correct to now do so.
Which it is not entirely either:
$ readelf -d host/bin/systemctl
[--SNIP--]
0x000000000000001d (RUNPATH) Library runpath: [/usr/lib/systemd:/home/ymorin/dev/buildroot/O/misc/per-package/host-systemd/host/lib]So, this is wrong, because it is going to use my system's systemd libs, not the host ones. Also, it still looks into the per-package directory instead of $(HOST_DIR). This does not prevent it to work, but is semantically incorrect. It will however break in a system that does not have the systemd libraries installed, or has incompatible libraries (e.g. too old or too recent). So, the rpath fixup hook is stil needed.
Maybe you can do for systemctl as was done for the other tools? Or maybe upstream should have a global option to build everything shared or static, instead of one such option for each tool...
Quoted 17 lines
Signed-off-by James Hilliard <[email protected]>--- ...nalctl-allow-statically-linked-build.patch | 68 +++++++++++++++++++ package/systemd/systemd.mk | 28 +++----- 2 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 package/systemd/0002-journalctl-allow-statically-linked-build.patchpackage/systemd/0002-journalctl-allow-statically-linked-build.patch new file +4
-0@@ -0,0 +1,68 @@ +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001 +From: James Hilliard <[email protected]> +Date: Wed, 27 Jul 2022 15:28:09 -0600 +Subject: [PATCH] journalctl: allow statically linked build
package/systemd/0002-journalctl-allow-statically-linked-build.patch line 14
Quoted 10 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +10
-0+ +The journalctl tool may be needed on cross compilation hosts in order +to run --update-catalog against a target rootfs. + +To avoid reliability issues caused by shared linking allow journalctl +to be linked statically. + +Signed-off-by: James Hilliard <[email protected]> +[Upstream status: +https://github.com/systemd/systemd/pull/24140]
That has been accepted now.
We are usually not too fond of feature backports, except maybe when they fix a build/run breakage that we can't easily fix otherwise. But in this case, we do not have a breakage, just ugly code, and the build succeeds, and the system runs. So, I think that this cleanup can very well wait for after we update to an upstream version that has this feature.
package/systemd/0002-journalctl-allow-statically-linked-build.patch HOST_SYSTEMD_CONF_OPTS = \ · line 790
Quoted 11 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +7
-0@@ -781,6 +781,13 @@ HOST_SYSTEMD_CONF_OPTS = \ --libdir=lib \ --sysconfdir=/etc \ --localstatedir=/var \ + -Dlink-udev-shared=false \ + -Dlink-systemctl-shared=false \ + -Dlink-networkd-shared=false \ + -Dlink-timesyncd-shared=false \ + -Dlink-journalctl-shared=false \ + -Dlink-boot-shared=false \ + -Dstandalone-binaries=true \
What is this new 'standalone' mode, and how is it related to statically linking tools?
Quoted 15 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +0
-8-Dmode=release \ -Dutmp=false \ -Dhibernate=false \@@ -854,24 +861,5 @@ HOST_SYSTEMD_DEPENDENCIES = \ HOST_SYSTEMD_NINJA_ENV = DESTDIR=$(HOST_DIR) -# Fix RPATH After installation -# * systemd provides a install_rpath instruction to meson because the binaries -# need to link with libsystemd which is not in a standard path -# * meson can only replace the RPATH, not append to it -# * the original rpath is thus lost. -# * the original path had been tweaked by buildroot via LDFLAGS to add -# $(HOST_DIR)/lib -# * thus re-tweak rpath after the installation for all binaries that need it
package/systemd/0002-journalctl-allow-statically-linked-build.patch HOST_SYSTEMD_DEPENDENCIES = \ · line 874
Quoted 10 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +0
-10-HOST_SYSTEMD_HOST_TOOLS = busctl journalctl systemctl systemd-* udevadm - -define HOST_SYSTEMD_FIX_RPATH - for f in $(addprefix $(HOST_DIR)/bin/,$(HOST_SYSTEMD_HOST_TOOLS)); do \ - [ -e $$f ] || continue; \ - $(HOST_DIR)/bin/patchelf --set-rpath $(HOST_DIR)/lib:$(HOST_DIR)/lib/systemd $${f} \ - || exit 1; \ - done -endef -HOST_SYSTEMD_POST_INSTALL_HOOKS += HOST_SYSTEMD_FIX_RPATH
That we will eventually be able to drop this hook, is very good news, though. But I think that is not urgent, and that we can wait for the next version bump.
Regards,
Yann E. MORIN.
Quoted 9 lines
package/systemd/0002-journalctl-allow-statically-linked-build.patch new file +0
-0$(eval $(meson-package)) $(eval $(host-meson-package))Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
James, All,
On 2022-07-27 16:10 -0600, James Hilliard spake thusly:
Quoted 3 lines
This lets us remove the
HOST_SYSTEMD_FIX_RPATHhack.Signed-off-by James Hilliard <[email protected]>
Given the feedback from Norbert and I, I have now marked this change as rejected in Patchwork.
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot