commit:     f6da80af796482d9cd13a47180061fca9a8c66ad
Author:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 22 08:58:58 2025 +0000
Commit:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
CommitDate: Sat Mar 22 14:52:26 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f6da80af

sys-boot/gnu-efi: simplify OBJCOPY handling

Copy it from sys-boot/gnu-efi-4.0.0.

Closes: https://bugs.gentoo.org/947826
Signed-off-by: Viorel Munteanu <ceamac <AT> gentoo.org>

 sys-boot/gnu-efi/gnu-efi-3.0.19.ebuild | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/sys-boot/gnu-efi/gnu-efi-3.0.19.ebuild 
b/sys-boot/gnu-efi/gnu-efi-3.0.19.ebuild
index 7ca85d23f576..d081e78f9e08 100644
--- a/sys-boot/gnu-efi/gnu-efi-3.0.19.ebuild
+++ b/sys-boot/gnu-efi/gnu-efi-3.0.19.ebuild
@@ -38,26 +38,32 @@ PATCHES=(
 
 check_and_set_objcopy() {
        if [[ ${MERGE_TYPE} != "binary" ]]; then
+
+               if use arm || use riscv; then
+                       # bug #939338
+                       # objcopy does not understand PE/COFF on these arches: 
arm32, riscv64 and mips64le
+                       # gnu-efi containes a workaround
+                       return 0
+               fi
+
                # 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}"
+               local binutils_objcopy="${EPREFIX}"/usr/bin/objcopy
                if [[ -e "${binutils_objcopy}" ]]; then
                        OBJCOPY="${binutils_objcopy}"
+                       einfo "Forcing OBJCOPY=${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 containes a workaround
-                       LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' || die 
"${OBJCOPY} (objcopy) does not support EFI target"
-               fi
+
+               # Test OBJCOPY again to see if it supports EFI targets, and 
fail if it doesn't
+               LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' || die 
"${OBJCOPY} (objcopy) does not support EFI target"
        fi
 }
 

Reply via email to