Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 914008 - sys-apps/systemd-utils-254.3 - clang-16: error: invalid linker name in argument '-fuse-ld=bfd'
Summary: sys-apps/systemd-utils-254.3 - clang-16: error: invalid linker name in argume...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: ARM64 Linux
: Normal normal (vote)
Assignee: Gentoo systemd Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-11 17:13 UTC by Stuart Meya
Modified: 2024-02-24 13:19 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info '=sys-apps/systemd-utils-254.3::gentoo' (emerge--infosys-appssystemd-utils-254-N5FCG.txt,19.15 KB, text/plain)
2023-09-11 17:13 UTC, Stuart Meya
Details
emerge -pqv '=sys-apps/systemd-utils-254.3::gentoo' (emerge-pqvsys-appssystemd-utils-254-EFYN6.txt,235 bytes, text/plain)
2023-09-11 17:14 UTC, Stuart Meya
Details
/var/tmp/portage/sys-apps/systemd-utils-254.3/temp/build.log (sys-apps_systemd_utils_254.3_build.log,899.29 KB, text/plain)
2023-09-11 17:15 UTC, Stuart Meya
Details
Patch to force off the bfd linker and gcc libs from systems-boot (disable_forced_bfd.patch,431 bytes, patch)
2023-09-11 21:46 UTC, Stuart Meya
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Meya 2023-09-11 17:13:21 UTC
Created attachment 870320 [details]
emerge --info '=sys-apps/systemd-utils-254.3::gentoo'

Hi,

it's me again, hunting for bugs on ARM64.

After Grub just does not work out (https://bugs.gentoo.org/911985), I tried using systemd-utils with the "boot" USE flag, to get systemd-boot on my musl LLVM16 VM.

The errors are kinda cryptic and I already asked on the Gentoo Discord, but I thought I might not be the only one with the problem in the future.

 * ERROR: sys-apps/systemd-utils-254.3::gentoo failed (compile phase):
 *   compile failed
 * 
 * Call stack:
 *     ebuild.sh, line  136:  Called src_compile
 *   environment, line 4236:  Called meson-multilib_src_compile
 *   environment, line 2653:  Called multilib-minimal_src_compile
 *   environment, line 2872:  Called multilib_foreach_abi 'multilib-minimal_abi_src_compile'
 *   environment, line 3139:  Called multibuild_foreach_variant '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_compile'
 *   environment, line 2832:  Called _multibuild_run '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_compile'
 *   environment, line 2830:  Called _multilib_multibuild_wrapper 'multilib-minimal_abi_src_compile'
 *   environment, line  668:  Called multilib-minimal_abi_src_compile
 *   environment, line 2866:  Called multilib_src_compile
 *   environment, line 3390:  Called meson_src_compile 'bootctl' 'kernel-install' 'man/bootctl.1' 'man/kernel-install.8' '90-loaderentry.install' 'src/boot/efi/linuxaa64.efi.stub' 'src/boot/efi/systemd-bootaa64.efi' 'systemd-tmpfiles.standalone' 'man/tmpfiles.d.5' 'man/systemd-tmpfiles.8' 'tmpfiles.d/etc.conf' 'tmpfiles.d/static-nodes-permissions.conf' 'tmpfiles.d/var.conf' 'udevadm' 'systemd-hwdb' 'src/udev/ata_id' 'src/udev/cdrom_id' 'src/udev/fido_id' 'src/udev/mtd_probe' 'src/udev/scsi_id' 'src/udev/udev.pc' 'src/udev/v4l_id' 'man/udev.conf.5' 'man/systemd.link.5' 'man/hwdb.7' 'man/udev.7' 'man/systemd-hwdb.8' 'man/systemd-udevd.service.8' 'man/udevadm.8' 'hwdb.d/60-autosuspend-chromiumos.hwdb' 'rules.d/50-udev-default.rules' 'rules.d/60-persistent-storage.rules' 'rules.d/64-btrfs.rules' 'udev:shared_library' 'src/libudev/libudev.pc'
 *   environment, line 2721:  Called die
 * The specific snippet of code:
 *       "$@" || die "compile failed"

I'll might try again via LLVM17 until I get this VM running somehow.

Greets,
Stuart
Comment 1 Stuart Meya 2023-09-11 17:14:23 UTC
Created attachment 870321 [details]
emerge -pqv '=sys-apps/systemd-utils-254.3::gentoo'
Comment 2 Stuart Meya 2023-09-11 17:15:56 UTC
Created attachment 870322 [details]
/var/tmp/portage/sys-apps/systemd-utils-254.3/temp/build.log
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-11 17:32:39 UTC
FAILED: src/boot/efi/linuxaa64.elf.stub 
clang  -o src/boot/efi/linuxaa64.elf.stub src/boot/efi/linuxaa64.elf.stub.p/cpio.c.o src/boot/efi/linuxaa64.elf.stub.p/linux.c.o src/boot/efi/linuxaa64.elf.stub.p/splash.c.o src/boot/efi/linuxaa64.elf.stub.p/stub.c.o -Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector -O2 -pipe -march=native -Wl,-O1 -Wl,--as-needed -Wl,--as-needed -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed -Wl,--start-group src/boot/efi/libefiaa64.a -fuse-ld=bfd -lgcc -Wl,--end-group -nostdlib -static-pie -Wl,--entry=efi_main -Wl,--fatal-warnings -Wl,--no-dynamic-linker -z text -z common-page-size=4096 -z max-page-size=4096 -z noexecstack -z norelro -T/var/tmp/portage/sys-apps/systemd-utils-254.3/work/systemd-stable-254.3/tools/elf2efi.lds -Wl,-z,nopack-relative-relocs -fcf-protection=none -fno-asynchronous-unwind-tables -fno-exceptions -fno-unwind-tables -fno-sanitize=all -Wno-unused-command-line-argument
clang-16: error: invalid linker name in argument '-fuse-ld=bfd'
Comment 4 Mia Neufeld 2023-09-11 18:45:47 UTC
The bfd linker is forced in /src/boot/efi/meson.build

```
efi_c_ld_args = [
        # We only support bfd. gold is going away, lld has issues with LTO on x86
        # and mold does not support linker scripts.
        '-fuse-ld=bfd',
...

Stuart and I have tested a simple patch that removes this line, it builds fine with LLD and -flto=thin, however we haven't done any more actual testing beyond building and more discussion would be needed to actually disable this restriction. (On top of finding out what the issue with LLD was that made them place it in the first place)
Comment 5 Mia Neufeld 2023-09-11 18:59:40 UTC
In regards to the musl issue, it seems my last reply was a bit hasty, as there are further gcc library dependencies, which is relevant as the user was attempting to build the package on a pure musl/llvm system. I'm sorry.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-11 19:01:01 UTC
(In reply to Mia Neufeld from comment #4)
> The bfd linker is forced in /src/boot/efi/meson.build
> 
> ```
> efi_c_ld_args = [
>         # We only support bfd. gold is going away, lld has issues with LTO
> on x86
>         # and mold does not support linker scripts.
>         '-fuse-ld=bfd',
> ...
> 
> Stuart and I have tested a simple patch that removes this line, it builds
> fine with LLD and -flto=thin, however we haven't done any more actual
> testing beyond building and more discussion would be needed to actually
> disable this restriction. (On top of finding out what the issue with LLD was
> that made them place it in the first place)

You need to make sure it actually works at runtime. Building EFI binaries is painful if doing it without a real toolchain. In any case, it's an issue which needs to go upstream.
Comment 7 Stuart Meya 2023-09-11 21:46:04 UTC
(In reply to Sam James from comment #6)
> (In reply to Mia Neufeld from comment #4)
> > The bfd linker is forced in /src/boot/efi/meson.build
> > 
> > ```
> > efi_c_ld_args = [
> >         # We only support bfd. gold is going away, lld has issues with LTO
> > on x86
> >         # and mold does not support linker scripts.
> >         '-fuse-ld=bfd',
> > ...
> > 
> > Stuart and I have tested a simple patch that removes this line, it builds
> > fine with LLD and -flto=thin, however we haven't done any more actual
> > testing beyond building and more discussion would be needed to actually
> > disable this restriction. (On top of finding out what the issue with LLD was
> > that made them place it in the first place)
> 
> You need to make sure it actually works at runtime. Building EFI binaries is
> painful if doing it without a real toolchain. In any case, it's an issue
> which needs to go upstream.

Good evening Sam,

we tested Mias patch with QEMU 7.2 ~arm64 VM based on LLVM16 musl. It's running on a MacBook Pro 14" M2 Pro 2023 with macOS Sonoma 14.0, latest Beta - utilising the UTM app as a frontend for QEMU.

I added Mia's disable_forced_bfd.patch to /etc/portage/patches/sys-apps/systemd-utils/ and compiled systemd-utils with the USE flag "boot". After doing "bootctl --esp-path=/boot/efi install" if went well, just had to do a "emerge --config sys-kernel/gentoo-kernel-bin" for getting the whole configs running.

It booted without problems afterwards.

I see this as a great breakthrough for the following Asahi Kernel Gentoo compatibility. 

Greetings,
Stuart
Comment 8 Stuart Meya 2023-09-11 21:46:56 UTC
Created attachment 870325 [details, diff]
Patch to force off the bfd linker and gcc libs from systems-boot
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-11 21:49:10 UTC
Thanks for the testing.

I at least (although I can't speak for floppym) don't feel comfortable dropping the check here though, given the long tail of bugs we've had here in the past and how brittle it is to build EFI binaries without a proper toolchain (systemd switched from one hack w/ gnu-efi to another one).

The check seems to have been added around https://github.com/systemd/systemd/issues/19005 and https://github.com/systemd/systemd/pull/19037, although the systemd-boot machinery got rewritten a lot since then.

In any case, please file a bug upstream and work with them on allowing LLD if you can identify which changes allow it to now work (presumably LLD gained some support) or perhaps some flags need to be passed with LLD.