From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KN2vMcMGnmPmygAAbAwnHQ (envelope-from ) for ; Sat, 17 Dec 2022 19:13:23 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id sHLEMcMGnmMAhgAA9RJhRA (envelope-from ) for ; Sat, 17 Dec 2022 19:13:23 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 878B628127 for ; Sat, 17 Dec 2022 19:13:23 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6bgK-0001to-8i; Sat, 17 Dec 2022 13:13:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6bgI-0001se-7y for guix-patches@gnu.org; Sat, 17 Dec 2022 13:13:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p6bgE-0001mv-Tx for guix-patches@gnu.org; Sat, 17 Dec 2022 13:13:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p6bgE-0008U5-CF for guix-patches@gnu.org; Sat, 17 Dec 2022 13:13:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60166] [PATCH] gnu: flashrom: Fix build on AArch64. Resent-From: Simon South Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 17 Dec 2022 18:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60166 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60166@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167130076432602 (code B ref -1); Sat, 17 Dec 2022 18:13:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Dec 2022 18:12:44 +0000 Received: from localhost ([127.0.0.1]:57271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6bfv-0008Tk-Dl for submit@debbugs.gnu.org; Sat, 17 Dec 2022 13:12:44 -0500 Received: from lists.gnu.org ([209.51.188.17]:38056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6bft-0008Te-0t for submit@debbugs.gnu.org; Sat, 17 Dec 2022 13:12:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6bfs-0001i6-PB for guix-patches@gnu.org; Sat, 17 Dec 2022 13:12:40 -0500 Received: from mailout.easymail.ca ([64.68.200.34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6bfm-0001jR-TE for guix-patches@gnu.org; Sat, 17 Dec 2022 13:12:38 -0500 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 5E704E7820 for ; Sat, 17 Dec 2022 18:12:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo08-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo08-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QDd_0ef8OJ_O for ; Sat, 17 Dec 2022 18:12:19 +0000 (UTC) Received: from localhost.localdomain (23-233-96-72.cpe.pppoe.ca [23.233.96.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id CB31CE77E5 for ; Sat, 17 Dec 2022 18:12:19 +0000 (UTC) From: Simon South Date: Sat, 17 Dec 2022 13:12:05 -0500 Message-Id: <20221217181205.23795-1-simon@simonsouth.net> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.68.200.34; envelope-from=simon@simonsouth.net; helo=mailout.easymail.ca X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-TUID: ro2SBiXq4nJu * gnu/packages/patches/flashrom-fix-building-on-aarch64.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/flashing-tools.scm (flashrom)[source]: Apply it. --- This patch allows the flashrom ROM-flashing utility to build on AArch64 by backporting a patch[0] that fixes the project's build system so it identifies the target architecture correctly. (Currently, trying to build the package on aarch64-linux fails immediately with "Target arch is unknown. Aborting.") I've tested this on x86-64 and AArch64 and everything appears fine. On x86-64 an identical binary is produced with or without this patch applied. [0] https://review.coreboot.org/plugins/gitiles/flashrom/+/da6b3b70cb852dd8e9f9e21aef95fa83e7f7ab0d -- Simon South simon@simonsouth.net gnu/local.mk | 1 + gnu/packages/flashing-tools.scm | 4 +- .../flashrom-fix-building-on-aarch64.patch | 89 +++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/flashrom-fix-building-on-aarch64.patch diff --git a/gnu/local.mk b/gnu/local.mk index 5b8944f568..56634e090c 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1112,6 +1112,7 @@ dist_patch_DATA = \ %D%/packages/patches/firebird-riscv64-support-pt1.patch \ %D%/packages/patches/firebird-riscv64-support-pt2.patch \ %D%/packages/patches/flann-cmake-3.11.patch \ + %D%/packages/patches/flashrom-fix-building-on-aarch64.patch \ %D%/packages/patches/flatpak-fix-path.patch \ %D%/packages/patches/flatpak-unset-gdk-pixbuf-for-sandbox.patch \ %D%/packages/patches/fontconfig-cache-ignore-mtime.patch \ diff --git a/gnu/packages/flashing-tools.scm b/gnu/packages/flashing-tools.scm index 08300cb860..e7165efe79 100644 --- a/gnu/packages/flashing-tools.scm +++ b/gnu/packages/flashing-tools.scm @@ -66,7 +66,9 @@ (define-public flashrom version ".tar.bz2")) (sha256 (base32 - "0ax4kqnh7kd3z120ypgp73qy1knz47l6qxsqzrfkd97mh5cdky71")))) + "0ax4kqnh7kd3z120ypgp73qy1knz47l6qxsqzrfkd97mh5cdky71")) + (patches + (search-patches "flashrom-fix-building-on-aarch64.patch")))) (build-system gnu-build-system) (inputs (list dmidecode pciutils libusb libftdi)) (native-inputs (list pkg-config)) diff --git a/gnu/packages/patches/flashrom-fix-building-on-aarch64.patch b/gnu/packages/patches/flashrom-fix-building-on-aarch64.patch new file mode 100644 index 0000000000..f5fbb0a111 --- /dev/null +++ b/gnu/packages/patches/flashrom-fix-building-on-aarch64.patch @@ -0,0 +1,89 @@ +commit da6b3b70cb852dd8e9f9e21aef95fa83e7f7ab0d +Author: Pyry Kontio +Date: Mon Jul 6 12:57:35 2020 +0900 + + Makefile: Fix building on AArch64 NixOS + + The parsing of the output of archtest.c produced an unexpected + value on AArch64 NixOS. For example, the make variable ARCH was set to: + + ``` + bit outside of fd_set selected + arm + ``` + + This made the arch and OS checks fail. + + This commit simplifies the parsing, making it more robust. + + The C files archtest.c, endiantest.c and os.h used to set the + TARGET_OS, ARCH and ENDIAN variables, respectively, output + the result of the test as the final line, so just extracting + the final line and removing double quoting is enough. + + This commit also fixes a bug with debug_shell lacking escaping + single quotes, which prevented using the single quote in the + debug_shell calls. It used to work by accident before this fix; + the line in the call happened to contain a balanced pair of double + quotes and lacked other characters that needed escaping, which + didn't break the debug_shell, but this was accidental and very + brittle. + + Signed-off-by: Pyry Kontio + Change-Id: Iaa4477a71e758cf9ecad2c22f3b77bc6508a3510 + Reviewed-on: https://review.coreboot.org/c/flashrom/+/43140 + Tested-by: build bot (Jenkins) + Reviewed-by: Angel Pons + +diff --git a/Makefile b/Makefile +index f3f7717e..e475cbdb 100644 +--- a/Makefile ++++ b/Makefile +@@ -83,7 +83,8 @@ dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUIL + + # Provide an easy way to execute a command, print its output to stdout and capture any error message on stderr + # in the build details file together with the original stdout output. +-debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(1) ; }' >&2; { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE)) ++debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(subst ','\'',$(1)) ; }' >&2; \ ++ { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE)) + + ############################################################################### + # General OS-specific settings. +@@ -106,7 +107,8 @@ endif + # IMPORTANT: The following line must be placed before TARGET_OS is ever used + # (of course), but should come after any lines setting CC because the line + # below uses CC itself. +-override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"')) ++override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null \ ++ | tail -1 | cut -f 2 -d'"')) + + ifeq ($(TARGET_OS), Darwin) + override CPPFLAGS += -I/opt/local/include -I/usr/local/include +@@ -490,8 +492,10 @@ endif + # IMPORTANT: The following line must be placed before ARCH is ever used + # (of course), but should come after any lines setting CC because the line + # below uses CC itself. +-override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"')) +-override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null | grep -v '^\#')) ++override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null \ ++ | tail -1 | cut -f 2 -d'"')) ++override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \ ++ | tail -1)) + + # Disable the internal programmer on unsupported architectures (everything but x86 and mipsel) + ifneq ($(ARCH)-little, $(filter $(ARCH),x86 mips)-$(ENDIAN)) +@@ -1299,12 +1303,12 @@ compiler: featuresavailable + @printf "Target arch is " + @# FreeBSD wc will output extraneous whitespace. + @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \ +- ( echo "unknown. Aborting."; exit 1) ++ ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1) + @printf "%s\n" '$(ARCH)' + @printf "Target OS is " + @# FreeBSD wc will output extraneous whitespace. + @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \ +- ( echo "unknown. Aborting."; exit 1) ++ ( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1) + @printf "%s\n" '$(TARGET_OS)' + ifeq ($(TARGET_OS), libpayload) + @$(CC) --version 2>&1 | grep -q coreboot || \ base-commit: 810b455013037f44801cf1048c81796e77577962 -- 2.38.1