From patchwork Wed Feb 9 10:21:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 37131 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 37FED27BBEA; Wed, 9 Feb 2022 10:35:34 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E212F27BBE9 for ; Wed, 9 Feb 2022 10:35:33 +0000 (GMT) Received: from localhost ([::1]:45230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHkJw-0003lV-SV for patchwork@mira.cbaines.net; Wed, 09 Feb 2022 05:35:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHk7q-0002D2-Qy for guix-patches@gnu.org; Wed, 09 Feb 2022 05:23:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHk7p-0001aI-Ug for guix-patches@gnu.org; Wed, 09 Feb 2022 05:23:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHk7p-000810-QF for guix-patches@gnu.org; Wed, 09 Feb 2022 05:23:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53895] [PATCH 1/5] guix: cpu: Rewrite based on feature flags. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 10:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53895@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 53895-submit@debbugs.gnu.org id=B53895.164440215630768 (code B ref 53895); Wed, 09 Feb 2022 10:23:01 +0000 Received: (at 53895) by debbugs.gnu.org; 9 Feb 2022 10:22:36 +0000 Received: from localhost ([127.0.0.1]:49955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk7P-00080B-RA for submit@debbugs.gnu.org; Wed, 09 Feb 2022 05:22:36 -0500 Received: from flashner.co.il ([178.62.234.194]:50034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk7O-0007zy-4O for 53895@debbugs.gnu.org; Wed, 09 Feb 2022 05:22:34 -0500 Received: from localhost (unknown [37.46.46.251]) by flashner.co.il (Postfix) with ESMTPSA id 394FB403CD; Wed, 9 Feb 2022 10:22:28 +0000 (UTC) From: Efraim Flashner Date: Wed, 9 Feb 2022 12:21:47 +0200 Message-Id: <848868e0ad4427a976bec55968f82a3469009fb9.1644401681.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.34.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/cpu.scm (cpu->gcc-architecture): Rewrite detection based on detected feature flags. --- guix/cpu.scm | 56 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/guix/cpu.scm b/guix/cpu.scm index e1911f52a8..5bb3fa9d2f 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Ludovic Courtès +;;; Copyright © 2022 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,28 +88,39 @@ (define (cpu->gcc-architecture cpu) ("x86_64" ;; Transcribed from GCC's 'host_detect_local_cpu' in driver-i386.c. (or (and (= 6 (cpu-family cpu)) ;the "Pentium Pro" family - (letrec-syntax ((model (syntax-rules (=>) - ((_) #f) - ((_ (candidate => integers ...) rest - ...) - (or (and (= (cpu-model cpu) integers) - candidate) - ... - (model rest ...)))))) - (model ("bonnel" => #x1c #x26) - ("silvermont" => #x37 #x4a #x4d #x5a #x5d) - ("core2" => #x0f #x17 #x1d) - ("nehalem" => #x1a #x1e #x1f #x2e) - ("westmere" => #x25 #x2c #x2f) - ("sandybridge" => #x2a #x2d) - ("ivybridge" => #x3a #x3e) - ("haswell" => #x3c #x3f #x45 #x46) - ("broadwell" => #x3d #x47 #x4f #x56) - ("skylake" => #x4e #x5e #x8e #x9e) - ("skylake-avx512" => #x55) ;TODO: cascadelake - ("knl" => #x57) - ("cannonlake" => #x66) - ("knm" => #x85)))) + (letrec-syntax ((if-flags (syntax-rules (=>) + ((_) + #f) + ((_ (flags ... => name) rest ...) + (if (every (lambda (flag) + (set-contains? (cpu-flags cpu) + flag)) + '(flags ...)) + name + (if-flags rest ...)))))) + + (if-flags ("avx" "avx512vp2intersect" "tsxldtrk" => "sapphirerapids") + ("avx" "avx512vp2intersect" => "tigerlake") + ("avx" "avx512bf16" => "cooperlake") + ("avx" "wbnoinvd" => "icelake-server") + ("avx" "avx512bitalg" => "icelake-client") + ("avx" "avx512vbmi" => "cannonlake") + ("avx" "avx5124vnniw" => "knm") + ("avx" "avx512er" => "knl") + ("avx" "avx512f" => "skylake-avx512") + ("avx" "serialize" => "alderlake") + ("avx" "clflushopt" => "skylake") + ("avx" "adx" => "broadwell") + ("avx" "avx2" => "haswell") + ("avx" => "sandybridge") + ("sse4_2" "gfni" => "tremont") + ("sse4_2" "sgx" => "goldmont-plus") + ("sse4_2" "xsave" => "goldmont") + ("sse4_2" "movbe" => "silvermont") + ("sse4_2" => "nehalem") + ("ssse3" "movbe" => "bonnell") + ("ssse3" => "core2") + ("longmode" => "x86-64")))) ;; Fallback case for non-Intel processors or for Intel processors not ;; recognized above. From patchwork Wed Feb 9 10:21:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 37134 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 527B227BBEA; Wed, 9 Feb 2022 10:52:44 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E690C27BBE9 for ; Wed, 9 Feb 2022 10:52:43 +0000 (GMT) Received: from localhost ([::1]:38332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHkaY-0002Ni-0Z for patchwork@mira.cbaines.net; Wed, 09 Feb 2022 05:52:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHk93-0002aE-GR for guix-patches@gnu.org; Wed, 09 Feb 2022 05:24:17 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHk8o-0001ej-Dg for guix-patches@gnu.org; Wed, 09 Feb 2022 05:24:16 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHk8o-00083b-Ae for guix-patches@gnu.org; Wed, 09 Feb 2022 05:24:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53895] [PATCH 2/5] gnu: cpu: Add detection for AMD CPUs. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 10:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53895@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 53895-submit@debbugs.gnu.org id=B53895.164440218830865 (code B ref 53895); Wed, 09 Feb 2022 10:24:02 +0000 Received: (at 53895) by debbugs.gnu.org; 9 Feb 2022 10:23:08 +0000 Received: from localhost ([127.0.0.1]:49959 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk7w-00081l-5R for submit@debbugs.gnu.org; Wed, 09 Feb 2022 05:23:08 -0500 Received: from flashner.co.il ([178.62.234.194]:50040) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk7u-00080t-KW for 53895@debbugs.gnu.org; Wed, 09 Feb 2022 05:23:07 -0500 Received: from localhost (unknown [37.46.46.251]) by flashner.co.il (Postfix) with ESMTPSA id EA4C5403CD; Wed, 9 Feb 2022 10:23:00 +0000 (UTC) From: Efraim Flashner Date: Wed, 9 Feb 2022 12:21:48 +0200 Message-Id: X-Mailer: git-send-email 2.34.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/cpu.scm : Add vendor field. (current-cpu): Also fill in the 'vendor' field. (cpu->gcc-architecture): Add detection logic for AMD CPUs. --- guix/cpu.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/guix/cpu.scm b/guix/cpu.scm index 5bb3fa9d2f..6d44599822 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -27,6 +27,7 @@ (define-module (guix cpu) #:export (current-cpu cpu? cpu-architecture + cpu-vendor cpu-family cpu-model cpu-flags @@ -42,9 +43,10 @@ (define-module (guix cpu) ;; CPU description. (define-record-type - (cpu architecture family model flags) + (cpu architecture vendor family model flags) cpu? (architecture cpu-architecture) ;string, from 'uname' + (vendor cpu-vendor) ;string (family cpu-family) ;integer (model cpu-model) ;integer (flags cpu-flags)) ;set of strings @@ -58,28 +60,33 @@ (define (prefix? prefix) (call-with-input-file "/proc/cpuinfo" (lambda (port) - (let loop ((family #f) + (let loop ((vendor #f) + (family #f) (model #f)) (match (read-line port) ((? eof-object?) #f) + ((? (prefix? "vendor_id") str) + (match (string-tokenize str) + (("vendor_id" ":" vendor) + (loop vendor family model)))) ((? (prefix? "cpu family") str) (match (string-tokenize str) (("cpu" "family" ":" family) - (loop (string->number family) model)))) + (loop vendor (string->number family) model)))) ((? (prefix? "model") str) (match (string-tokenize str) (("model" ":" model) - (loop family (string->number model))) + (loop vendor family (string->number model))) (_ - (loop family model)))) + (loop vendor family model)))) ((? (prefix? "flags") str) (match (string-tokenize str) (("flags" ":" flags ...) (cpu (utsname:machine (uname)) - family model (list->set flags))))) + vendor family model (list->set flags))))) (_ - (loop family model)))))))) + (loop vendor family model)))))))) (define (cpu->gcc-architecture cpu) "Return the architecture name, suitable for GCC's '-march' flag, that @@ -87,7 +94,8 @@ (define (cpu->gcc-architecture cpu) (match (cpu-architecture cpu) ("x86_64" ;; Transcribed from GCC's 'host_detect_local_cpu' in driver-i386.c. - (or (and (= 6 (cpu-family cpu)) ;the "Pentium Pro" family + (or (and (equal? "GenuineIntel" (cpu-vendor cpu)) + (= 6 (cpu-family cpu)) ;the "Pentium Pro" family (letrec-syntax ((if-flags (syntax-rules (=>) ((_) #f) @@ -122,6 +130,40 @@ (define (cpu->gcc-architecture cpu) ("ssse3" => "core2") ("longmode" => "x86-64")))) + (and (equal? "AuthenticAMD" (cpu-vendor cpu)) + (letrec-syntax ((if-flags (syntax-rules (=>) + ((_) + #f) + ((_ (flags ... => name) rest ...) + (if (every (lambda (flag) + (set-contains? (cpu-flags cpu) + flag)) + '(flags ...)) + name + (if-flags rest ...)))))) + + (when (= 22 (cpu-family cpu)) + (if-flags ("movbe" => "btver2"))) + (when (= 6 (cpu-family cpu)) + (if-flags ("3dnowp" => "athalon"))) + + (if-flags ("vaes" => "znver3") + ("clwb" => "znver2") + ("clzero" => "znver1") + ("avx2" => "bdver4") + ("xsaveopt" => "bdver3") + ("bmi" => "bdver2") + ("xop" => "bdver1") + ("sse4a" "has_ssse3" => "btver1") + ("sse4a" => "amdfam10") + ("sse2" "sse3" => "k8-sse3") + ("longmode" "sse3" => "k8-sse3") + ("sse2" => "k8") + ("longmode" => "k8") + ("mmx" "3dnow" => "k6-3") + ("mmx" => "k6") + (_ => "pentium")))) + ;; Fallback case for non-Intel processors or for Intel processors not ;; recognized above. (letrec-syntax ((if-flags (syntax-rules (=>) @@ -147,7 +189,7 @@ (define (cpu->gcc-architecture cpu) ("ssse3" "movbe" => "bonnell") ("ssse3" => "core2"))) - ;; TODO: Recognize AMD models (bdver*, znver*, etc.)? + ;; TODO: Recognize CENTAUR/CYRIX/NSC? "x86_64")) (architecture From patchwork Wed Feb 9 10:21:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 37133 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 74AE827BBEA; Wed, 9 Feb 2022 10:52:31 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2E62527BBE9 for ; Wed, 9 Feb 2022 10:52:31 +0000 (GMT) Received: from localhost ([::1]:38108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHkaM-0002Bz-C2 for patchwork@mira.cbaines.net; Wed, 09 Feb 2022 05:52:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHk93-0002Zv-DG for guix-patches@gnu.org; Wed, 09 Feb 2022 05:24:17 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHk8o-0001ek-QL for guix-patches@gnu.org; Wed, 09 Feb 2022 05:24:16 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHk8o-00083i-Mg for guix-patches@gnu.org; Wed, 09 Feb 2022 05:24:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53895] [PATCH 3/5] gnu: gcc: Add compiler-cpu-architectures for aarch64. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 10:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53895@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 53895-submit@debbugs.gnu.org id=B53895.164440222730940 (code B ref 53895); Wed, 09 Feb 2022 10:24:02 +0000 Received: (at 53895) by debbugs.gnu.org; 9 Feb 2022 10:23:47 +0000 Received: from localhost ([127.0.0.1]:49968 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk8U-00082o-8s for submit@debbugs.gnu.org; Wed, 09 Feb 2022 05:23:47 -0500 Received: from flashner.co.il ([178.62.234.194]:50048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk8R-00082Z-J9 for 53895@debbugs.gnu.org; Wed, 09 Feb 2022 05:23:40 -0500 Received: from localhost (unknown [37.46.46.251]) by flashner.co.il (Postfix) with ESMTPSA id DDD55403CD; Wed, 9 Feb 2022 10:23:33 +0000 (UTC) From: Efraim Flashner Date: Wed, 9 Feb 2022 12:21:49 +0200 Message-Id: <35229fe985da5a2027622b247d2c95d2bac4213b.1644401681.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.34.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/gcc.scm (%gcc-7.5-aarch64-micro-architectures, %gcc-10-aarch64-micro-architectures): New variables. (gcc-7, gcc-10)[properties]: Add aarch64 compiler-cpu-architectures. --- gnu/packages/gcc.scm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index efa0baeaa1..726c0eed89 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -3,7 +3,7 @@ ;;; Copyright © 2014, 2015, 2018 Mark H Weaver ;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus ;;; Copyright © 2015 Andreas Enge -;;; Copyright © 2015, 2016, 2017, 2018, 2020, 2021 Efraim Flashner +;;; Copyright © 2015, 2016, 2017, 2018, 2020, 2021, 2022 Efraim Flashner ;;; Copyright © 2016 Carlos Sánchez de La Lama ;;; Copyright © 2018 Tobias Geerinckx-Rice ;;; Copyright © 2018, 2020 Marius Bakke @@ -525,6 +525,11 @@ (define-public gcc-6 ,@(package-inputs gcc-4.7))))) +(define %gcc-7.5-aarch64-micro-architectures + ;; Suitable '-march' values for GCC 7.5. + ;; TODO: Allow dynamically adding feature flags. + '("armv8-a" "armv8.1-a" "armv8.2-a" "armv8.3-a")) + (define %gcc-7.5-x86_64-micro-architectures ;; Suitable '-march' values for GCC 7.5 (info "(gcc) x86 Options"). '("core2" "nehalem" "westmere" "sandybridge" "ivybridge" @@ -536,6 +541,12 @@ (define %gcc-7.5-x86_64-micro-architectures "znver1" "btver1" "btver2" "geode")) +(define %gcc-10-aarch64-micro-architectures + ;; Suitable '-march' values for GCC 10. + ;; TODO: Allow dynamically adding feature flags. + (append %gcc-7.5-aarch64-micro-architectures + '("armv8.4-a" "armv8.5-a" "armv8.6-a"))) + (define %gcc-10-x86_64-micro-architectures ;; Suitable '-march' values for GCC 10. (append %gcc-7.5-x86_64-micro-architectures @@ -545,7 +556,6 @@ (define %gcc-10-x86_64-micro-architectures "znver2" "znver3"))) - (define-public gcc-7 (package (inherit gcc-6) @@ -566,6 +576,7 @@ (define-public gcc-7 It also includes runtime support libraries for these languages.") (properties `((compiler-cpu-architectures + ("aarch64" ,@%gcc-7.5-aarch64-micro-architectures) ("x86_64" ,@%gcc-7.5-x86_64-micro-architectures)))))) (define-public gcc-8 @@ -619,6 +630,7 @@ (define-public gcc-10 (snippet gcc-canadian-cross-objdump-snippet))) (properties `((compiler-cpu-architectures + ("aarch64" ,@%gcc-10-aarch64-micro-architectures) ("x86_64" ,@%gcc-10-x86_64-micro-architectures)))))) (define-public gcc-11 From patchwork Wed Feb 9 10:21:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 37132 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 00B0727BBEA; Wed, 9 Feb 2022 10:36:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B9B8D27BBE9 for ; Wed, 9 Feb 2022 10:36:40 +0000 (GMT) Received: from localhost ([::1]:46804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHkL1-0004v0-Sx for patchwork@mira.cbaines.net; Wed, 09 Feb 2022 05:36:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHk9m-0002q0-KO for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56079) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHk9m-0001iv-AH for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHk9m-00085r-5H for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53895] [PATCH 4/5] gnu: gcc: Add compiler-cpu-architectures for armhf. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 10:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53895@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 53895-submit@debbugs.gnu.org id=B53895.164440225431028 (code B ref 53895); Wed, 09 Feb 2022 10:25:02 +0000 Received: (at 53895) by debbugs.gnu.org; 9 Feb 2022 10:24:14 +0000 Received: from localhost ([127.0.0.1]:49973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk90-00084O-5v for submit@debbugs.gnu.org; Wed, 09 Feb 2022 05:24:14 -0500 Received: from flashner.co.il ([178.62.234.194]:50076) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk8y-000847-Hz for 53895@debbugs.gnu.org; Wed, 09 Feb 2022 05:24:12 -0500 Received: from localhost (unknown [37.46.46.251]) by flashner.co.il (Postfix) with ESMTPSA id DB130403CD; Wed, 9 Feb 2022 10:24:06 +0000 (UTC) From: Efraim Flashner Date: Wed, 9 Feb 2022 12:21:50 +0200 Message-Id: <0f41df430961566bffb9a5dac222690be88f4872.1644401681.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.34.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/gcc.scm (%gcc-7.5-armhf-micro-architectures, %gcc-10-armhf-micro-architectures): New variables. (gcc-7, gcc-10)[properties]: Add armhf compiler-cpu-architectures. --- gnu/packages/gcc.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index 726c0eed89..e0a431a0ff 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -530,6 +530,14 @@ (define %gcc-7.5-aarch64-micro-architectures ;; TODO: Allow dynamically adding feature flags. '("armv8-a" "armv8.1-a" "armv8.2-a" "armv8.3-a")) +(define %gcc-7.5-armhf-micro-architectures + ;; Suitable '-march' values for GCC 7.5. + ;; TODO: Allow dynamically adding feature flags. + '("armv7" "armv7-a" "armv7-m" "armv7-r" "armv7e-m" "armv7ve" + "armv8-a" "armv8-a+crc" "armv8.1-a" "armv8.1-a+crc" + "armv8-m.base" "armv8-m.main" "armv8-m.main+dsp" + "iwmmxt" "iwmmxt2")) + (define %gcc-7.5-x86_64-micro-architectures ;; Suitable '-march' values for GCC 7.5 (info "(gcc) x86 Options"). '("core2" "nehalem" "westmere" "sandybridge" "ivybridge" @@ -547,6 +555,13 @@ (define %gcc-10-aarch64-micro-architectures (append %gcc-7.5-aarch64-micro-architectures '("armv8.4-a" "armv8.5-a" "armv8.6-a"))) +(define %gcc-10-armhf-micro-architectures + ;; Suitable '-march' values for GCC 10. + ;; TODO: Allow dynamically adding feature flags. + (append %gcc-7.5-armhf-micro-architectures + '("armv8.2-a" "armv8.3-a" "armv8.4-a" "armv8.5-a" "armv8.6-a" + "armv8-r" "armv8.1-m.main"))) + (define %gcc-10-x86_64-micro-architectures ;; Suitable '-march' values for GCC 10. (append %gcc-7.5-x86_64-micro-architectures @@ -577,6 +592,7 @@ (define-public gcc-7 (properties `((compiler-cpu-architectures ("aarch64" ,@%gcc-7.5-aarch64-micro-architectures) + ("armhf" ,@%gcc-7.5-armhf-micro-architectures) ("x86_64" ,@%gcc-7.5-x86_64-micro-architectures)))))) (define-public gcc-8 @@ -631,6 +647,7 @@ (define-public gcc-10 (properties `((compiler-cpu-architectures ("aarch64" ,@%gcc-10-aarch64-micro-architectures) + ("armhf" ,@%gcc-10-armhf-micro-architectures) ("x86_64" ,@%gcc-10-x86_64-micro-architectures)))))) (define-public gcc-11 From patchwork Wed Feb 9 10:21:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 37135 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id EF97427BBEA; Wed, 9 Feb 2022 10:52:51 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A669827BBE9 for ; Wed, 9 Feb 2022 10:52:51 +0000 (GMT) Received: from localhost ([::1]:38650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHkag-0002dG-Rd for patchwork@mira.cbaines.net; Wed, 09 Feb 2022 05:52:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHk9n-0002qY-LV for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHk9n-0001j3-1n for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHk9m-00085y-Ju for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53895] [PATCH 5/5] WIP: guix: cpu: Add detection for aarch64 CPUs. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 10:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53895@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 53895-submit@debbugs.gnu.org id=B53895.164440228731081 (code B ref 53895); Wed, 09 Feb 2022 10:25:02 +0000 Received: (at 53895) by debbugs.gnu.org; 9 Feb 2022 10:24:47 +0000 Received: from localhost ([127.0.0.1]:49976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk9X-00085F-El for submit@debbugs.gnu.org; Wed, 09 Feb 2022 05:24:47 -0500 Received: from flashner.co.il ([178.62.234.194]:50082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk9V-000851-Gi for 53895@debbugs.gnu.org; Wed, 09 Feb 2022 05:24:45 -0500 Received: from localhost (unknown [37.46.46.251]) by flashner.co.il (Postfix) with ESMTPSA id B9901403CD; Wed, 9 Feb 2022 10:24:39 +0000 (UTC) From: Efraim Flashner Date: Wed, 9 Feb 2022 12:21:51 +0200 Message-Id: <26894a74e7a1ed861a170239e26d13f1298fe5ac.1644401681.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.34.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/cpu.scm (current-cpu): Extend existing implementation to also read cpuinfo from aarch64 machines. (cpu->gcc-architecture): Add case for aarch64. --- guix/cpu.scm | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/guix/cpu.scm b/guix/cpu.scm index 6d44599822..d4dbd5f6b8 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -66,25 +66,47 @@ (define (prefix? prefix) (match (read-line port) ((? eof-object?) #f) + ;; vendor for x86_64 and i686 ((? (prefix? "vendor_id") str) (match (string-tokenize str) (("vendor_id" ":" vendor) (loop vendor family model)))) + ;; vendor for aarch64 and armhf + ((? (prefix? "CPU implementer") str) + (match (string-tokenize str) + (("CPU" "implementer" ":" vendor) + (loop vendor family model)))) + ;; family for x86_64 and i686 ((? (prefix? "cpu family") str) (match (string-tokenize str) (("cpu" "family" ":" family) (loop vendor (string->number family) model)))) + ;; model for x86_64 and i686 ((? (prefix? "model") str) (match (string-tokenize str) (("model" ":" model) (loop vendor family (string->number model))) (_ (loop vendor family model)))) + ;; model for aarch64 and armhf + ((? (prefix? "CPU part") str) + (match (string-tokenize str) + (("CPU" "part" ":" model) + (loop vendor family (string->number (string-append "#x" (string-drop model 2))))) + (_ + (loop vendor family model)))) + ;; flags for x86_64 and i686 ((? (prefix? "flags") str) (match (string-tokenize str) (("flags" ":" flags ...) (cpu (utsname:machine (uname)) vendor family model (list->set flags))))) + ;; flags for aarch64 and armhf + ((? (prefix? "Features") str) + (match (string-tokenize str) + (("Features" ":" flags ...) + (cpu (utsname:machine (uname)) + vendor family model (list->set flags))))) (_ (loop vendor family model)))))))) @@ -192,6 +214,54 @@ (define (cpu->gcc-architecture cpu) ;; TODO: Recognize CENTAUR/CYRIX/NSC? "x86_64")) + ("aarch64" + (pk (cpu-architecture cpu)(cpu-vendor cpu)(cpu-family cpu) (cpu-model cpu)(cpu-flags cpu)) + ;; Currently returns ("aarch64" #f #f #f #< vhash: # insert: # ref: #>) + ;; Transcribed from GCC's list of aarch64 processors in aarch64-cores.def + (match (cpu-vendor cpu) + ("0x41" + (match (cpu-model cpu) + ((or #xd02 #xd04 #xd03 #xd07 #xd08 #xd09) + "armv8-a") + ((or #xd05 #xd0a #xd0b #xd0e #xd0d #xd41 #xd42 #xd4b #xd46 #xd43 #xd44 #xd41 #xd0c #xd4a) + "armv8.2-a") + (#xd40 + "armv8.4-a") + (#xd15 + "armv8-r") + ((or #xd46 #xd47 #xd48) + "armv9-a"))) + ("0x42" + "armv8.1-a") + ("0x43" + (match (cpu-model cpu) + ((or #x0a0 #x0a1 #x0a2 #x0a3) + "armv8-a") + ((or #x0b0 #x0b1 #x0b2 #x0b3 #x0b4 #x0b5) + "armv8.2-a") + (#x0b8 + "armv8.3-a"))) + ("0x46" + "armv8.2-a") + ("0x48" + "armv8.2-a") + ("0x50" + "armv8-a") + ("0x51" + (match (cpu-model cpu) + (#xC00 + "armv8-a") + (#x516 + "armv8.1-a") + (#xC01 + "armv8.4-a"))) + ("0x53" + "armv8-a") + ("0x68" + "armv8-a") + (_ + "armv8-a")) + "armv8-a") (architecture ;; TODO: AArch64. architecture)))