From patchwork Sun Mar 27 21:40:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 38155 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 C60D427BBEA; Sun, 27 Mar 2022 22:51:17 +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=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 55FDD27BBE9 for ; Sun, 27 Mar 2022 22:51:17 +0100 (BST) Received: from localhost ([::1]:39424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYan6-00018j-I9 for patchwork@mira.cbaines.net; Sun, 27 Mar 2022 17:51:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYams-00018O-87 for guix-patches@gnu.org; Sun, 27 Mar 2022 17:51:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYamr-0006hH-Vk for guix-patches@gnu.org; Sun, 27 Mar 2022 17:51:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nYamr-0004o8-Ji for guix-patches@gnu.org; Sun, 27 Mar 2022 17:51:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49672] [PATCH v2 3/6] utils: Introduce the =?utf-8?q?=E2=80=98?= =?utf-8?q?current-target-nix-system=E2=80=99?= procedure Resent-From: Thiago Jung Bauermann Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 27 Mar 2022 21:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49672 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49672@debbugs.gnu.org Cc: Maxime Devos , Thiago Jung Bauermann Received: via spool by 49672-submit@debbugs.gnu.org id=B49672.164841785218462 (code B ref 49672); Sun, 27 Mar 2022 21:51:01 +0000 Received: (at 49672) by debbugs.gnu.org; 27 Mar 2022 21:50:52 +0000 Received: from localhost ([127.0.0.1]:56708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nYamh-0004ng-Oy for submit@debbugs.gnu.org; Sun, 27 Mar 2022 17:50:52 -0400 Received: from mx.kolabnow.com ([212.103.80.154]:3440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nYamf-0004nT-Jw for 49672@debbugs.gnu.org; Sun, 27 Mar 2022 17:50:50 -0400 Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id E54031A0D; Sun, 27 Mar 2022 23:41:00 +0200 (CEST) Authentication-Results: ext-mx-out001.mykolab.com (amavisd-new); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:date:subject:subject :from:from:received:received:received; s=dkim20160331; t= 1648417260; x=1650231661; bh=UCCO8iMFjJihEEtub0kvSDOnPlu+KT7clTY WTK8y2Z8=; b=wa/6iKOSIp7N7yIZgAvGsqY8ZtiPgAJk8XX9uVxErxZw3tbBfxs GcBqf+ShFZecMuxsVf8H2M165v1wNUsg/JTGmfX27Dr4SjzTP8jlh2LeA1Hs0YFI ybBPbWINmAe2Tx0Z0K+3AqflCKZ3UZwq0IKt9bI6FkXHrJNiKPXIKeHSiGTerRVD fBM5NVMFNqQ81HKJmQ1tOp3St0Xw5Zk01NzdyLxeDetnJf/UIP377+WfZgyuRtBQ tCciophfHoJdoTPXmzri2PBn9NwhP9ZWLCAjH8sBPXLzuF+X2rjdUr/AwTID5kyw bggYFeAOlk3SO3sIrVVmQAAc6BQJ9BXX2wDMmZ9xiwyLup/ebCQr6SycMzS7DqVf 6lGUeu6CKR2ja3o/mYzkV3/qYAVQGC89kZBGGCbePPNOjNZjA6YSLdE5zN8FfHRJ wmvXazJUIAKUW4Lvycc7dt/LOTsoi27VLIhAPhUkhHTzQCIahhTEO7NyBvZanNvp srbDsZYJ1VrpQDqpsT0lzGh14qFLB4KHYLgiR89C1c/+0KDzkqk/GddkWalp93cn W21ghzIt9ylUQoqp4cG89ZoYgpWG0puEUipUflDnX4AvQf94f+bxu3SgL1Tn0VfR YzDnlY1LB7E+kkEoMwFbn99E4mUrCaHB+ufBi6asPnAtHBKgEhpi/YFA= X-Virus-Scanned: amavisd-new at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out001.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6cTEAJDDo5ia; Sun, 27 Mar 2022 23:41:00 +0200 (CEST) Received: from int-mx001.mykolab.com (unknown [10.9.13.1]) by mx.kolabnow.com (Postfix) with ESMTPS id C8A5F14D8; Sun, 27 Mar 2022 23:40:50 +0200 (CEST) Received: from ext-subm001.mykolab.com (unknown [10.9.6.1]) by int-mx001.mykolab.com (Postfix) with ESMTPS id 496EBBC9; Sun, 27 Mar 2022 23:40:50 +0200 (CEST) Date: Sun, 27 Mar 2022 18:40:23 -0300 Message-Id: <20220327214026.102723-4-bauermann@kolabnow.com> In-Reply-To: <20220327214026.102723-1-bauermann@kolabnow.com> References: <20220327214026.102723-1-bauermann@kolabnow.com> 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" Reply-to: Thiago Jung Bauermann X-ACL-Warn: , Thiago Jung Bauermann via Guix-patches X-Patchwork-Original-From: Thiago Jung Bauermann via Guix-patches via From: Thiago Jung Bauermann X-getmail-retrieved-from-mailbox: Patches Both ‘glibc-dynamic-linker’ and ‘system->llvm-target’ use the same logic for the default value of their arguments, so factor it out into a separate procedure. It turns out that this procedure will be useful in other places as well. * gnu/packages/bootstrap.scm (glibc-dynamic-linker): Use result of ‘current-target-nix-system’ as default value for ‘system’ argument. * gnu/packages/llvm.scm (system->llvm-target): Likewise. * guix/utils.scm (current-target-nix-system): Define. --- gnu/packages/bootstrap.scm | 4 +--- gnu/packages/llvm.scm | 4 +--- guix/utils.scm | 7 +++++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index 8bd0c4eaf3ab..8f444b1ff338 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -309,9 +309,7 @@ (define rewritten-input package-with-bootstrap-guile))))) (define* (glibc-dynamic-linker - #:optional (system (or (and=> (%current-target-system) - gnu-triplet->nix-system) - (%current-system)))) + #:optional (system (current-target-nix-system))) "Return the name of Glibc's dynamic linker for SYSTEM." ;; See the 'SYSDEP_KNOWN_INTERPRETER_NAMES' cpp macro in libc. (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2") diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index eb949bed1b47..e2bc5398715a 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -77,9 +77,7 @@ (define-module (gnu packages llvm) system->llvm-target)) (define* (system->llvm-target #:optional - (system (or (and=> (%current-target-system) - gnu-triplet->nix-system) - (%current-system)))) + (system (current-target-nix-system))) "Return the LLVM target name that corresponds to SYSTEM, a system type such as \"x86_64-linux\"." ;; See the 'lib/Target' directory of LLVM for a list of supported targets. diff --git a/guix/utils.scm b/guix/utils.scm index 44c46cb4a96c..d5e15581acea 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -85,6 +85,7 @@ (define-module (guix utils) gnu-triplet->nix-system %current-system %current-target-system + current-target-nix-system package-name->name+version target-linux? target-hurd? @@ -635,6 +636,12 @@ (define %current-target-system ;; cross-building to. (make-parameter #f)) +(define (current-target-nix-system) + "Return the Nix system identifier for the current target, whether we are +cross-building or not." + (or (and=> (%current-target-system) gnu-triplet->nix-system) + (%current-system))) + (define* (package-name->name+version spec #:optional (delimiter #\@)) "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"