all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thiago Jung Bauermann via Guix-patches via <guix-patches@gnu.org>
To: 49672@debbugs.gnu.org
Cc: Thiago Jung Bauermann <bauermann@kolabnow.com>
Subject: [bug#49672] [PATCH 2/9] utils: Add ‘current-target-nix-system’ helper
Date: Tue, 20 Jul 2021 22:00:36 -0300	[thread overview]
Message-ID: <20210721010043.632012-2-bauermann@kolabnow.com> (raw)
In-Reply-To: <20210721010043.632012-1-bauermann@kolabnow.com>

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\"




  reply	other threads:[~2021-07-21  1:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21  0:46 [bug#49672] [PATCH 0/9] Target check fixes and cleanups Thiago Jung Bauermann via Guix-patches via
2021-07-21  1:00 ` [bug#49672] [PATCH 1/9] gnu: Fix check of ‘%current-system’ and ‘%current-target-system’ Thiago Jung Bauermann via Guix-patches via
2021-07-21  1:00   ` Thiago Jung Bauermann via Guix-patches via [this message]
2021-07-21  1:00   ` [bug#49672] [PATCH 3/9] gnu: Query membership in ‘supported-systems’ list with Nix identifier Thiago Jung Bauermann via Guix-patches via
2021-07-21  1:00   ` [bug#49672] [PATCH 4/9] gnu: Use ‘current-target-nix-system’ in pattern matches Thiago Jung Bauermann via Guix-patches via
2021-07-21  1:00   ` [bug#49672] [PATCH 5/9] gnu: Use ‘current-target-nix-system’ in prefix checks Thiago Jung Bauermann via Guix-patches via
2021-07-21  1:00   ` [bug#49672] [PATCH 6/9] gnu: Fix GNU/Linux system detection Thiago Jung Bauermann via Guix-patches via
2021-07-21  1:00   ` [bug#49672] [PATCH 7/9] bootloader: grub: Fix mix of GNU triplet and Nix system identifier Thiago Jung Bauermann via Guix-patches via
2021-07-21  1:00   ` [bug#49672] [PATCH 8/9] gnu: ustr: Don’t pass default argument Thiago Jung Bauermann via Guix-patches via
2021-07-21  1:00   ` [bug#49672] [PATCH 9/9] gnu: Use existing target helpers from ‘(guix utils)’ Thiago Jung Bauermann via Guix-patches via
2021-11-07 11:23 ` [bug#49672] [PATCH 0/9] Target check fixes and cleanups Maxime Devos
2021-11-12  0:56   ` Thiago Jung Bauermann via Guix-patches via
2022-03-27 21:40 ` [bug#49672] [PATCH v2 0/6] Target check fixes for cross compilation Thiago Jung Bauermann via Guix-patches via
2022-03-27 21:40   ` [bug#49672] [PATCH v2 1/6] gnu: Fix GNU/Linux system detection Thiago Jung Bauermann via Guix-patches via
2022-03-27 21:40   ` [bug#49672] [PATCH v2 2/6] gnu: libgc: Use default argument in ‘target-hurd?’ call Thiago Jung Bauermann via Guix-patches via
2022-03-27 21:40   ` [bug#49672] [PATCH v2 3/6] utils: Introduce the ‘current-target-nix-system’ procedure Thiago Jung Bauermann via Guix-patches via
2022-03-27 21:40   ` [bug#49672] [PATCH v2 4/6] gnu: Use ‘current-target-nix-system’ for matches Thiago Jung Bauermann via Guix-patches via
2022-03-27 21:40   ` [bug#49672] [PATCH v2 5/6] gnu: Query membership in ‘supported-systems’ list with Nix identifier Thiago Jung Bauermann via Guix-patches via
2022-03-27 21:40   ` [bug#49672] [PATCH v2 6/6] gnu: Fix check of ‘%current-system’ and ‘%current-target-system’ Thiago Jung Bauermann via Guix-patches via
2022-03-28 12:10   ` [bug#49672] [PATCH v2 0/6] Target check fixes for cross compilation Maxime Devos
2022-03-29  0:12     ` Thiago Jung Bauermann via Guix-patches via
2022-04-29  4:17   ` Thiago Jung Bauermann via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210721010043.632012-2-bauermann@kolabnow.com \
    --to=guix-patches@gnu.org \
    --cc=49672@debbugs.gnu.org \
    --cc=bauermann@kolabnow.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.