From patchwork Fri Nov 8 10:44:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 70119 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 8EE6E27BBEA; Fri, 8 Nov 2024 10:45:37 +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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 014DC27BBE2 for ; Fri, 8 Nov 2024 10:45:37 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9MUV-0008Fp-Fk; Fri, 08 Nov 2024 05:45:23 -0500 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 1t9MUJ-00086b-Ao for guix-patches@gnu.org; Fri, 08 Nov 2024 05:45:12 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9MUH-0006OK-4U; Fri, 08 Nov 2024 05:45:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=ZE+YnHjYRfo9BFqJaCKkYU0joU4rkR5LbNyaosUECDY=; b=auaI+B52lfziiBZ/FH16iCUpdskPXoUPgGlkDfBdUyUIhFuS/mZkhuHKBH0uXzSLMFG1MuhMFPmOpfWQ3W2bWJNeOMDoxFR1yCJ2/lgazubS9rWr6zi9S3i9DsFd41BJM0RtSp2s+e7Qu809j6rFYkO3fjpM1kIdSU5VEZQvpcxpLDp0SuPuqOsMujsIPWg5Oxm1w4lKlO/gmf7dS8rmpxwSCWxzErbHOwuu61+1VhzC6LJaCb/Aa8FJ5IKmCI7qQoRzIHNdsKmrfbsSbFOh+kbaiisuU79gopkdpj1vPnteeUJhN3ZnJfmOlIJ1rlPIjIf/erTtP7/9K2Rkv6frpA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t9MUA-00081M-Kl; Fri, 08 Nov 2024 05:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74253] [PATCH] transformations: Add multituned-package. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 08 Nov 2024 10:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74253 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74253@debbugs.gnu.org Cc: Efraim Flashner , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.173106267530775 (code B ref -1); Fri, 08 Nov 2024 10:45:02 +0000 Received: (at submit) by debbugs.gnu.org; 8 Nov 2024 10:44:35 +0000 Received: from localhost ([127.0.0.1]:51248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9MTi-00080G-Kq for submit@debbugs.gnu.org; Fri, 08 Nov 2024 05:44:35 -0500 Received: from lists.gnu.org ([209.51.188.17]:59458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9MTd-000803-Ej for submit@debbugs.gnu.org; Fri, 08 Nov 2024 05:44:32 -0500 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 1t9MTc-0006XR-Dt for guix-patches@gnu.org; Fri, 08 Nov 2024 05:44:28 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9MTa-0006Ba-CV for guix-patches@gnu.org; Fri, 08 Nov 2024 05:44:28 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-43161c0068bso17477845e9.1 for ; Fri, 08 Nov 2024 02:44:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731062664; x=1731667464; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=ZE+YnHjYRfo9BFqJaCKkYU0joU4rkR5LbNyaosUECDY=; b=WuefaQSYs8A/XmrmKbCxi1JOV62/SG1L+NQmDuXsBTteOX4Wxd1CruE7Av+85vcM9W EouJMr496+NOmidSCtggNP3fKc6K4oJMPL3ET4NBqmrpM2EW5K0xKlxxC41OFNtZ5U2g 6VYvWYdNVt6Y2bqC6TH1WNdWcmSbhStmiURLABxLCGSn9049dVaafaxWA1QrV50gFM1Q UNNV6Yb1qBnFjkE7AgHWaShvWvl99z5Mx5RjJC7WLkk/NfAwU9/az5CBoRL0p5oFhIGY 8MTVRWz8mwb/kx/h0e0DZ5xi2PdDGsbVG24hef8D2LrxqPmnBhgTlfs9VRYFKX/1pxGN WIBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731062664; x=1731667464; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZE+YnHjYRfo9BFqJaCKkYU0joU4rkR5LbNyaosUECDY=; b=mmSDP055/KYESq7RQivN9zYTHzYsnslLcuEj2IVW6OIrO0Wg2QJuJpYbopUehSzuUf ie7qFmk8RhI6IefSi8a2s2o6Flg4SyDcRMniNJtNHq7QuSlyVof+Kd/5rpF7wRL7nEXY 3JDboL69uNpDDSBQZFS+rdtoO7BH52Nc8iIOpJqZ4jYTe72KdjQ32d12HTGD0IQo/N/k F5JAShDOMKmbaF5o0SJyWnltPH+b1tnT9BcgZwCb0o5InoiSptBlLEmM/wW4d0Tm+05a mKljnusdXZi8Bu82mnWeJw6pNvBqY6+bjgIaiTX4yHR04f75yYrGAkXAKyXv22W5lpY7 U+nQ== X-Gm-Message-State: AOJu0Ywd7gv7uCsGaV2sitoaylSHPsxDRrdxx8qh24oySqC0WlTBuoNS kK22PqWy3RVDuIr94y2cr7t4cyLbzFkeU1zneYkt8vLvPYi/iYy/80W4kg== X-Google-Smtp-Source: AGHT+IHRGSIXm1U25llVHu0fRj4QUN6ahMdbTjIQUC8gscZ+sZ8Jb/B+XYvbmBr+jtj2Z0/uzpaGRA== X-Received: by 2002:a05:600d:b:b0:432:bb4d:cd63 with SMTP id 5b1f17b1804b1-432bb4dce85mr1564255e9.18.1731062664093; Fri, 08 Nov 2024 02:44:24 -0800 (PST) Received: from localhost ([141.226.162.35]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432aa70a1e9sm97724085e9.29.2024.11.08.02.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 02:44:23 -0800 (PST) From: Efraim Flashner Date: Fri, 8 Nov 2024 12:44:15 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=efraim.flashner@gmail.com; helo=mail-wm1-x333.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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 (package-tuned-for-psabi, multituned-package): New variables. Change-Id: I09ac7ae9fc2bcd9aa712b3c30fef807bc7d55895 --- This allows wrapping a package definition in multituned-package, ie: (define-public opus (multituned-package (package ...))) I'm not sure where to go with this patch from here. This will provide the psabi libraries for x86_64 and powerpc64le so they get most of the benefits from tuning for the architecture but without needing to specify which architecture to tune for. It should also provide a nice boost for guix packs and docker images and the like. The downside with using this by default is the larger package size due to the extra versions of the libraries, and if it is used then the regular --tune is disabled for that package. I think adding it as a '--tune=generic' or '--tune=psabi' would be a nice way to use it. guix/transformations.scm | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) base-commit: 2a6d96425eea57dc6dd48a2bec16743046e32e06 diff --git a/guix/transformations.scm b/guix/transformations.scm index ea8b7a08443..4787e016b5d 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -60,6 +60,7 @@ (define-module (guix transformations) tunable-package? tuned-package + multituned-package show-transformation-options-help transformation-option-key? @@ -634,6 +635,80 @@ (define (tuned-package p micro-architecture) ;; call 'tuned-package' again on this one. ,@(alist-delete 'tunable? (package-properties p)))))) +(define (package-tuned-for-psabi p psabi) + (let ((base (tuned-package p psabi))) + (package/inherit base + (name (string-append (package-name base) "-" psabi)) + (arguments + (substitute-keyword-arguments (package-arguments base) + ((#:configure-flags flags #~'()) + #~(append + (list + #$@(if (eq? (build-system-name (package-build-system p)) ; not base + (quote cmake-build-system)) + #~((string-append "-DCMAKE_INSTALL_LIBDIR=lib/glibc-hwcaps/" + #$psabi)) + #~((string-append "--libdir=" #$output + "/lib/glibc-hwcaps/" #$psabi)))) + #$flags)) + ((#:phases phases #~%standard-phases) + #~(modify-phases #$phases + (add-after 'install 'remove-extra-files + (lambda _ + (for-each (lambda (dir) + (when (file-exists? (string-append #$output dir)) + (delete-file-recursively + (string-append #$output dir)))) + (list (string-append "/lib/glibc-hwcaps/" + #$psabi "/cmake") + (string-append "/lib/glibc-hwcaps/" + #$psabi "/pkgconfig") + "/bin" "/etc" "/include" "/libexec" + "/sbin" "/share" "/var"))))))))))) + +(define (multituned-package p) + (package/inherit p + (arguments + (substitute-keyword-arguments (package-arguments p) + ((#:phases phases #~%standard-phases) + (if (or (target-x86-64?) + (target-ppc64le?)) + #~(modify-phases #$phases + (add-after 'install 'install-optimized-libraries + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((hwcaps "/lib/glibc-hwcaps/")) + (for-each + (lambda (psabi) + (copy-recursively + (string-append + (assoc-ref inputs (string-append + #$(package-name p) "-" psabi)) + hwcaps psabi) + (string-append #$output hwcaps psabi))) + #$(cond ((target-x86-64?) + #~(list "x86-64-v2" "x86-64-v3" "x86-64-v4")) + ((target-ppc64le?) + #~(list "power9" "power10")) + (#t #~'()))))))) + phases)))) + (inputs + (cond ((target-x86-64?) + (modify-inputs (package-inputs p) + (append (package-tuned-for-psabi p "x86-64-v2") + (package-tuned-for-psabi p "x86-64-v3") + (package-tuned-for-psabi p "x86-64-v4")))) + ((target-ppc64le?) + (modify-inputs (package-inputs p) + (append (package-tuned-for-psabi p "power9") + (package-tuned-for-psabi p "power10")))) + (#t (package-inputs p)))) + ;; With the addition of the psABIs this package should not be tuned. + (properties + (if (or (target-x86-64?) + (target-ppc64le?)) + '((alist-delete 'tunable? (package-properties p))) + (package-properties p))))) + (define (tunable-package? package) "Return true if package PACKAGE is \"tunable\"--i.e., if tuning it for the host CPU is worthwhile."