Skip to contentSkip to conversation

systemd-boot: use ld.bfd as efi-ld even when gold or lld is used in ${LD}

PATCH Superseded Martin Jansa 2 participants 5 messages 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 v2 1/1 systemd-boot: use ld.bfd as efi-ld even when gold or lld is used in ${LD}

* 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

* if someone is using lld or ld.lld in ${LD} then it would fail as well:
https://github.com/systemd/systemd/commit/e39288193fcdf3a36dbc49b78e6c9bf86a764e31

* work around this by always using ld.bfd instead of whatever is set in ${LD}

---
 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..3c24e7ea4d 100644
@@ -19,11 +19,13 @@ objcopy = ${@meson_array('OBJCOPY', d)}
 EOF
 }
 
+EFI_LD = "ld.bfd"
+
 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=${EFI_LD} \
                   -Dman=false \
                   --cross-file ${WORKDIR}/meson-${PN}.cross \
                   "
Signature · 1 line
2.30.2
#2 lore raw
Quoted 18 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

* if someone is using lld or ld.lld in ${LD} then it would fail as well:
  https://github.com/systemd/systemd/commit/e39288193fcdf3a36dbc49b78e6c9bf86a764e31

Quoted 6 lines

* work around this by always using ld.bfd instead of whatever is set in ${LD}

---
 meta/recipes-core/systemd/systemd-boot_249.1.bb | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)

I suspect but haven't confirmed this is probably the cause of:

https://autobuilder.yoctoproject.org/typhoon/#/builders/104/builds/2673/steps/11/logs/stdio

Cheers,

Richard

#3 lore raw

I've tried to reproduce this with:

BB_VERSION           = "1.51.1"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "x86_64-poky-linux"
MACHINE              = "genericx86-64"
DISTRO               = "poky-altcfg"
DISTRO_VERSION       =

"3.3+snapshot-e2e76a4f7f4ff58a51592fdab0e9cbf2a69524bc"
TUNE_FEATURES = "m64 core2"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "master:e2e76a4f7f4ff58a51592fdab0e9cbf2a69524bc"

martin@jama:/OE/build/poky$ git log --oneline | head -n 1
e2e76a4f7f systemd-boot: use ld.bfd as efi-ld even when gold or lld is used
in ${LD}

and it built fine here, not sure what the autobuilder is doing differently, was it failing only for this poky-altcfg build or some other ones as well?

Quoted 52 lines · Richard Purdie
Quoted 2 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 9 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

* if someone is using lld or ld.lld in ${LD} then it would fail as well:

https://github.com/systemd/systemd/commit/e39288193fcdf3a36dbc49b78e6c9bf86a764e31

Quoted 2 lines

* work around this by always using ld.bfd instead of whatever is set in

${LD}

Quoted 5 lines
---
 meta/recipes-core/systemd/systemd-boot_249.1.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I suspect but haven't confirmed this is probably the cause of:

https://autobuilder.yoctoproject.org/typhoon/#/builders/104/builds/2673/steps/11/logs/stdio

Cheers,

Richard

#4 lore raw
Quoted 15 lines · Martin Jansa

I've tried to reproduce this with:

BB_VERSION           = "1.51.1"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "x86_64-poky-linux"
MACHINE              = "genericx86-64"
DISTRO               = "poky-altcfg"
DISTRO_VERSION       = "3.3+snapshot-e2e76a4f7f4ff58a51592fdab0e9cbf2a69524bc" TUNE_FEATURES        = "m64 core2"
TARGET_FPU           = ""
meta
meta-poky
meta-yocto-bsp       = "master:e2e76a4f7f4ff58a51592fdab0e9cbf2a69524bc"

Quoted 5 lines
martin@jama:/OE/build/poky$ git log --oneline | head -n 1
e2e76a4f7f systemd-boot: use ld.bfd as efi-ld even when gold or lld is used in ${LD}

and it built fine here, not sure what the autobuilder is doing differently, was it failing only for this poky-altcfg build or some other ones as well?

It was only that build and removing the patch from the next run made the error disappear. Your config looks like so not sure what is going on...

Cheers,

Richard

#5 lore raw

PATCH v3 1/1 systemd-boot: use ld.bfd as efi-ld even when gold or lld is used in ${LD}

In reply to a message not in the archive

* 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

* if someone is using lld or ld.lld in ${LD} then it would fail as well:
https://github.com/systemd/systemd/commit/e39288193fcdf3a36dbc49b78e6c9bf86a764e31

* work around this by always using ld.bfd instead of whatever is set in ${LD}

* it needs to be prefixed with ${HOST_PREFIX} to match how LD is constructed:

  $ bitbake-getvar -r systemd-boot LD
  #
  # $LD [2 operations]
  #   exported /OE/build/oe-core/openembedded-core/meta/conf/bitbake.conf:523
  #     [export] "1"
  #   set /OE/build/oe-core/openembedded-core/meta/conf/bitbake.conf:523
  #     "${HOST_PREFIX}ld${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
  # pre-expansion value:
  #   "${HOST_PREFIX}ld${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
  export LD="x86_64-oe-linux-ld --sysroot=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/systemd-boot/249.1-r0/recipe-sysroot  "
  $ bitbake-getvar -r systemd-boot EFI_LD
  #
  # $EFI_LD
  #   set /OE/build/oe-core/openembedded-core/meta/recipes-core/systemd/systemd-boot_249.1.bb:23
  #     "${HOST_PREFIX}ld.bfd"
  EFI_LD="x86_64-oe-linux-ld.bfd"

otherwise first ld.bfd it will find will be from HOSTTOOLS_NONFATAL and fail when host's binutils isn't compatible as in:
https://autobuilder.yoctoproject.org/typhoon/#/builders/104/builds/2673/steps/11/logs/stdio

FAILED: src/boot/efi/linuxx64.elf.stub
/home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/hosttools/ld.bfd -o src/boot/efi/linuxx64.elf.stub -T /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -nostdlib -znocombreloc --build-id=sha1 -L /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-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 /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/../lib/x86_64-poky-linux/11.2.0/libgcc.a /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/hosttools/ld.bfd: warning: /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/hosttools/ld.bfd: warning: /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/hosttools/ld.bfd: /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o: unable to initialize decompress status for section .debug_line
/home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/hosttools/ld.bfd: /home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o: unable to initialize decompress status for section .debug_line
/home/pokybuild/yocto-worker/genericx86-64-alt/build/build/tmp/work/core2-64-poky-linux/systemd-boot/249.1-r0/recipe-sysroot/usr/lib/crt0-efi-x86_64.o: file not recognized: File format not recognized

---
 meta/recipes-core/systemd/systemd-boot_249.1.bb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/recipes-core/systemd/systemd-boot_249.1.bb +4 -1
index d767b5bf8d..c93bc3160b 100644
@@ -19,11 +19,14 @@ objcopy = ${@meson_array('OBJCOPY', d)}
 EOF
 }
 
+# need to use ${HOST_PREFIX} here, otherwise ld.bfd could be used from HOSTTOOLS_NONFATAL
+EFI_LD = "${HOST_PREFIX}ld.bfd"
+
 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=${EFI_LD} \
                   -Dman=false \
                   --cross-file ${WORKDIR}/meson-${PN}.cross \
                   "
Signature · 1 line
2.30.2