[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#49672] [PATCH v2 3/6] utils: Introduce the ‘current-target-nix-syst
From: |
Thiago Jung Bauermann |
Subject: |
[bug#49672] [PATCH v2 3/6] utils: Introduce the ‘current-target-nix-system’ procedure |
Date: |
Sun, 27 Mar 2022 18:40:23 -0300 |
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\"
- [bug#49672] [PATCH v2 0/6] Target check fixes for cross compilation, Thiago Jung Bauermann, 2022/03/27
- [bug#49672] [PATCH v2 1/6] gnu: Fix GNU/Linux system detection, Thiago Jung Bauermann, 2022/03/27
- [bug#49672] [PATCH v2 2/6] gnu: libgc: Use default argument in ‘target-hurd?’ call, Thiago Jung Bauermann, 2022/03/27
- [bug#49672] [PATCH v2 6/6] gnu: Fix check of ‘%current-system’ and ‘%current-target-system’, Thiago Jung Bauermann, 2022/03/27
- [bug#49672] [PATCH v2 4/6] gnu: Use ‘current-target-nix-system’ for matches, Thiago Jung Bauermann, 2022/03/27
- [bug#49672] [PATCH v2 5/6] gnu: Query membership in ‘supported-systems’ list with Nix identifier, Thiago Jung Bauermann, 2022/03/27
- [bug#49672] [PATCH v2 3/6] utils: Introduce the ‘current-target-nix-system’ procedure,
Thiago Jung Bauermann <=
- [bug#49672] [PATCH v2 0/6] Target check fixes for cross compilation, Maxime Devos, 2022/03/28