commit: d25b3f6cfcf28716f030b7a7fea3206a5fc4dffd Author: Maide <github <AT> maide <DOT> ca> AuthorDate: Thu Sep 26 17:00:25 2024 +0000 Commit: Viorel Munteanu <ceamac <AT> gentoo <DOT> org> CommitDate: Fri Sep 27 17:07:21 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d25b3f6c
sys-boot/gnu-efi: Fix compile when LLVM `binutils-plugin` USE flag is set LLVM's objcopy is being used instead of the GNU version when `binutils-plugin` is enabled. I tried to avoid this by explictly using the GNU path for objcopy when our initial test fails. Let me know if this isn't acceptable, or if you need me to open a new bug for this. It was basically the same repo as the linked issue, but the fix did not work, as `which objcopy` returns '/usr/lib/llvm/18/bin/objcopy' instead of '/usr/bin/objcopy'. Bug: https://bugs.gentoo.org/931792 Signed-off-by: Maide <github <AT> maide.ca> Closes: https://github.com/gentoo/gentoo/pull/38785 Signed-off-by: Viorel Munteanu <ceamac <AT> gentoo.org> sys-boot/gnu-efi/gnu-efi-3.0.18-r3.ebuild | 10 ++++++++++ sys-boot/gnu-efi/gnu-efi-3.0.18-r5.ebuild | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/sys-boot/gnu-efi/gnu-efi-3.0.18-r3.ebuild b/sys-boot/gnu-efi/gnu-efi-3.0.18-r3.ebuild index 511b4e30b24d..26cfa7b58d27 100644 --- a/sys-boot/gnu-efi/gnu-efi-3.0.18-r3.ebuild +++ b/sys-boot/gnu-efi/gnu-efi-3.0.18-r3.ebuild @@ -42,6 +42,16 @@ check_and_set_objcopy() { # 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 LANG=C LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' || die "${OBJCOPY} (objcopy) does not support EFI target" fi } diff --git a/sys-boot/gnu-efi/gnu-efi-3.0.18-r5.ebuild b/sys-boot/gnu-efi/gnu-efi-3.0.18-r5.ebuild index adfad0c0f98e..d3d5d12d57b7 100644 --- a/sys-boot/gnu-efi/gnu-efi-3.0.18-r5.ebuild +++ b/sys-boot/gnu-efi/gnu-efi-3.0.18-r5.ebuild @@ -42,6 +42,16 @@ check_and_set_objcopy() { # 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
