Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 914606 - sys-boot/gnu-efi-3.0.17: error: expected the entry size (clang)
Summary: sys-boot/gnu-efi-3.0.17: error: expected the entry size (clang)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Mike Gilbert
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-24 16:53 UTC by Violet Purcell
Modified: 2024-04-23 19:42 UTC (History)
3 users (show)

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


Attachments
build.log (build.log,121.64 KB, text/x-log)
2023-09-24 16:53 UTC, Violet Purcell
Details
working build log for clang-first system (sys-boot:gnu-efi-3.0.17:20240102-114842.log,84.49 KB, text/x-log)
2024-01-02 12:03 UTC, Fabio Scaccabarozzi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Violet Purcell 2023-09-24 16:53:09 UTC
Created attachment 871254 [details]
build.log

Compilation fails on lib/ctors.S with an error I do not understand.

emerge --info sys-boot/gnu-efi:
Portage 3.0.51 (python 3.12.0-candidate-3, default/linux/amd64/23.0/musl/llvm, [unavailable], musl-1.2.4-r1, 6.5.4-gentoo-dist-hardened x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-6.5.4-gentoo-dist-hardened-x86_64-AMD_Ryzen_7_7700X_8-Core_Processor-with-libc
KiB Mem:    31975068 total,  21524176 free
KiB Swap:          0 total,         0 free
Head commit of repository gentoo: c87b4b764db4fcd59ce9aa092e1c1e88d7ced6dd

Head commit of repository guru: ef225a96c51485f1215aa55cc1f84ca0ef0c6473

Head commit of repository haskell: 8ea2a2b811770010ae0cfde43f40251e43551be0

Head commit of repository mv: 1a2152bd73d9b813c4777be29bb61b7da8db28ec

Head commit of repository vimproved: f774f156f38b5ee8538d8447cdb9f91f293f97b8

sh mksh 59c
ld LLD 17.0.1 (compatible with GNU linkers)
ccache version 4.8.3 [disabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p15-r6::gentoo
dev-lang/perl:             5.38.0-r1::gentoo
dev-lang/python:           3.11.5::gentoo, 3.12.0_rc3::gentoo
dev-lang/rust:             1.72.0-r1::vimproved
dev-util/ccache:           4.8.3::gentoo
dev-util/cmake:            3.27.6-r1::gentoo
dev-util/meson:            1.2.1-r1::gentoo
sys-apps/baselayout:       2.14::gentoo
sys-apps/openrc:           0.50::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/autoconf:        2.13-r8::gentoo, 2.71-r7::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           16.0.6::gentoo, 17.0.1::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             16.0.6::gentoo, 17.0.1::gentoo
sys-devel/llvm:            16.0.6::gentoo, 17.0.1::gentoo
sys-devel/make:            4.4.1-r1::gentoo
sys-kernel/linux-headers:  6.5::gentoo (virtual/os-headers)
sys-libs/musl:             1.2.4-r1::vimproved
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo/gentoo.git
    priority: -1000
    volatile: False

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo/guru.git
    masters: gentoo
    volatile: False

haskell
    location: /var/db/repos/haskell
    sync-type: git
    sync-uri: https://github.com/gentoo-haskell/gentoo-haskell.git
    masters: gentoo
    volatile: False

mv
    location: /var/db/repos/mv
    sync-type: git
    sync-uri: https://github.com/vaeth/mv-overlay.git
    masters: gentoo
    volatile: False

vimproved
    location: /var/db/repos/vimproved
    sync-type: git
    sync-uri: https://codeberg.org/vimproved/overlay.git
    masters: gentoo
    volatile: False

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
ADDR2LINE="llvm-addr2line"
AR="llvm-ar"
AS="clang -c"
CBUILD="x86_64-gentoo-linux-musl"
CC="clang"
CFLAGS="-march=znver4 -O3 -pipe -flto=thin"
CHOST="x86_64-gentoo-linux-musl"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/sandbox.d"
CPP="clang-cpp"
CXX="clang++"
CXXFLAGS="-march=znver4 -O3 -pipe -flto=thin"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="charset.alias /usr/share/locale/locale.alias"
LANG="C.UTF-8"
LD="ld.lld"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,--as-needed"
LEX="reflex"
LINGUAS=""
MAKEOPTS="-j16"
NM="llvm-nm"
OBJCOPY="llvm-objcopy"
OBJDUMP="llvm-objdump"
PKGDIR="/var/cache/binpkgs"
PORTAGE_COMPRESS="gzip"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
RANLIB="llvm-ranlib"
READELF="llvm-readelf"
RUSTFLAGS="-C target-cpu=znver4"
SHELL="/bin/bash"
STRINGS="llvm-strings"
STRIP="llvm-strip"
USE="amd64 bzip2 cet clang crypt dist-kernel hardened iconv ipv6 libtirpc llvm-libunwind lzma modules-sign ncurses nptl pam pcre pie readline seccomp secureboot ssl ssp test-rust unicode xattr xtpax zlib zstd" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 avx512f avx512dq avx512cd avx512bw avx512vl avx512vbmi f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="X86" LUA_SINGLE_TARGET="luajit" LUA_TARGETS="luajit" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_11 python3_12" RUBY_TARGETS="ruby32" VIDEO_CARDS="amdgpu radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
YACC="byacc"
Unset:  ARFLAGS, ASFLAGS, CCLD, CONFIG_SHELL, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SIZE, YFLAGS

=================================================================
                        Package Settings
=================================================================

sys-boot/gnu-efi-3.0.15::gentoo was built with the following:
USE="(-custom-cflags)"
CFLAGS=""
LDFLAGS=""
Comment 1 Mike Gilbert gentoo-dev 2023-09-25 14:16:55 UTC
Which version of clang is being used here? I see you have 2 versions installed.
Comment 2 Violet Purcell 2023-09-27 01:44:05 UTC
(In reply to Mike Gilbert from comment #1)
> Which version of clang is being used here? I see you have 2 versions
> installed.

Clang 17, however the same error is present when using CC="clang-16".
Comment 3 Chris Pritchard 2023-11-13 11:32:35 UTC
There seems to be some clue here: https://github.com/kraj/meta-clang/blob/master/conf/nonclangable.conf

in that they've added the following:


# TOPDIR/build/tmp/work/core2-32-yoe-linux/gnu-efi/3.0.17-r0/gnu-efi-3.0.17//lib/ctors.S:11:41: error: expected the entry size
# .section .init_array, "aM", @init_array
#                                        ^
CFLAGS:append:pn-gnu-efi:toolchain-clang = " -no-integrated-as"

I've tried adding that to Make.defaults via a user patch, and changing both CC and BULDCC to "clang -no-integrated-as". I've also tried changing AS from AS=llvm-as to AS=as but none of these seem to work.
Comment 4 Chris Pritchard 2023-11-13 11:53:56 UTC
I've also done some more digging, gnu-efi-3.0.15 builds fine, and it looks to be that the ctors.S file was added in 3.0.17. Looks like the GNU assembler accepts these without a defined size but the LLVM assembler doesn't. Unfortunately that's where my expertise ends...
Comment 5 Violet Purcell 2023-11-13 14:48:25 UTC
(In reply to Chris Pritchard from comment #4)
> I've also done some more digging, gnu-efi-3.0.15 builds fine, and it looks
> to be that the ctors.S file was added in 3.0.17. Looks like the GNU
> assembler accepts these without a defined size but the LLVM assembler
> doesn't. Unfortunately that's where my expertise ends...


According to https://sourceware.org/binutils/docs/as/Section.html, the entsize argument is supposed to be required by GNU AS as well, but clearly this isn't enforced.

> If flags contains the M symbol then the type argument must be specified as well as an extra argument—entsize—like this: 
> .section name , "flags"M, @type, entsize
Comment 6 Violet Purcell 2023-11-13 14:51:04 UTC
Seems like this was already fixed upstream actually, will backport.
https://sourceforge.net/p/gnu-efi/code/ci/97499a0cf265bf2d515bfcab99349ce00ecf2662/
Comment 7 Chris Pritchard 2023-11-13 15:10:45 UTC
(In reply to Violet Purcell from comment #6)
> Seems like this was already fixed upstream actually, will backport.
> https://sourceforge.net/p/gnu-efi/code/ci/
> 97499a0cf265bf2d515bfcab99349ce00ecf2662/

Had a quick look at applying this as a user patch, I now get a completely new error:

ld.lld: error: section: .dynamic is not contiguous with other relro sections
make[1]: *** [/var/tmp/portage/sys-boot/gnu-efi-3.0.17/work/gnu-efi-3.0.17//apps/../Make.rules:49: t.so] Error 1
rm t.o
make[1]: Leaving directory '/var/tmp/portage/sys-boot/gnu-efi-3.0.17/work/gnu-efi-3.0.17/ia32/apps'
make: *** [Makefile:82: apps] Error 2
Comment 8 Violet Purcell 2023-11-13 18:06:12 UTC
(In reply to Chris Pritchard from comment #7)
> (In reply to Violet Purcell from comment #6)
> > Seems like this was already fixed upstream actually, will backport.
> > https://sourceforge.net/p/gnu-efi/code/ci/
> > 97499a0cf265bf2d515bfcab99349ce00ecf2662/
> 
> Had a quick look at applying this as a user patch, I now get a completely
> new error:
> 
> ld.lld: error: section: .dynamic is not contiguous with other relro sections
> make[1]: ***
> [/var/tmp/portage/sys-boot/gnu-efi-3.0.17/work/gnu-efi-3.0.17//apps/../Make.
> rules:49: t.so] Error 1
> rm t.o
> make[1]: Leaving directory
> '/var/tmp/portage/sys-boot/gnu-efi-3.0.17/work/gnu-efi-3.0.17/ia32/apps'
> make: *** [Makefile:82: apps] Error 2

Yep, same here. Haven't had the time to look into it yet.
Comment 9 Lunarequest 2023-12-23 11:06:21 UTC
I looked into this issue and it seem the llvm toolchain defaults to `-zrelro` where as bfd defaults to `-znorelro` I have not been able to make gnu-efi use my own cflags so if someone could test with these it should make it possible to make gnu-efi  build
Comment 10 Fabio Scaccabarozzi 2024-01-02 12:03:05 UTC
Created attachment 881261 [details]
working build log for clang-first system

I have backported the referenced patch manually (I couldn't find a way to download it) and it seems to work for me.

I have a clang-first system though, perhaps that plays a role. I have attached the working build log in case you want to check the actual build commands.


This is how my system is set up w.r.t. Clang/LLVM:

[ebuild   R    ] dev-libs/libffi-3.4.4-r2:0/8::gentoo  USE="test -debug (-exec-static-trampoline) -pax-kernel -static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R   ~] sys-devel/llvm-common-17.0.6::gentoo  USE="verify-sig -emacs" 0 KiB
[ebuild   R   ~] sys-devel/llvm-17.0.6:17::gentoo  USE="binutils-plugin libffi ncurses verify-sig xml zstd -debug -debuginfod -doc -exegesis -libedit -test -xar -z3" ABI_X86="32 (64) (-x32)" LLVM_TARGETS="(AArch64) (AMDGPU) (ARM) (AVR) (BPF) (Hexagon) (Lanai) (LoongArch) (MSP430) (Mips) (NVPTX) (PowerPC) (RISCV) (Sparc) (SystemZ) (VE) (WebAssembly) (X86) (XCore) -ARC -CSKY -DirectX -M68k -SPIRV -Xtensa" 0 KiB
[ebuild   R   ~] sys-apps/hwloc-2.9.3:0/15::gentoo  USE="cairo cpuid pci svg udev xml -X -cuda -debug -nvml -static-libs -valgrind" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="-nvidia" 0 KiB
[ebuild   R   ~] dev-util/spirv-llvm-translator-17.0.0:17::gentoo  USE="-test" 0 KiB
[ebuild   R   ~] sys-devel/lld-17.0.6:17::gentoo  USE="test verify-sig zstd -debug" 0 KiB
[ebuild   R   ~] sys-devel/clang-common-17.0.6-r1::gentoo  USE="default-compiler-rt default-libcxx default-lld hardened llvm-libunwind verify-sig" 0 KiB
[ebuild   R   ~] sys-devel/clang-17.0.6:17::gentoo  USE="extra (pie) static-analyzer verify-sig xml -debug -doc (-ieee-long-double) -test" ABI_X86="32 (64) (-x32)" LLVM_TARGETS="(AArch64) (AMDGPU) (ARM) (AVR) (BPF) (Hexagon) (Lanai) (LoongArch) (MSP430) (Mips) (NVPTX) (PowerPC) (RISCV) (Sparc) (SystemZ) (VE) (WebAssembly) (X86) (XCore) -ARC -CSKY -DirectX -M68k -SPIRV -Xtensa" PYTHON_SINGLE_TARGET="python3_11 -python3_10 -python3_12" 0 KiB
[ebuild   R   ~] sys-libs/compiler-rt-17.0.6:17::gentoo  USE="clang test verify-sig -debug" ABI_X86="32 (64)" 0 KiB
[ebuild   R   ~] sys-libs/compiler-rt-sanitizers-17.0.6:17::gentoo  USE="asan cfi clang dfsan gwp-asan hwasan libfuzzer lsan memprof msan orc profile safestack scudo tsan ubsan verify-sig xray -debug (-shadowcallstack) -test" ABI_X86="32 (64)" 0 KiB
[ebuild   R   ~] sys-libs/libcxxabi-17.0.6::gentoo  USE="clang static-libs test verify-sig" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R   ~] sys-libs/libomp-17.0.6:0/17::gentoo  USE="hwloc offload test verify-sig -debug -gdb-plugin -ompt" ABI_X86="32 (64) (-x32)" LLVM_TARGETS="AMDGPU -NVPTX" PYTHON_SINGLE_TARGET="python3_11 -python3_10 -python3_12" 0 KiB
[ebuild   R   ~] dev-libs/libclc-17.0.6::gentoo  USE="spirv verify-sig" VIDEO_CARDS="radeonsi -nvidia -r600" 0 KiB
[ebuild   R   ~] dev-util/lldb-17.0.6:0/17::gentoo  USE="libedit lzma ncurses verify-sig xml -debug -python -test" PYTHON_SINGLE_TARGET="python3_11 -python3_10 -python3_12" 0 KiB
[ebuild   R   ~] sys-libs/libcxx-17.0.6::gentoo  USE="clang (libcxxabi) static-libs verify-sig -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R   ~] sys-devel/clang-runtime-17.0.6:17::gentoo  USE="compiler-rt libcxx openmp sanitize" ABI_X86="32 (64) (-x32)" 0 KiB

emerge --info (relevant parts):
AR="llvm-ar"
CBUILD="x86_64-pc-linux-gnu"
CC="clang-17"
CFLAGS="-O3 -march=native -pipe -glldb -flto=thin -fwhole-program-vtables -gline-tables-only"
CHOST="x86_64-pc-linux-gnu"
CXX="clang++-17"
CXXFLAGS="-O3 -march=native -pipe -glldb -flto=thin -fwhole-program-vtables -gline-tables-only"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg buildpkg-live compressdebug config-protect-if-modified distlocks downgrade-backup ebuild-locks fail-clean fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install pid-sandbox pkgdir-index-trusted prese
rve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms split-elog splitdebug strict test unknown-features-warn unmerge-backup unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
LDFLAGS="-Wl,-O3,-z,now,--as-needed,--lto-O3,--icf=safe,--gc-sections"
MAKEOPTS="-j64"
NM="llvm-nm"
RANLIB="llvm-ranlib"
Comment 11 Lukas Schmelting 2024-02-16 23:29:27 UTC
(In reply to Fabio Scaccabarozzi from comment #10)
> I have a clang-first system though, perhaps that plays a role.
I am on a fresh install using a "stage3-amd64-llvm-systemd-mergedusr" archive and got the same error messages mentioned above after applying the already mentioned patch.

I then noticed that Fabio is using the following linker in the provided logs: "x86_64-pc-linux-gnu-ld". I then tried: 
LD=ld.bfd emerge gnu-efi
and got another error:
llvm-objcopy: error: invalid output format: 'efi-app-x86_64'. 

Looking at other bugs i saw that switching to binutils objcopy would enable me to install gnu-efi:
LD=ld.bfd OBJCOPY="objcopy" emerge gnu-efi
Comment 12 Larry the Git Cow gentoo-dev 2024-04-23 19:42:11 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cb4d8611da3298786eb12f11a367abf86e447036

commit cb4d8611da3298786eb12f11a367abf86e447036
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-04-23 19:40:55 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-04-23 19:40:55 +0000

    sys-boot/gnu-efi: add 3.0.18
    
    Closes: https://bugs.gentoo.org/914606
    Closes: https://bugs.gentoo.org/929216
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-boot/gnu-efi/Manifest              |  1 +
 sys-boot/gnu-efi/gnu-efi-3.0.18.ebuild | 85 ++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)