git: 7d70f8b482fd - main - Makefile.inc1: Rework ELF Tool Chain bootstrapping

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Thu, 27 Mar 2025 16:38:57 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=7d70f8b482fd1ab82dbea31103be7de5ec3c2c7b

commit 7d70f8b482fd1ab82dbea31103be7de5ec3c2c7b
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2025-03-25 13:47:50 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-03-27 16:38:25 +0000

    Makefile.inc1: Rework ELF Tool Chain bootstrapping
    
    Remove additional conditions and bootstrap elfctl, elfdump, and elfcopy
    (aka objdump) if ELFTOOLCHAIN_BOOTSTRAP is true.  The first two are
    bespoke tools that won't exist in an external GNU or LLVM binutils, and
    elfcopy is also not provided by that name.
    
    This should fix GCC CI builds, which was skipping the elfcopy build
    because of the ${TARGET_ARCH} != ${MACHINE_ARCH} condition.
    
    Reported by:    olce
    Reviewed by:    brooks
    Fixes: b885643b63e4 ("boot: Always use ELF Tool Chain elfcopy for EFI builds")
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D49493
---
 Makefile.inc1 | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 3569d068095c..af9e4736a65a 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2909,29 +2909,24 @@ _dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \
     cddl/usr.bin/ctfmerge
 .endif
 
-# If we're given an XAS, don't build binutils.
-.if ${XAS:M/*} == ""
 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
+# Some bespoke tools from or based on ELF Tool Chain.  objcopy (elfcopy) is
+# included because llvm-objcopy is currently not capable of translating ELF to
+# PE32+, which is required for EFI boot programs.
 _elftctools=	lib/libelftc \
 		lib/libpe \
 		usr.bin/elfctl \
 		usr.bin/elfdump \
-		usr.bin/objcopy \
-		usr.bin/nm \
+		usr.bin/objcopy
+# If we're given an XNM we don't need to build standard binary utilities.
+.if ${XNM:M/*} == ""
+_elftctools+=	usr.bin/nm \
 		usr.bin/size \
 		usr.bin/strings
 # These are not required by the build, but can be useful for developers who
 # cross-build on a FreeBSD 10 host:
 _elftctools+=	usr.bin/addr2line
 .endif
-.elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
-# If cross-building with an external binutils we still need to build strip for
-# the target (for at least crunchide).
-_elftctools=	lib/libelftc \
-		lib/libpe \
-		usr.bin/elfctl \
-		usr.bin/elfdump \
-		usr.bin/objcopy
 .endif
 
 .if ${MK_CLANG_BOOTSTRAP} != "no"