From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 20 21:01:29 2021 Received: (at 49672) by debbugs.gnu.org; 21 Jul 2021 01:01:29 +0000 Received: from localhost ([127.0.0.1]:35751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m60c5-00006l-DX for submit@debbugs.gnu.org; Tue, 20 Jul 2021 21:01:29 -0400 Received: from mx.kolabnow.com ([95.128.36.40]:59496) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m60c1-00006B-B4 for 49672@debbugs.gnu.org; Tue, 20 Jul 2021 21:01:25 -0400 Received: from localhost (unknown [127.0.0.1]) by ext-mx-out003.mykolab.com (Postfix) with ESMTP id A2FD0405B8 for <49672@debbugs.gnu.org>; Wed, 21 Jul 2021 03:01:19 +0200 (CEST) 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= 1626829279; x=1628643680; bh=GFRSO9hwK9Ix1U2vSpPPEERhAc0ECXwS5jo cGimT+Cw=; b=ohrHIfcTTh8PR6D4QkR/uSL0vv1SHBXl0DM0uWrQlirdSS5oqNr 4Jp2ACvLqfujSuifP5mOrH7k/02T4UcxRRPF/7gfyBv+lAxAk2WsJPNd0VkeenEY eN4OhkbTocXFhjNZ+Hg2pzQzHjAQCBEPttrF6h56kMGAEtP+D6IOMyXEcaSq9ihf wSienpbBxnUQpXJjYmAg0AwkqlCm1I3pEUgpa7g5AjVdCuKCA2/0cMDBaE6BOtEG HIpdbd0Yamx4zROa+W/Y5SIEqq2aCdiQ+IhNnVxeBgdfSOs9hb1Y3VBxyqdPJ3PO mMQVedduyGWb1g6P4+hDMuASWyDPST2SAf6gVRhCEukpUGhSYcNW5nrJn4J7OsOP p1hFV6LamlQv7PzVc8OziATGcIEhIPXYOvdBa+yiD4aiTS8EDBMT3UO+jzDSYxaX GGKpZjA1dIsMhfoALFn3/08jY0vrtmvuFskcckgHe9VkjRYEpVXdtvYcEyQq4Uke YqWN1+PWHIRHf1WXfsLF6BQJAeAO9BhiKuLKandnHK27rvVfLV+R35a68O+vilVp uxhHOKujOC6Aci8yivDQS2U+gDqaqSfhlWpgRQLYIXlKtlDGtGpkfcVwmqFGxPB0 ifEcSNIZa0r+VN8cXqmxKoDyV+aowxnlS9gserZb6uow5Ny+6ig8+95w= X-Virus-Scanned: amavisd-new at mykolab.com X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-10 required=5 tests=[BAYES_00=-1.9] autolearn=ham autolearn_force=no Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out003.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id st6Qh1x9Aou1 for <49672@debbugs.gnu.org>; Wed, 21 Jul 2021 03:01:19 +0200 (CEST) Received: from int-mx001.mykolab.com (unknown [10.9.13.1]) by ext-mx-out003.mykolab.com (Postfix) with ESMTPS id 06063403CB for <49672@debbugs.gnu.org>; Wed, 21 Jul 2021 03:01:17 +0200 (CEST) Received: from ext-subm003.mykolab.com (unknown [10.9.6.3]) by int-mx001.mykolab.com (Postfix) with ESMTPS id 12B0F323; Wed, 21 Jul 2021 03:01:16 +0200 (CEST) From: Thiago Jung Bauermann To: 49672@debbugs.gnu.org Subject: [PATCH 2/9] =?UTF-8?q?utils:=20Add=20=E2=80=98current-target-nix-?= =?UTF-8?q?system=E2=80=99=20helper?= Date: Tue, 20 Jul 2021 22:00:36 -0300 Message-Id: <20210721010043.632012-2-bauermann@kolabnow.com> In-Reply-To: <20210721010043.632012-1-bauermann@kolabnow.com> References: <20210721010043.632012-1-bauermann@kolabnow.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49672 Cc: Thiago Jung Bauermann X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Many places check a Nix system identifier string against ‘%current-target-system’ and ‘%current-target’. This is problematic because these parameters hold different kinds of identifiers. The former holds a GNU triplet (or #f if not cross-compiling), while the latter holds a Nix system identifier. As a first step to solve the confusion, introduce the ‘current-target-nix-system’ procedure which looks at both parameters and always returns a Nix system identifier. The code is factored out from ‘glibc-dynamic-linker’ and ‘system->llvm-target’. * 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 new procedure. --- gnu/packages/bootstrap.scm | 6 ++---- gnu/packages/llvm.scm | 4 +--- guix/utils.scm | 7 +++++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index c598cedc0ae2..b7134653cfc4 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -35,7 +35,7 @@ #:select (run-with-store add-to-store add-text-to-store)) #:use-module ((guix derivations) #:select (derivation derivation-input derivation->output-path)) - #:use-module ((guix utils) #:select (gnu-triplet->nix-system)) + #:use-module (guix utils) #:use-module ((guix gexp) #:select (lower-object)) #:use-module (guix memoization) #:use-module (guix i18n) @@ -286,9 +286,7 @@ or false to signal an error." 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 575c63c713e9..3c4e5930d044 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -66,9 +66,7 @@ #:export (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 2c56c8b2e08b..4072dea89051 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -77,6 +77,7 @@ gnu-triplet->nix-system %current-system %current-target-system + current-target-nix-system package-name->name+version target-mingw? target-arm32? @@ -520,6 +521,12 @@ returned by `config.guess'." ;; 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\"