From patchwork Mon Jun 26 12:38:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 51350 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 4DF3627BBE9; Mon, 26 Jun 2023 13:42:37 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED 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 BA03A27BBE2 for ; Mon, 26 Jun 2023 13:42:36 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDlWJ-0000B8-Pc; Mon, 26 Jun 2023 08:40:39 -0400 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 1qDlVl-0008FY-3K for guix-patches@gnu.org; Mon, 26 Jun 2023 08:40:05 -0400 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 1qDlVk-0005rK-8O; Mon, 26 Jun 2023 08:40:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qDlVk-0004Id-36; Mon, 26 Jun 2023 08:40:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64188] [PATCH v2 4/7] guix: cpu: Refactor cpu->gcc-architecture. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: mail@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 26 Jun 2023 12:40:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64188 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64188@debbugs.gnu.org Cc: Efraim Flashner , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 64188-submit@debbugs.gnu.org id=B64188.168778315416382 (code B ref 64188); Mon, 26 Jun 2023 12:40:04 +0000 Received: (at 64188) by debbugs.gnu.org; 26 Jun 2023 12:39:14 +0000 Received: from localhost ([127.0.0.1]:44765 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qDlUv-0004Fy-8f for submit@debbugs.gnu.org; Mon, 26 Jun 2023 08:39:13 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:42052) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qDlUr-0004Ew-5D for 64188@debbugs.gnu.org; Mon, 26 Jun 2023 08:39:09 -0400 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-31297125334so2742760f8f.0 for <64188@debbugs.gnu.org>; Mon, 26 Jun 2023 05:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687783143; x=1690375143; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=E2lA4qQUapcvjg38AXDXp4wACqRJI5uJ52nAKM4GHYo=; b=X1Hf++xP5IdxGMgIv6bXE31WLq+hsRcaBYcvIfA8EK5wWRDz9qCXmbxufUHTykSpRS 6EY2Y+Tz8OASnoO/ubB5zRBW61Qpm+2ZLtmqBK8+NOm7FrX5L5E5xVfoGkLGZrY32Eps jwmpv1GyYfnJHqzy2AlnJL7/XsYkXGS5L2QkzxuxmHV9xNyogo2SNhHRwITkx4g+KoFQ kBa5drTqtdzp9ITGdsDyWJmP31T9ytTT7uAL9ov5C4SpkoR5tmK6CiZrW1HHvPjkbP8k QD1cWDu1pq6qR/mYNFiYpjFOkx+VxWRX0dYrHX7PL1rXQGBGBKgP0PfFKTIuGyS0LGNm 6fIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687783143; x=1690375143; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=E2lA4qQUapcvjg38AXDXp4wACqRJI5uJ52nAKM4GHYo=; b=ie+4b9lKIvmhRoOVJEDlHU0Tu6J6PPX9y0NoQw0WsKJrFqV61uVn/y0xeWhbo6KqCh +PBis+G4xGhg207D2Yt406dmargpIkZruRVZFIyHrlWjRjcillRJv0rox+TZMgcDjDVr lKXrNE/sesQdY5QXP/1+/gJwoMSD1IM0DTFW+Najp8aW+3e0UZFeZNFUUPLVfSp5jFFI bZfv/Agl6CcdBBiGgsdXeC7qM3vA7lPkc2EQR1X0u1srUp/q1cjmroQFF8GPssKsxcoe Njlp4V5nhuUO1w+xphdmo2MNWE5cIJxIiWZTw3IO3Oy7D41mCGGDbzA9S4UNOpa+PQCa 8iEg== X-Gm-Message-State: AC+VfDzU95jPNzYUjrztxn1p2+FgnNSJRJWcY4qsd3mERJSsFABP6mp3 hwOKLzjtgD2MF5J5Th5rqiq5FlHBGCVGvw== X-Google-Smtp-Source: ACHHUZ4GKPNrmGJLk3rxSAfYA6W1e98LV9dYoRtv09kiY4D2R5C7UUMyEMW0l4GpYdsl0Pj+l3aaLw== X-Received: by 2002:a5d:480c:0:b0:311:5b9:9d58 with SMTP id l12-20020a5d480c000000b0031105b99d58mr25387590wrq.16.1687783143507; Mon, 26 Jun 2023 05:39:03 -0700 (PDT) Received: from localhost ([188.120.129.124]) by smtp.gmail.com with ESMTPSA id e10-20020a056000194a00b0031134bcdacdsm7297974wry.42.2023.06.26.05.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 05:39:03 -0700 (PDT) From: Efraim Flashner Date: Mon, 26 Jun 2023 15:38:40 +0300 Message-Id: <0e756812e63220f9f5bc17169713b80281806dbe.1687781377.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.40.1 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/cpu.scm (cpu->gcc-architecture): Refactor to wrap all the x86_64 options inside a common letrec-syntax. --- guix/cpu.scm | 57 +++++++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/guix/cpu.scm b/guix/cpu.scm index 1a75b8ac62..30cd860a19 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -114,19 +114,19 @@ (define (cpu->gcc-architecture cpu) (match (cpu-architecture cpu) ("x86_64" ;; Transcribed from GCC's 'host_detect_local_cpu' in driver-i386.cc. - (or (and (equal? "GenuineIntel" (cpu-vendor cpu)) - (= 6 (cpu-family cpu)) ;the "Pentium Pro" family - (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 ...)))))) + (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 ...)))))) + (or (and (equal? "GenuineIntel" (cpu-vendor cpu)) + (= 6 (cpu-family cpu)) ;the "Pentium Pro" family (if-flags ("avx" "raoint" => "grandridge") ("avx" "amx_fp16" => "graniterapids") ("avx" "avxvnniint8" => "sierraforest") @@ -152,20 +152,9 @@ (define (cpu->gcc-architecture cpu) ("ssse3" "movbe" => "bonnell") ("ssse3" => "core2") ("longmode" => "x86-64") - ("lm" => "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 ...)))))) + ("lm" => "x86-64"))) + (and (equal? "AuthenticAMD" (cpu-vendor cpu)) (or (and (= 22 (cpu-family cpu)) (if-flags ("movbe" => "btver2"))) (and (= 6 (cpu-family cpu)) @@ -192,20 +181,10 @@ (define (cpu->gcc-architecture cpu) ("lm" => "k8") ("mmx" "3dnow" => "k6-3") ("mmx" => "k6") - (_ => "pentium"))))) + (_ => "pentium")))) - ;; Fallback case for non-Intel processors or for Intel processors not - ;; recognized above. - (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 ...)))))) + ;; Fallback case for non-Intel processors or for processors not + ;; recognized above. (if (and (= 7 (cpu-family cpu)) (= #x3b (cpu-model cpu))) "lujiazui" @@ -213,7 +192,7 @@ (define (cpu->gcc-architecture cpu) ;; TODO: Recognize CENTAUR/CYRIX/NSC? - "x86_64")) + "x86_64"))) ("aarch64" ;; Transcribed from GCC's list of aarch64 processors in aarch64-cores.def ;; What to do with big.LITTLE cores?