FS#75610 - [gnu-efi] [clang] 'plugin needed to handle lto object' when building an EFI binary

Attached to Project: Arch Linux
Opened by Frantisek Sumsal (mrc0mmand) - Monday, 15 August 2022, 13:37 GMT
Last edited by Toolybird (Toolybird) - Tuesday, 17 January 2023, 20:24 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To David Runge (dvzrv)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
In our Arch Linux systemd CI job I recently encountered an issue[0] when building EFI binaries - the build with clang fails with `/usr/sbin/ld: /usr/sbin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../lib64/libefi.a(data.o): plugin needed to handle lto object` - gcc builds are unaffected.

Minimal-ish reproducer:

```
# cat test.c
#include <efi.h>
#include <efilib.h>

__UINTPTR_TYPE__ efi_main(void *a, void *b) {
return (__UINTPTR_TYPE__)ST;
}

## No error with gcc
# gcc -o test.elf -isystem /usr/include/efi -isystem /usr/include/efi/x86_64 -nostdlib -T /usr/lib/elf_x86_64_efi.lds /usr/lib/crt0-efi-x86_64.o -Wl,--no-dynamic-linker test.c -lefi -lgnuefi -lgcc -pie

# clang -o test.elf -isystem /usr/include/efi -isystem /usr/include/efi/x86_64 -nostdlib -T /usr/lib/elf_x86_64_efi.lds /usr/lib/crt0-efi-x86_64.o -Wl,--no-dynamic-linker test.c -lefi -lgnuefi -lgcc -pie
/usr/sbin/ld: /usr/sbin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../lib64/libefi.a(data.o): plugin needed to handle lto object
/usr/sbin/ld: /usr/sbin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../lib64/libefi.a(data.o): plugin needed to handle lto object
/usr/sbin/ld: /tmp/test-da9f04.o: in function `efi_main':
test.c:(.text+0xf): undefined reference to `ST'
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
```

[0] https://github.com/systemd/systemd/issues/24304


Additional info:
* package version(s)
# pacman -Q clang gnu-efi
clang 14.0.6-2
gnu-efi 3.0.15-1

* link to upstream bug report, if any
https://github.com/systemd/systemd/issues/24304
This task depends upon

Closed by  Toolybird (Toolybird)
Tuesday, 17 January 2023, 20:24 GMT
Reason for closing:  Fixed
Additional comments about closing:  gnu-efi 3.0.15-3
Comment by Evangelos Foutras (foutrelis) - Tuesday, 16 August 2022, 08:50 GMT
Seems to be caused by objects getting built in package() with the default CFLAGS (and thus missing -ffat-lto-objects).

Loading...