Skip to contentSkip to conversation

systemd-boot: use ld.bfd as efi-ld when gold is being used by default with ld-is-gold

PATCH In review Martin Jansa 4 participants 5 messages Aug 3, 2021 – Aug 4, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 systemd-boot: use ld.bfd as efi-ld when gold is being used by default with ld-is-gold

* since the upgrade to 249.1 in:
https://git.openembedded.org/openembedded-core/commit/?id=323ec445dfe22860cd450c303db5ed8fcb4e791c
the builds with ld-is-gold are failing with:

[17/21] Generating linuxx64.elf.stub with a custom command
FAILED: src/boot/efi/linuxx64.elf.stub
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld -o src/boot/efi/linuxx64.elf.stub -T /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -nostdlib -znocombreloc --build-id=sha1 -L /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o src/boot/efi/string-util-fundamental.c.o src/boot/efi/disk.c.o src/boot/efi/graphics.c.o src/boot/efi/measure.c.o src/boot/efi/pe.c.o src/boot/efi/secure-boot.c.o src/boot/efi/util.c.o src/boot/efi/linux.c.o src/boot/efi/splash.c.o src/boot/efi/stub.c.o -lefi -lgnuefi /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/../lib/x86_64-oe-linux/11.2.0/libgcc.a /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld: internal error in segment_precedes, at ../../gold/layout.cc:3721
[18/21] Generating boot.c.o with a custom command
ninja: build stopped: subcommand failed.
WARNING: exit code 1 from a shell command.

as reported in:
https://lists.openembedded.org/g/openembedded-core/message/154246

work around this by using ld.bfd when ld-is-gold is in DISTRO_FEATURES

---
 meta/recipes-core/systemd/systemd-boot_249.1.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-core/systemd/systemd-boot_249.1.bb +3 -1
index d767b5bf8d..18f4fe55ce 100644
@@ -19,11 +19,13 @@ objcopy = ${@meson_array('OBJCOPY', d)}
 EOF
 }
 
+EFI_LD = "${@d.getVar('LD').split()[0]}"
+
 EXTRA_OEMESON += "-Defi=true \
                   -Dgnu-efi=true \
                   -Defi-includedir=${STAGING_INCDIR}/efi \
                   -Defi-libdir=${STAGING_LIBDIR} \
-                  -Defi-ld=${@ d.getVar('LD').split()[0]} \
+                  -Defi-ld=${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld.bfd', '${EFI_LD}', d)} \
                   -Dman=false \
                   --cross-file ${WORKDIR}/meson-${PN}.cross \
                   "
Signature · 1 line
2.30.2
#2 lore raw
Quoted 29 lines · Martin Jansa

* since the upgrade to 249.1 in:
https://git.openembedded.org/openembedded-core/commit/?id=323ec445dfe22860cd450c303db5ed8fcb4e791c
the builds with ld-is-gold are failing with:

[17/21] Generating linuxx64.elf.stub with a custom command
FAILED: src/boot/efi/linuxx64.elf.stub
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld -o src/boot/efi/linuxx64.elf.stub -T /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -nostdlib -znocombreloc --build-id=sha1 -L /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o src/boot/efi/string-util-fundamental.c.o src/boot/efi/disk.c.o src/boot/efi/graphics.c.o src/boot/efi/measure.c.o src/boot/efi/pe.c.o src/boot/efi/secure-boot.c.o src/boot/efi/util.c.o src/boot/efi/linux.c.o src/boot/efi/splash.c.o src/boot/efi/stub.c.o -lefi -lgnuefi /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/../lib/x86_64-oe-linux/11.2.0/libgcc.a /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld: internal error in segment_precedes, at ../../gold/layout.cc:3721
[18/21] Generating boot.c.o with a custom command
ninja: build stopped: subcommand failed.
WARNING: exit code 1 from a shell command.

as reported in:
https://lists.openembedded.org/g/openembedded-core/message/154246

work around this by using ld.bfd when ld-is-gold is in DISTRO_FEATURES

---
 meta/recipes-core/systemd/systemd-boot_249.1.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-core/systemd/systemd-boot_249.1.bb +0 -0
index d767b5bf8d..18f4fe55ce 100644
@@ -19,11 +19,13 @@ objcopy = ${@meson_array('OBJCOPY', d)}
 EOF

meta/recipes-core/systemd/systemd-boot_249.1.bb objcopy = ${@meson_array('OBJCOPY', d)} · line 28

Quoted 10 lines
meta/recipes-core/systemd/systemd-boot_249.1.bb +3 -1
 }
 
+EFI_LD = "${@d.getVar('LD').split()[0]}"
+
 EXTRA_OEMESON += "-Defi=true \
                   -Dgnu-efi=true \
                   -Defi-includedir=${STAGING_INCDIR}/efi \
                   -Defi-libdir=${STAGING_LIBDIR} \
-                  -Defi-ld=${@ d.getVar('LD').split()[0]} \
+                  -Defi-ld=${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld.bfd', '${EFI_LD}', d)} \

Could this just be set to ld.bfd in all cases?

#3 lore raw

Probably as lld isn't supported as well:
https://github.com/systemd/systemd/commit/e39288193fcdf3a36dbc49b78e6c9bf86a764e31

Quoted 60 lines · Andre McCurdy
Quoted 3 lines · Martin Jansa

* since the upgrade to 249.1 in:

https://git.openembedded.org/openembedded-core/commit/?id=323ec445dfe22860cd450c303db5ed8fcb4e791c

Quoted 5 lines

the builds with ld-is-gold are failing with:

[17/21] Generating linuxx64.elf.stub with a custom command
FAILED: src/boot/efi/linuxx64.elf.stub

/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld
-o src/boot/efi/linuxx64.elf.stub -T /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -nostdlib -znocombreloc --build-id=sha1 -L /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o src/boot/efi/string-util-fundamental.c.o src/boot/efi/disk.c.o
src/boot/efi/graphics.c.o src/boot/efi/measure.c.o src/boot/efi/pe.c.o
src/boot/efi/secure-boot.c.o src/boot/efi/util.c.o src/boot/efi/linux.c.o
src/boot/efi/splash.c.o src/boot/efi/stub.c.o -lefi -lgnuefi /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/../lib/x86_64-oe-linux/11.2.0/libgcc.a

Quoted 1 line

/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld:
internal error in segment_precedes, at ../../gold/layout.cc:3721

Quoted 7 lines

[18/21] Generating boot.c.o with a custom command
ninja: build stopped: subcommand failed.
WARNING: exit code 1 from a shell command.

as reported in:
https://lists.openembedded.org/g/openembedded-core/message/154246

Review

Quoted 8 lines

work around this by using ld.bfd when ld-is-gold is in DISTRO_FEATURES

---
 meta/recipes-core/systemd/systemd-boot_249.1.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/recipes-core/systemd/systemd-boot_249.1.bb

Quoted 5 lines

index d767b5bf8d..18f4fe55ce 100644

meta/recipes-core/systemd/systemd-boot_249.1.bb +0 -0
@@ -19,11 +19,13 @@ objcopy = ${@meson_array('OBJCOPY', d)}
 EOF

meta/recipes-core/systemd/systemd-boot_249.1.bb objcopy = ${@meson_array('OBJCOPY', d)} · line 28

Quoted 10 lines
meta/recipes-core/systemd/systemd-boot_249.1.bb +3 -1
 }
 
+EFI_LD = "${@d.getVar('LD').split()[0]}"
+
 EXTRA_OEMESON += "-Defi=true \
                   -Dgnu-efi=true \
                   -Defi-includedir=${STAGING_INCDIR}/efi \
                   -Defi-libdir=${STAGING_LIBDIR} \
-                  -Defi-ld=${@ d.getVar('LD').split()[0]} \
+                  -Defi-ld=${@bb.utils.contains('DISTRO_FEATURES',

'ld-is-gold', 'ld.bfd', '${EFI_LD}', d)} \

Could this just be set to ld.bfd in all cases?

#4 lore raw

I found I sent this email to wrong list, let me CC to it.

Quoted 5 lines · Martin Jansa

Probably as lld isn't supported as well:
https://github.com/systemd/systemd/commit/e39288193fcdf3a36dbc49b78e6c9bf86a764e31

You can’t use systemd in Android of course, I decide to ignore those packages won’t be used for Android vendor partition.

Quoted 33 lines
Quoted 33 lines · Andre McCurdy
Quoted 31 lines · Martin Jansa

* since the upgrade to 249.1 in:
https://git.openembedded.org/openembedded-core/commit/?id=323ec445dfe22860cd450c303db5ed8fcb4e791c
the builds with ld-is-gold are failing with:

[17/21] Generating linuxx64.elf.stub with a custom command
FAILED: src/boot/efi/linuxx64.elf.stub
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld -o src/boot/efi/linuxx64.elf.stub -T /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -nostdlib -znocombreloc --build-id=sha1 -L /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o src/boot/efi/string-util-fundamental.c.o src/boot/efi/disk.c.o src/boot/efi/graphics.c.o src/boot/efi/measure.c.o src/boot/efi/pe.c.o src/boot/efi/secure-boot.c.o src/boot/efi/util.c.o src/boot/efi/linux.c.o src/boot/efi/splash.c.o src/boot/efi/stub.c.o -lefi -lgnuefi /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/../lib/x86_64-oe-linux/11.2.0/libgcc.a /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld: internal error in segment_precedes, at ../../gold/layout.cc:3721
[18/21] Generating boot.c.o with a custom command
ninja: build stopped: subcommand failed.
WARNING: exit code 1 from a shell command.

as reported in:
https://lists.openembedded.org/g/openembedded-core/message/154246

work around this by using ld.bfd when ld-is-gold is in DISTRO_FEATURES

---
 meta/recipes-core/systemd/systemd-boot_249.1.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-core/systemd/systemd-boot_249.1.bb +0 -0
index d767b5bf8d..18f4fe55ce 100644
@@ -19,11 +19,13 @@ objcopy = ${@meson_array('OBJCOPY', d)}
 EOF
 }
 
Quoted 10 lines
Quoted 10 lines

meta/recipes-core/systemd/systemd-boot_249.1.bb objcopy = ${@meson_array('OBJCOPY', d)} · line 28

Quoted 8 lines
meta/recipes-core/systemd/systemd-boot_249.1.bb +3 -1
+EFI_LD = "${@d.getVar('LD').split()[0]}"
+
 EXTRA_OEMESON += "-Defi=true \
                   -Dgnu-efi=true \
                   -Defi-includedir=${STAGING_INCDIR}/efi \
                   -Defi-libdir=${STAGING_LIBDIR} \
-                  -Defi-ld=${@ d.getVar('LD').split()[0]} \
+                  -Defi-ld=${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld.bfd', '${EFI_LD}', d)} \

Could this just be set to ld.bfd in all cases?

https://github.com/android/ndk/issues/1288
Android has dropped the support for gold linker and it has been marked as deprecated for a long time. I just heard that Gstreamer doesn’t support lld linker but I prefer to solve it in Gstreamer.

Quoted 3 lines
#5 lore raw
Quoted 38 lines · Randy Li

I found I sent this email to wrong list, let me CC to it.

Quoted 3 lines · On Aug 4, 2021, at 3:28 AM, Martin Jansa <[email protected]…

Probably as lld isn't supported as well:
https://github.com/systemd/systemd/commit/e39288193fcdf3a36dbc49b78e6c9bf86a764e31 <https://github.com/systemd/systemd/commit/e39288193fcdf3a36dbc49b78e6c9bf86a764e31>

You can’t use systemd in Android of course, I decide to ignore those packages won’t be used for Android vendor partition.

Quoted 30 lines · On Tue, Aug 3, 2021 at 9:19 PM Andre McCurdy <[email protected]…
    On Tue, Aug 3, 2021 at 12:04 PM Martin Jansa
    <[email protected] <mailto:[email protected]>> wrote:
    >
    > * since the upgrade to 249.1 in:
    >
    https://git.openembedded.org/openembedded-core/commit/?id=323ec445dfe22860cd450c303db5ed8fcb4e791c
    <https://git.openembedded.org/openembedded-core/commit/?id=323ec445dfe22860cd450c303db5ed8fcb4e791c>
    >   the builds with ld-is-gold are failing with:
    >
    >   [17/21] Generating linuxx64.elf.stub with a custom command
    >   FAILED: src/boot/efi/linuxx64.elf.stub
    > 
     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld
    -o src/boot/efi/linuxx64.elf.stub -T
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/elf_x86_64_efi.lds
    -shared -Bsymbolic -nostdlib -znocombreloc --build-id=sha1 -L
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o
    src/boot/efi/string-util-fundamental.c.o src/boot/efi/disk.c.o
    src/boot/efi/graphics.c.o src/boot/efi/measure.c.o
    src/boot/efi/pe.c.o src/boot/efi/secure-boot.c.o
    src/boot/efi/util.c.o src/boot/efi/linux.c.o
    src/boot/efi/splash.c.o src/boot/efi/stub.c.o -lefi -lgnuefi
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/../lib/x86_64-oe-linux/11.2.0/libgcc.a
    > 
     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-ld:
    internal error in segment_precedes, at ../../gold/layout.cc:3721
    <http://layout.cc:3721>

Yes I am seeing it too on OE jenkins
this is a gold bug ofcourse, but someone has to reduce this to a testcase and report in binutils bugzilla

Quoted 55 lines
Quoted 36 lines
Quoted 6 lines

   [18/21] Generating boot.c.o with a custom command
   ninja: build stopped: subcommand failed.
   WARNING: exit code 1 from a shell command.

   as reported in:

    https://lists.openembedded.org/g/openembedded-core/message/154246
    <https://lists.openembedded.org/g/openembedded-core/message/154246>
    >
    >   work around this by using ld.bfd when ld-is-gold is in
    DISTRO_FEATURES
    >
    > Signed-off-by: Martin Jansa <[email protected]
    <mailto:[email protected]>>
    > ---
    >  meta/recipes-core/systemd/systemd-boot_249.1.bb
    <http://systemd-boot_249.1.bb> | 4 +++-
    >  1 file changed, 3 insertions(+), 1 deletion(-)
    >
    > diff --git a/meta/recipes-core/systemd/systemd-boot_249.1.bb
    <http://systemd-boot_249.1.bb>
    b/meta/recipes-core/systemd/systemd-boot_249.1.bb
    <http://systemd-boot_249.1.bb>
    > index d767b5bf8d..18f4fe55ce 100644
    > --- a/meta/recipes-core/systemd/systemd-boot_249.1.bb
    <http://systemd-boot_249.1.bb>
    > +++ b/meta/recipes-core/systemd/systemd-boot_249.1.bb
    <http://systemd-boot_249.1.bb>
    > @@ -19,11 +19,13 @@ objcopy = ${@meson_array('OBJCOPY', d)}
    >  EOF
    >  }
    >
    > +EFI_LD = "${@d.getVar('LD').split()[0]}"
    > +
    >  EXTRA_OEMESON += "-Defi=true \
    >                    -Dgnu-efi=true \
Quoted 9 lines
    >                    -Defi-includedir=${STAGING_INCDIR}/efi \
    >                    -Defi-libdir=${STAGING_LIBDIR} \
    > -                  -Defi-ld=${@ d.getVar('LD').split()[0]} \
    > +                  -Defi-ld=${@bb.utils.contains
    <mailto:Defi-ld=${@bb.utils.contains>('DISTRO_FEATURES',
    'ld-is-gold', 'ld.bfd', '${EFI_LD}', d)} \

    Could this just be set to ld.bfd in all cases?

https://github.com/android/ndk/issues/1288 <https://github.com/android/ndk/issues/1288>
Android has dropped the support for gold linker and it has been marked as deprecated for a long time. I just heard that Gstreamer doesn’t support lld linker but I prefer to solve it in Gstreamer.

Quoted 3 lines