From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oFODC72HmWQVBAEASxT56A (envelope-from ) for ; Mon, 26 Jun 2023 14:42:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iAdDCr2HmWQfYAAAG6o9tA (envelope-from ) for ; Mon, 26 Jun 2023 14:42:37 +0200 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 BB8C31551 for ; Mon, 26 Jun 2023 14:42:36 +0200 (CEST) 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1687783356; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=E2lA4qQUapcvjg38AXDXp4wACqRJI5uJ52nAKM4GHYo=; b=mU6ZcVc4DhnKfTm453pb+Bc/kU7tZk/eC7njuOX0LzuMnM9L4hZuXx4n74G4qsSTd4Kl5N TnQg7Ie0HVsVHJdxH+a1kJO8u0AAv2L3db7+mHCrHhMH6646CIHeZbuXx+73/eQWbFyHbr QJioAmS2zwDxgTHHYlUNQJdQqNbPxwup/AAR81l8azEQpYyeE3Cmk43H38a4cvhmkyupAq JhSyEreET39X2yGMtQPl+Gh87SPNoBUPYiR2o+s2U/+iF6JkEaToycTo2PXvRBZed01w8z SbmrQyo/Hj/eg6vy9zIQGT6Yp13e249gz4nLf56J5RiRQw7uAxAF88HqLDxR8Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=X1Hf++xP; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1687783356; a=rsa-sha256; cv=none; b=LntaGSYlKMN0/j0661MSK9Dze5ldSsOuglt32wMzKhf11avrCMXEuxYD5+GDl7QlGEsEfA IZNRML9uUuCi4B2/yxojswVaAvKyNseJyn+KwG+UjSceR8wrSyWEYmzzh9fXmUJ8S3IIET JSaC1uQx/1rVoNS+LvzGei7hTumRfu+7TXjinNHronJ4Q2W0INDlMud+o8xaUR1d1cwlMn Dk1OMI73XUS5+2VOwF+W/A8xFbMkPZsKBpk5l+UevYqRJAw2IPJRVy7T5k1EL2FGULOfhL zzLFxZgCW5bCTyVSqZjYjMdtkW3QUB6LPhNoGilPGNrwbjWuKMWoE3YaouaYzw== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: 0.25 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=X1Hf++xP; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: BB8C31551 X-Spam-Score: 0.25 X-TUID: AO6Bjgn4rrL8 * 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? -- Efraim Flashner רנשלפ םירפא GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted