commit:     9b184c5de6bccb0c876592bb5fd9c654dbee8cc9
Author:     Z. Liu <zhixu.liu <AT> gmail <DOT> com>
AuthorDate: Thu Oct 30 06:09:33 2025 +0000
Commit:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
CommitDate: Fri Oct 31 13:15:48 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9b184c5d

app-crypt/efitools: fix building w/ llvm profile

1. ld.lld: error: section: .dynamic is not contiguous with other relro sections
   fix by force ld.bfd
2. llvm-objcopy: error: invalid output format: 'efi-app-x86_64'
   fix by force objcopy from binutils, check_and_set_objcopy is copied
   from sys-boot/gnu-efi

Closes: https://bugs.gentoo.org/934377
Closes: https://bugs.gentoo.org/953401
Signed-off-by: Z. Liu <zhixu.liu <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/44380
Closes: https://github.com/gentoo/gentoo/pull/44380
Signed-off-by: Viorel Munteanu <ceamac <AT> gentoo.org>

 app-crypt/efitools/efitools-1.9.2-r1.ebuild | 34 +++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/app-crypt/efitools/efitools-1.9.2-r1.ebuild 
b/app-crypt/efitools/efitools-1.9.2-r1.ebuild
index 19832a9ca84a..dfc140075e16 100644
--- a/app-crypt/efitools/efitools-1.9.2-r1.ebuild
+++ b/app-crypt/efitools/efitools-1.9.2-r1.ebuild
@@ -26,6 +26,7 @@ BDEPEND="
        app-crypt/sbsigntools
        dev-perl/File-Slurp
        sys-apps/help2man
+       sys-devel/binutils
        virtual/pkgconfig"
 
 PATCHES=(
@@ -34,6 +35,35 @@ PATCHES=(
        "${FILESDIR}"/1.9.2-gcc15.patch
 )
 
+check_and_set_objcopy() {
+       if [[ ${MERGE_TYPE} != "binary" ]]; then
+               # bug #931792
+               # llvm-objcopy does not support EFI target, try to use binutils 
objcopy or fail
+               tc-export OBJCOPY
+               OBJCOPY="${OBJCOPY/llvm-/}"
+               # Test OBJCOPY to see if it supports EFI targets, and return if 
it does
+               LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' && return 0
+               # If OBJCOPY does not support EFI targets, it is possible that 
the 'objcopy' on our path is
+               # still LLVM if the 'binutils-plugin' USE flag is set. In this 
case, we check to see if the
+               # '(prefix)/usr/bin/objcopy' binary is available (it should be, 
it's a dependency), and if
+               # so, we use the absolute path explicitly.
+               local binutils_objcopy="${EPREFIX}"/usr/bin/"${OBJCOPY}"
+               if [[ -e "${binutils_objcopy}" ]]; then
+                       OBJCOPY="${binutils_objcopy}"
+               fi
+               if ! use arm && ! use riscv; then
+                       # bug #939338
+                       # objcopy does not understand PE/COFF on these arches: 
arm32, riscv64 and mips64le
+                       # gnu-efi contains a workaround
+                       LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' || die 
"${OBJCOPY} (objcopy) does not support EFI target"
+               fi
+       fi
+}
+
+pkg_setup() {
+       check_and_set_objcopy
+}
+
 src_prepare() {
        default
 
@@ -42,6 +72,10 @@ src_prepare() {
                sed -i -e 's/-fno-toplevel-reorder//g' Make.rules || die
        fi
 
+       if tc-ld-is-lld; then
+               tc-ld-force-bfd
+       fi
+
        if use static; then
                append-ldflags -static
                export STATIC_FLAG=--static

Reply via email to