git: 8c22b9f3ba58 - main - Fix cross-building on Linux/aarch64

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Mon, 18 Oct 2021 16:09:33 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=8c22b9f3ba586e008e8e55a6215a1d46eb6830b9

commit 8c22b9f3ba586e008e8e55a6215a1d46eb6830b9
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2021-10-18 02:26:47 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-10-18 16:09:00 +0000

    Fix cross-building on Linux/aarch64
    
    Add necessary bits to detect ELF format on Linux/aarch64; note that
    Linux calls it aarch64 where we would typically call it arm64 (uname -m)
    
    Reviewed by:    arichardson, emaste, imp
    Sponsored by:   Ampere Computing LLC
    Sponsored by:   Klara Inc.
    Differential Revision:  https://reviews.freebsd.org/D32542
---
 contrib/elftoolchain/common/native-elf-format | 2 ++
 tools/build/Makefile                          | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/contrib/elftoolchain/common/native-elf-format b/contrib/elftoolchain/common/native-elf-format
index cef29e75111e..903dc37d0fbe 100755
--- a/contrib/elftoolchain/common/native-elf-format
+++ b/contrib/elftoolchain/common/native-elf-format
@@ -39,6 +39,8 @@ $1 ~ "Machine:" {
             elfarch = "EM_X86_64";
         } else if (match($0, "PowerPC64")) {
             elfarch = "EM_PPC64";
+        } else if (match($0, "AArch64")) {
+            elfarch = "EM_AARCH64";
         } else {
             elfarch = "unknown";
         }
diff --git a/tools/build/Makefile b/tools/build/Makefile
index 742432872c49..ec9b11398ae9 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -125,6 +125,9 @@ _host_arch=${MACHINE}
 .if ${_host_arch} == "x86_64"
 # bmake on Linux/mac often prints that instead of amd64
 _host_arch=amd64
+.elif ${_host_arch} == "aarch64"
+# Linux calls arm64, aarch64, across the board
+_host_arch=arm64
 .elif ${_host_arch:Mppc*}
 _host_arch=powerpc
 .endif