From patchwork Tue Jun 20 07:51:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 51094 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 79A5D27BBE9; Tue, 20 Jun 2023 08:52:39 +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 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 DDC5527BBE2 for ; Tue, 20 Jun 2023 08:52:38 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBW9q-0003pz-Gq; Tue, 20 Jun 2023 03:52:10 -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 1qBW9n-0003n1-Dz for guix-patches@gnu.org; Tue, 20 Jun 2023 03:52:07 -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 1qBW9n-0006OO-3G; Tue, 20 Jun 2023 03:52:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qBW9l-00056w-1E; Tue, 20 Jun 2023 03:52:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64188] [PATCH 8/8] transformations: Allow autotuning for go packages. 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: Tue, 20 Jun 2023 07:52: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.168724749319541 (code B ref 64188); Tue, 20 Jun 2023 07:52:04 +0000 Received: (at 64188) by debbugs.gnu.org; 20 Jun 2023 07:51:33 +0000 Received: from localhost ([127.0.0.1]:57967 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBW9E-000554-Iz for submit@debbugs.gnu.org; Tue, 20 Jun 2023 03:51:33 -0400 Received: from mail-lf1-f54.google.com ([209.85.167.54]:57567) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBW98-00054G-K2 for 64188@debbugs.gnu.org; Tue, 20 Jun 2023 03:51:27 -0400 Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-4f86a7a5499so3305481e87.2 for <64188@debbugs.gnu.org>; Tue, 20 Jun 2023 00:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687247481; x=1689839481; 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=uliwPgGofx32KubgtxjpIsl6lux11rtd1cYIDTx20SE=; b=FOhxoa+xsYgrjtRf6zby6K7SBaaLK5iOcRCOkQCJJwFQFq+SthhhzuOF4Cv6v9XA0o k6Lgn+dmCp/Ze/5Bq/Tga2vo5iYIEwuY+j1OLl2jgAoh2VMs9DcKnqmUt1f0LzvVg7EV Vg3hY647PI8Gpdq8pkUAhkAGgDdhWVeVQqpUm83M+HEKE7WSb0pge9iC4UviE5HF4nd5 hNN/aaoUW+1S7OXEtdcKAEQpyhBB6lOuyA5GyqnHsCLafNnJmarzaBxk+xf4RbGXH6+2 XJbmnCU8B0ZEuliMmxvl5uc0OIj/rI/UTUJL63W3jP6WDA9QnanpjQRmXfrOSgdXd1KT 6fBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247481; x=1689839481; 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=uliwPgGofx32KubgtxjpIsl6lux11rtd1cYIDTx20SE=; b=FNM7lSG614ZqinhdEyQQ20GmgPDa02l126UQJ0cM2jyk6cqD5DXUMrcIuyG4HVweVF 0SPGpupBESg+iJpQS2GHWIxYKs4EqBNz1V6Y112E//RqpN2sB69PXPb21TPbkFg3m/Ua jsZrUdzgfU611VHCvDYAioOKhgn7wAu72XdaRxQk4JGGZAU5KMsM2kJ2wj16jF2xB+xz 0GjPfpa8GL2OloXh07poMK41Bf8z+zZMVTdOJlPAwaG2Oh9J2SAFca+t6IzBrJxlTjTm +0NCl5iSiqqo945Kc/zR/RminD7ierGCUhuYb8q2OSKaN/tevLVAw5uLBIuTgXW/yqgt 6Gow== X-Gm-Message-State: AC+VfDxbs8fEKxYUZy86v0uqnQWDcShzdq+6UWizW6UeRQ73JewXXaih vO2PoYix4HiHqz0goCAofxVPYkCYyfhZcKEh X-Google-Smtp-Source: ACHHUZ4sUQ4hpWvrvsNYBcEXJ9jI5/RdGot5P56iBFxpk8UepSvKgzxQOlWVC2uOQVHM3m8vWIGBLA== X-Received: by 2002:ac2:5f99:0:b0:4f8:6cad:aae7 with SMTP id r25-20020ac25f99000000b004f86cadaae7mr3399159lfe.61.1687247480681; Tue, 20 Jun 2023 00:51:20 -0700 (PDT) Received: from localhost ([188.120.129.124]) by smtp.gmail.com with ESMTPSA id p19-20020a05600c469300b003f7f475c3bcsm22345002wmo.1.2023.06.20.00.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:51:19 -0700 (PDT) From: Efraim Flashner Date: Tue, 20 Jun 2023 10:51:09 +0300 Message-Id: <08188fe179fbbbe815ad75d39b14c6c8f6cca678.1687247150.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/transformations.scm (tuned-package)[build-system]: When the inherited package uses the go-build-system, use a generic micro-architecture. [arguments]: Adjust the 'set-microarchitecture phase for changes in the code. --- guix/transformations.scm | 50 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/guix/transformations.scm b/guix/transformations.scm index 47eb4b0515..122b0e74aa 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -33,7 +33,9 @@ (define-module (guix transformations) #:autoload (guix upstream) (package-latest-release upstream-source-version upstream-source-signature-urls) - #:autoload (guix cpu) (current-cpu cpu->gcc-architecture) + #:autoload (guix cpu) (current-cpu + cpu->gcc-architecture + gcc-architecture->generic-architecture) #:use-module (guix utils) #:use-module (guix memoization) #:use-module (guix gexp) @@ -568,16 +570,19 @@ (define (build-system-with-tuning-compiler bs micro-architecture) (define (tuned-package p micro-architecture) "Return package P tuned for MICRO-ARCHITECTURE." + (let ((generic-micro-arch (gcc-architecture->generic-architecture + micro-architecture))) (package (inherit p) (build-system - ;; The go compiler doesn't need to be wrapped. - ;; XXX: This is where we check for supported micro-architectures. - (if (eq? (build-system-name (package-build-system p)) - 'go) + ;; The go compiler doesn't need to be wrapped but we want the error + ;; checking to make sure we're targeting a recognized optimization target. + (build-system-with-tuning-compiler (package-build-system p) - (build-system-with-tuning-compiler (package-build-system p) - micro-architecture))) + (if (eq? (build-system-name (package-build-system p)) + 'go) + generic-micro-arch + micro-architecture))) (arguments ;; The machine building this package may or may not be able to run code ;; for MICRO-ARCHITECTURE. Because of that, skip tests; they are run for @@ -591,21 +596,20 @@ (define (tuned-package p micro-architecture) #~(modify-phases #$phases (add-after 'setup-go-environment 'set-microarchitecture (lambda _ - (let ((microarch #$micro-architecture)) - (cond - ((string-prefix? "arm" microarch) - (setenv "GOARM" (string-take-right microarch 1)) - (format #t "Setting GOARM to ~s." - (getenv "GOARM"))) - ((string-prefix? "powerpc" microarch) - (setenv "GOPPC64" microarch) - (format #t "Setting GOPPC64 to ~s." - (getenv "GOPPC64"))) - ((string-prefix? "x86_64" microarch) - (setenv "GOAMD" (string-take-right microarch 2)) - (format #t "Setting GOAMD to ~s.\n" - (getenv "GOAMD"))) - (else #t)))))) + (cond + ((string-prefix? "arm" #$generic-micro-arch) + (setenv "GOARM" (string-take-right #$generic-micro-arch 1)) + (format #t "Setting GOARM to ~s." + (getenv "GOARM"))) + ((string-prefix? "powerpc" #$generic-micro-arch) + (setenv "GOPPC64" #$generic-micro-arch) + (format #t "Setting GOPPC64 to ~s." + (getenv "GOPPC64"))) + ((string-prefix? "x86_64" #$generic-micro-arch) + (setenv "GOAMD" (string-take-right #$generic-micro-arch 2)) + (format #t "Setting GOAMD to ~s.\n" + (getenv "GOAMD"))) + (else #t))))) phases)))) (properties @@ -613,7 +617,7 @@ (define (tuned-package p micro-architecture) ;; Remove the 'tunable?' property so that 'package-tuning' does not ;; call 'tuned-package' again on this one. - ,@(alist-delete 'tunable? (package-properties p)))))) + ,@(alist-delete 'tunable? (package-properties p))))))) (define (tunable-package? package) "Return true if package PACKAGE is \"tunable\"--i.e., if tuning it for the