The branch main has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=22921f4b4aedb5017b727e62045130ab69c3dd1b

commit 22921f4b4aedb5017b727e62045130ab69c3dd1b
Author:     Ed Maste <ema...@freebsd.org>
AuthorDate: 2025-03-25 13:34:23 +0000
Commit:     Ed Maste <ema...@freebsd.org>
CommitDate: 2025-04-09 19:26:54 +0000

    boot: Fall back to objcopy if usable for EFI components
    
    In commit b885643b63e4 ("boot: Always use ELF Tool Chain elfcopy for EFI
    builds") I switched to using elfcopy for EFI_OBJCOPY, as llvm-objcopy
    lacks support for translating ELF objects to PE32+.  This broke building
    on older releases with WITHOUT_ELFTOOLCHAIN_BOOTSTRAP set, as the host
    did not provide elfcopy and it was not built as a bootstrap tool.
    
    Now, if we're not bootstrapping ELF Tool Chain we check the output of
    `${OBJCOPY} --version`, and will use that ${OBJCOPY} as long as it is
    not llvm-objcopy.
    
    Reviewed by:    imp
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D49722
---
 stand/efi/Makefile.inc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stand/efi/Makefile.inc b/stand/efi/Makefile.inc
index f91ac9102ca8..6bb0af1d84f3 100644
--- a/stand/efi/Makefile.inc
+++ b/stand/efi/Makefile.inc
@@ -1,3 +1,5 @@
+.include <src.opts.mk>
+
 # Options used when building app-specific efi components
 # See conf/kern.mk for the correct set of these
 CFLAGS+=       -Wformat
@@ -26,7 +28,20 @@ EFI_TARGET=  efi-app-x86_64
 .else
 EFI_TARGET=    binary
 .endif
+
+# GNU or ELF Tool Chain objcopy is usable for building EFI objects.
+# LLVM objcopy is not.  Use elfcopy if we've bootstrapped it (and thus
+# known to be available) or objcopy is LLVM's.
+.if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
 EFI_OBJCOPY?=  elfcopy
+.else
+_v!=           ${OBJCOPY} --version
+.if ${_v:Mllvm-objcopy*} == ""
+EFI_OBJCOPY?=  ${OBJCOPY}
+.else
+EFI_OBJCOPY?=  elfcopy
+.endif
+.endif
 
 # Arbitrarily set the PE/COFF header timestamps to 1 Jan 2024 00:00:00
 # for build reproducibility.

Reply via email to