All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools
@ 2022-07-27 22:10 James Hilliard
  2022-07-28  8:33 ` Norbert Lange
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: James Hilliard @ 2022-07-27 22:10 UTC (permalink / raw)
  To: buildroot; +Cc: James Hilliard, Norbert Lange, Sen Hastings, Yann E . MORIN

This lets us remove the HOST_SYSTEMD_FIX_RPATH hack.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 ...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

diff --git a/package/systemd/0002-journalctl-allow-statically-linked-build.patch b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
new file mode 100644
index 0000000000..98ffb72cca
--- /dev/null
+++ b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
@@ -0,0 +1,68 @@
+From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001
+From: James Hilliard <james.hilliard1@gmail.com>
+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 <james.hilliard1@gmail.com>
+[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
+
diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index 47aaddf849..13348f9358 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -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))
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools
  2022-07-27 22:10 [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools James Hilliard
@ 2022-07-28  8:33 ` Norbert Lange
  2022-07-28  9:01   ` James Hilliard
  2022-07-30 10:22 ` Yann E. MORIN
  2022-08-29 15:37 ` Yann E. MORIN
  2 siblings, 1 reply; 6+ messages in thread
From: Norbert Lange @ 2022-07-28  8:33 UTC (permalink / raw)
  To: James Hilliard; +Cc: Sen Hastings, Yann E . MORIN, buildroot

Am Do., 28. Juli 2022 um 00:11 Uhr schrieb James Hilliard
<james.hilliard1@gmail.com>:
>
> This lets us remove the HOST_SYSTEMD_FIX_RPATH hack.
>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
>  ...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
>
> diff --git a/package/systemd/0002-journalctl-allow-statically-linked-build.patch b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> new file mode 100644
> index 0000000000..98ffb72cca
> --- /dev/null
> +++ b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> @@ -0,0 +1,68 @@
> +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001
> +From: James Hilliard <james.hilliard1@gmail.com>
> +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 <james.hilliard1@gmail.com>
> +[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
> +
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index 47aaddf849..13348f9358 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -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))
> --
> 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
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools
  2022-07-28  8:33 ` Norbert Lange
@ 2022-07-28  9:01   ` James Hilliard
  2022-07-30 19:04     ` Norbert Lange
  0 siblings, 1 reply; 6+ messages in thread
From: James Hilliard @ 2022-07-28  9:01 UTC (permalink / raw)
  To: Norbert Lange; +Cc: Sen Hastings, Yann E . MORIN, buildroot

On Thu, Jul 28, 2022 at 2:33 AM Norbert Lange <nolange79@gmail.com> wrote:
>
> Am Do., 28. Juli 2022 um 00:11 Uhr schrieb James Hilliard
> <james.hilliard1@gmail.com>:
> >
> > This lets us remove the HOST_SYSTEMD_FIX_RPATH hack.
> >
> > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> > ---
> >  ...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
> >
> > diff --git a/package/systemd/0002-journalctl-allow-statically-linked-build.patch b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> > new file mode 100644
> > index 0000000000..98ffb72cca
> > --- /dev/null
> > +++ b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> > @@ -0,0 +1,68 @@
> > +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001
> > +From: James Hilliard <james.hilliard1@gmail.com>
> > +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 <james.hilliard1@gmail.com>
> > +[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
> > +
> > diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> > index 47aaddf849..13348f9358 100644
> > --- a/package/systemd/systemd.mk
> > +++ b/package/systemd/systemd.mk
> > @@ -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))
> > --
> > 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.

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).

>
> 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
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools
  2022-07-27 22:10 [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools James Hilliard
  2022-07-28  8:33 ` Norbert Lange
@ 2022-07-30 10:22 ` Yann E. MORIN
  2022-08-29 15:37 ` Yann E. MORIN
  2 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2022-07-30 10:22 UTC (permalink / raw)
  To: James Hilliard; +Cc: Norbert Lange, Sen Hastings, buildroot

James, All,

On 2022-07-27 16:10 -0600, James Hilliard spake thusly:
> This lets us remove the HOST_SYSTEMD_FIX_RPATH hack.

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...

> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
>  ...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
> 
> diff --git a/package/systemd/0002-journalctl-allow-statically-linked-build.patch b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> new file mode 100644
> index 0000000000..98ffb72cca
> --- /dev/null
> +++ b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> @@ -0,0 +1,68 @@
> +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001
> +From: James Hilliard <james.hilliard1@gmail.com>
> +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 <james.hilliard1@gmail.com>
> +[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.

> @@ -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?

>  	-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

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.

>  $(eval $(meson-package))
>  $(eval $(host-meson-package))
> -- 
> 2.34.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  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
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools
  2022-07-28  9:01   ` James Hilliard
@ 2022-07-30 19:04     ` Norbert Lange
  0 siblings, 0 replies; 6+ messages in thread
From: Norbert Lange @ 2022-07-30 19:04 UTC (permalink / raw)
  To: James Hilliard; +Cc: Sen Hastings, Yann E . MORIN, buildroot


[-- Attachment #1.1: Type: text/plain, Size: 7634 bytes --]

James Hilliard <james.hilliard1@gmail.com> schrieb am Do., 28. Juli 2022,
11:01:

> On Thu, Jul 28, 2022 at 2:33 AM Norbert Lange <nolange79@gmail.com> wrote:
> >
> > Am Do., 28. Juli 2022 um 00:11 Uhr schrieb James Hilliard
> > <james.hilliard1@gmail.com>:
> > >
> > > This lets us remove the HOST_SYSTEMD_FIX_RPATH hack.
> > >
> > > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> > > ---
> > >  ...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
> > >
> > > diff --git
> a/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> > > new file mode 100644
> > > index 0000000000..98ffb72cca
> > > --- /dev/null
> > > +++
> b/package/systemd/0002-journalctl-allow-statically-linked-build.patch
> > > @@ -0,0 +1,68 @@
> > > +From d2dadbdc5618776e07e98baf8795cc8adebf05a1 Mon Sep 17 00:00:00 2001
> > > +From: James Hilliard <james.hilliard1@gmail.com>
> > > +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 <james.hilliard1@gmail.com>
> > > +[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
> > > +
> > > diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> > > index 47aaddf849..13348f9358 100644
> > > --- a/package/systemd/systemd.mk
> > > +++ b/package/systemd/systemd.mk
> > > @@ -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))
> > > --
> > > 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.
>
> 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,
> 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

[-- Attachment #1.2: Type: text/html, Size: 11107 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools
  2022-07-27 22:10 [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools James Hilliard
  2022-07-28  8:33 ` Norbert Lange
  2022-07-30 10:22 ` Yann E. MORIN
@ 2022-08-29 15:37 ` Yann E. MORIN
  2 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2022-08-29 15:37 UTC (permalink / raw)
  To: James Hilliard; +Cc: Norbert Lange, Sen Hastings, buildroot

James, All,

On 2022-07-27 16:10 -0600, James Hilliard spake thusly:
> This lets us remove the HOST_SYSTEMD_FIX_RPATH hack.
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>

Given the feedback from Norbert and I, I have now marked this change as
rejected in Patchwork.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  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
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-29 15:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 22:10 [Buildroot] [PATCH 1/1] package/systemd: use statically linked host tools James Hilliard
2022-07-28  8:33 ` Norbert Lange
2022-07-28  9:01   ` James Hilliard
2022-07-30 19:04     ` Norbert Lange
2022-07-30 10:22 ` Yann E. MORIN
2022-08-29 15:37 ` Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.