From patchwork Tue Jun 20 07:51:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 14099 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 A8CDC27BBE9; Tue, 20 Jun 2023 08:52:48 +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 24B9227BBE2 for ; Tue, 20 Jun 2023 08:52:48 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBW9o-0003nR-KK; Tue, 20 Jun 2023 03:52:08 -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-0003ms-2U 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 1qBW9m-0006OA-Oc; Tue, 20 Jun 2023 03:52:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qBW9j-00056Z-V7; Tue, 20 Jun 2023 03:52:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64188] [PATCH 6/8] transformations: Allow tuning 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:03 +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.168724748819521 (code B ref 64188); Tue, 20 Jun 2023 07:52:03 +0000 Received: (at 64188) by debbugs.gnu.org; 20 Jun 2023 07:51:28 +0000 Received: from localhost ([127.0.0.1]:57963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBW99-00054m-QT for submit@debbugs.gnu.org; Tue, 20 Jun 2023 03:51:28 -0400 Received: from mail-lf1-f54.google.com ([209.85.167.54]:56569) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBW94-00053m-Nk for 64188@debbugs.gnu.org; Tue, 20 Jun 2023 03:51:23 -0400 Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-4f866a3d8e4so3734167e87.0 for <64188@debbugs.gnu.org>; Tue, 20 Jun 2023 00:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687247476; x=1689839476; 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=s+4t5DdUHTaWV4XSXAE8le0FxTs+pztfyGUuJdYMBZg=; b=L/z/P9IhBdAo/NNNY2RPrbUoOuZwZdjDpM3j6ilDXWRwxodVVJqge5mPdeN3dFpqg4 3MmM8cnYYh73VjhLqHYatrw+ysCthf4+kHo/VNPA8+N4l8DpUWmh1wslFwLgqRyw3jJi 4ZLik51RpzzbaqD0N5AinIjSmHtVDLdQLgf6Wy9FKY0Ct/4x69tWCNwa4B3b7LXETR58 7I94arlCKFvZnFuWdE1zLMwGBehh/AQm4MoTaVqadoqiLQ2coHIov/+6Oy8s4HrQZl1Q FaRakOlVYgVOxzcM5QJoEn58Zf0ecrPzXk1YNW5o4YJt6Mec1Mj+ZVqarOUXzwibookl lOpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247476; x=1689839476; 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=s+4t5DdUHTaWV4XSXAE8le0FxTs+pztfyGUuJdYMBZg=; b=Bhmf8wQ891FDSmnmum9uSWmcVGYfbvRXiD840u4lo52Un4rM5DW0EtMrP4i3b0pYo+ GwOfjgD+v/tPb0W3mJ++mF+oJOHpScbKZacb0m+crhG5W1KoC8bb8xUbY1slOWLXnPju jttgBQrEf48oXx53FtaTAK/t3CysX1v+1IFi9m1HY2wzdQtYcc5UJM3ntPbDV25n2Yje 84jASI3Nggc4p9tVG9FVWld7q6ygDqqd1yPFqkMhZLafpWQmiD2K/mKTBWV2WWg0TME9 zTTwOi7UoQ2l/w1jqDNqzuhgrJC7fhkdzJ2kxchAcn3mwClbRCmhWJJN/bHugVOccn3n XdyA== X-Gm-Message-State: AC+VfDzfHMQYckpGa9XwhswLaBmYaQ+dEg5Fndsqf6uEmA7gebKsGIpS SN52oGDtrofrBuvbBpih2iTaG//TR0qrJbcb X-Google-Smtp-Source: ACHHUZ7qNWXgwzdo2afU1oj63AQWDR7tU4vaz8ZfDMob3EiGJgTj9pXYztbrxqPyQb6dWvrXi2kKcQ== X-Received: by 2002:a19:4409:0:b0:4f8:7556:23e6 with SMTP id r9-20020a194409000000b004f8755623e6mr2029931lfa.54.1687247476231; Tue, 20 Jun 2023 00:51:16 -0700 (PDT) Received: from localhost ([188.120.129.124]) by smtp.gmail.com with ESMTPSA id x11-20020adff0cb000000b003112d12a1ecsm1312246wro.98.2023.06.20.00.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:51:15 -0700 (PDT) From: Efraim Flashner Date: Tue, 20 Jun 2023 10:51:07 +0300 Message-Id: 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]: Don't replace the build-system if inheriting from the go-build-system. [arguments]: If using the go-build-system add a phase to set the micro-architecture for Go. --- guix/transformations.scm | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/guix/transformations.scm b/guix/transformations.scm index a289f81219..47eb4b0515 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2016-2023 Ludovic Courtès ;;; Copyright © 2021 Marius Bakke ;;; Copyright © 2023 Sarthak Shah +;;; Copyright © 2023 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -570,14 +571,42 @@ (define (tuned-package p micro-architecture) (package (inherit p) (build-system - (build-system-with-tuning-compiler (package-build-system p) - micro-architecture)) + ;; 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) + (package-build-system p) + (build-system-with-tuning-compiler (package-build-system p) + 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 ;; the "baseline" variant anyway. (substitute-keyword-arguments (package-arguments p) - ((#:tests? _ #f) #f))) + ((#:tests? _ #f) #f) + ;; We add the tuning parameter after the default GO flags are set. + ((#:phases phases '%standard-phases) + (if (eq? (build-system-name (package-build-system p)) + 'go) + #~(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)))))) + phases)))) (properties `((cpu-tuning . ,micro-architecture)