diff mbox series

[2/2] shadow: link executables statically for -native variant

Message ID 20240110120948.4140846-2-alex@linutronix.de
State Accepted, archived
Commit 495ff95eae14a91c94187f78a0b30c7957c9b168
Headers show
Series [1/2] shadow: update 4.13 -> 4.14.2 | expand

Commit Message

Alexander Kanavin Jan. 10, 2024, 12:09 p.m. UTC
shadow 4.14.x adds a number of libraries it dynamically links with
(md, bsd, attr). This causes troubles in setscene tasks where
shadow executables are used (such as useradd), as pulling in
the needed dynamic libraries needs unpleasant special-casing.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/conf/distro/include/no-static-libs.inc | 5 +++++
 meta/recipes-extended/shadow/shadow.inc     | 9 +++++++++
 2 files changed, 14 insertions(+)

Comments

Richard Purdie Jan. 10, 2024, 5:50 p.m. UTC | #1
On Wed, 2024-01-10 at 13:09 +0100, Alexander Kanavin wrote:
> shadow 4.14.x adds a number of libraries it dynamically links with
> (md, bsd, attr). This causes troubles in setscene tasks where
> shadow executables are used (such as useradd), as pulling in
> the needed dynamic libraries needs unpleasant special-casing.
> 
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
>  meta/conf/distro/include/no-static-libs.inc | 5 +++++
>  meta/recipes-extended/shadow/shadow.inc     | 9 +++++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/meta/conf/distro/include/no-static-libs.inc b/meta/conf/distro/include/no-static-libs.inc
> index 75359928a14..8898d53d756 100644
> --- a/meta/conf/distro/include/no-static-libs.inc
> +++ b/meta/conf/distro/include/no-static-libs.inc
> @@ -21,6 +21,11 @@ DISABLE_STATIC:pn-libusb1-native = ""
>  # needed by rust
>  DISABLE_STATIC:pn-musl = ""
>  
> +# needed by shadow-native to build static executables, particularly useradd
> +DISABLE_STATIC:pn-attr-native = ""
> +DISABLE_STATIC:pn-libbsd-native = ""
> +DISABLE_STATIC:pn-libmd-native = ""
> +
>  EXTRA_OECONF:append = "${DISABLE_STATIC}"
>  
>  EXTRA_OECMAKE:append:pn-libical = " -DSHARED_ONLY=True"
> diff --git a/meta/recipes-extended/shadow/shadow.inc b/meta/recipes-extended/shadow/shadow.inc
> index c024746d4ff..67346aa5cb1 100644
> --- a/meta/recipes-extended/shadow/shadow.inc
> +++ b/meta/recipes-extended/shadow/shadow.inc
> @@ -47,6 +47,15 @@ EXTRA_OECONF += "--without-libcrack \
>  
>  CFLAGS:append:libc-musl = " -DLIBBSD_OVERLAY"
>  
> +# Force static linking of utilities so we can use from the sysroot/sstate for useradd
> +# without worrying about the dependency libraries being available
> +do_compile:prepend:class-native () {
> +	sed -i -e 's#\(LIBS.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a ${STAGING_LIBDIR}/libmd.a#g' \
> +	       -e 's#\(LIBBSD.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a ${STAGING_LIBDIR}/libmd.a#g' \
> +	       -e 's#\(LIBATTR.*\)-lattr#\1 ${STAGING_LIBDIR}/libattr.a#g' \
> +               ${B}/*/Makefile
> +}
> +
>  NSCDOPT = ""
>  NSCDOPT:class-native = "--without-nscd"
>  NSCDOPT:class-nativesdk = "--without-nscd"

Something isn't quite right:

https://autobuilder.yoctoproject.org/typhoon/#/builders/23/builds/8749
https://autobuilder.yoctoproject.org/typhoon/#/builders/120/builds/3837
https://autobuilder.yoctoproject.org/typhoon/#/builders/117/builds/4219
https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/6301/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/154/builds/1155/steps/13/logs/stdio

:(

I'm going to stop that build.

Cheers,

Richard
Alexander Kanavin Jan. 10, 2024, 6:07 p.m. UTC | #2
Ah, we patch all of Makefiles:

sed ...  ${B}/*/Makefile

This isn't correct; only ${B}/src/Makefile produces executables and
only they need to be statically linked. It did work fine on debian 12,
so I guess newer host gcc throws these errors when linking shared
libraries :-/

I'll reproduce and confirm that.

Alex


On Wed, 10 Jan 2024 at 18:50, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Wed, 2024-01-10 at 13:09 +0100, Alexander Kanavin wrote:
> > shadow 4.14.x adds a number of libraries it dynamically links with
> > (md, bsd, attr). This causes troubles in setscene tasks where
> > shadow executables are used (such as useradd), as pulling in
> > the needed dynamic libraries needs unpleasant special-casing.
> >
> > Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> > ---
> >  meta/conf/distro/include/no-static-libs.inc | 5 +++++
> >  meta/recipes-extended/shadow/shadow.inc     | 9 +++++++++
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/meta/conf/distro/include/no-static-libs.inc b/meta/conf/distro/include/no-static-libs.inc
> > index 75359928a14..8898d53d756 100644
> > --- a/meta/conf/distro/include/no-static-libs.inc
> > +++ b/meta/conf/distro/include/no-static-libs.inc
> > @@ -21,6 +21,11 @@ DISABLE_STATIC:pn-libusb1-native = ""
> >  # needed by rust
> >  DISABLE_STATIC:pn-musl = ""
> >
> > +# needed by shadow-native to build static executables, particularly useradd
> > +DISABLE_STATIC:pn-attr-native = ""
> > +DISABLE_STATIC:pn-libbsd-native = ""
> > +DISABLE_STATIC:pn-libmd-native = ""
> > +
> >  EXTRA_OECONF:append = "${DISABLE_STATIC}"
> >
> >  EXTRA_OECMAKE:append:pn-libical = " -DSHARED_ONLY=True"
> > diff --git a/meta/recipes-extended/shadow/shadow.inc b/meta/recipes-extended/shadow/shadow.inc
> > index c024746d4ff..67346aa5cb1 100644
> > --- a/meta/recipes-extended/shadow/shadow.inc
> > +++ b/meta/recipes-extended/shadow/shadow.inc
> > @@ -47,6 +47,15 @@ EXTRA_OECONF += "--without-libcrack \
> >
> >  CFLAGS:append:libc-musl = " -DLIBBSD_OVERLAY"
> >
> > +# Force static linking of utilities so we can use from the sysroot/sstate for useradd
> > +# without worrying about the dependency libraries being available
> > +do_compile:prepend:class-native () {
> > +     sed -i -e 's#\(LIBS.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a ${STAGING_LIBDIR}/libmd.a#g' \
> > +            -e 's#\(LIBBSD.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a ${STAGING_LIBDIR}/libmd.a#g' \
> > +            -e 's#\(LIBATTR.*\)-lattr#\1 ${STAGING_LIBDIR}/libattr.a#g' \
> > +               ${B}/*/Makefile
> > +}
> > +
> >  NSCDOPT = ""
> >  NSCDOPT:class-native = "--without-nscd"
> >  NSCDOPT:class-nativesdk = "--without-nscd"
>
> Something isn't quite right:
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/23/builds/8749
> https://autobuilder.yoctoproject.org/typhoon/#/builders/120/builds/3837
> https://autobuilder.yoctoproject.org/typhoon/#/builders/117/builds/4219
> https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/6301/steps/14/logs/stdio
> https://autobuilder.yoctoproject.org/typhoon/#/builders/154/builds/1155/steps/13/logs/stdio
>
> :(
>
> I'm going to stop that build.
>
> Cheers,
>
> Richard
>
>
diff mbox series

Patch

diff --git a/meta/conf/distro/include/no-static-libs.inc b/meta/conf/distro/include/no-static-libs.inc
index 75359928a14..8898d53d756 100644
--- a/meta/conf/distro/include/no-static-libs.inc
+++ b/meta/conf/distro/include/no-static-libs.inc
@@ -21,6 +21,11 @@  DISABLE_STATIC:pn-libusb1-native = ""
 # needed by rust
 DISABLE_STATIC:pn-musl = ""
 
+# needed by shadow-native to build static executables, particularly useradd
+DISABLE_STATIC:pn-attr-native = ""
+DISABLE_STATIC:pn-libbsd-native = ""
+DISABLE_STATIC:pn-libmd-native = ""
+
 EXTRA_OECONF:append = "${DISABLE_STATIC}"
 
 EXTRA_OECMAKE:append:pn-libical = " -DSHARED_ONLY=True"
diff --git a/meta/recipes-extended/shadow/shadow.inc b/meta/recipes-extended/shadow/shadow.inc
index c024746d4ff..67346aa5cb1 100644
--- a/meta/recipes-extended/shadow/shadow.inc
+++ b/meta/recipes-extended/shadow/shadow.inc
@@ -47,6 +47,15 @@  EXTRA_OECONF += "--without-libcrack \
 
 CFLAGS:append:libc-musl = " -DLIBBSD_OVERLAY"
 
+# Force static linking of utilities so we can use from the sysroot/sstate for useradd
+# without worrying about the dependency libraries being available
+do_compile:prepend:class-native () {
+	sed -i -e 's#\(LIBS.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a ${STAGING_LIBDIR}/libmd.a#g' \
+	       -e 's#\(LIBBSD.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a ${STAGING_LIBDIR}/libmd.a#g' \
+	       -e 's#\(LIBATTR.*\)-lattr#\1 ${STAGING_LIBDIR}/libattr.a#g' \
+               ${B}/*/Makefile
+}
+
 NSCDOPT = ""
 NSCDOPT:class-native = "--without-nscd"
 NSCDOPT:class-nativesdk = "--without-nscd"