[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/22: utils: Define a target-x86-32? and target-x86-64? predicate.
From: |
guix-commits |
Subject: |
04/22: utils: Define a target-x86-32? and target-x86-64? predicate. |
Date: |
Wed, 14 Jul 2021 13:20:48 -0400 (EDT) |
mothacehe pushed a commit to branch core-updates
in repository guix.
commit f54852be22c29a0d5b174d15ef6189c57cab2017
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Wed Jul 14 13:12:49 2021 +0200
utils: Define a target-x86-32? and target-x86-64? predicate.
* guix/utils.scm (target-x86-32?, target-x86-64?): New predicates.
* tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
---
guix/utils.scm | 20 ++++++++++++++++++++
tests/utils.scm | 23 +++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/guix/utils.scm b/guix/utils.scm
index fe1439a..b75710e 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -87,6 +87,8 @@
target-linux?
target-hurd?
target-mingw?
+ target-x86-32?
+ target-x86-64?
target-arm32?
target-aarch64?
target-arm?
@@ -654,6 +656,24 @@ a character other than '@'."
;; are 64-bit.
(string-suffix? "-mingw32" target)))
+(define* (target-x86-32? #:optional (target (or (%current-target-system)
+ (%current-system))))
+ "Is the architecture of TARGET a variant of Intel's 32-bit architecture
+(IA32)?"
+ ;; Intel also has a 16-bit architecture in the iN86 series, i286
+ ;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this
+ ;; procedure is not named target-x86?.
+ (or (string-prefix? "i386-" target)
+ (string-prefix? "i486-" target)
+ (string-prefix? "i586-" target)
+ (string-prefix? "i686-" target)))
+
+(define* (target-x86-64? #:optional (target (or (%current-target-system)
+ (%current-system))))
+ "Is the architecture of TARGET a variant of Intel/AMD's 64-bit
+architecture (x86_64)?"
+ (string-prefix? "x86_64-" target))
+
(define* (target-arm32? #:optional (target (or (%current-target-system)
(%current-system))))
(string-prefix? "arm" target))
diff --git a/tests/utils.scm b/tests/utils.scm
index e170070..648e91f 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -306,6 +306,29 @@ skip these tests."
'("i686-linux-gnu" "i686-pc-gnu"
"i686-w64-mingw32")))
+(test-equal "target-x86-32?"
+ '(#f #f #f #t #t #t #t #f)
+ ;; These are (according to Wikipedia) two RISC architectures
+ ;; by Intel and presumably not compatible with the x86-32 series.
+ (map target-x86-32?
+ '("i860-gnu" "i960-gnu"
+ ;; This is a 16-bit architecture
+ "i286-gnu"
+ ;; These are part of the x86-32 series.
+ "i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu"
+ ;; Maybe this one will exist some day, but not yet.
+ "i786-gnu")))
+
+(test-equal "target-x86-64?"
+ '(#t #f #f #f)
+ (map target-x86-64?
+ `("x86_64-linux-gnu" "i386-linux-gnu"
+ ;; Just because it includes "64" doesn't make it 64-bit.
+ "aarch64-linux-gnu"
+ ;; Note that (expt 2 109) in decimal notation starts with 64.
+ ;; However, it isn't 32-bit.
+ ,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
+
(test-end)
(false-if-exception (delete-file temp-file))
- 09/22: libgpg-error: Prevent silent miscompilation some systems., (continued)
- 09/22: libgpg-error: Prevent silent miscompilation some systems., guix-commits, 2021/07/14
- 05/22: packages: Define this-package-input and this-package-native-input., guix-commits, 2021/07/14
- 02/22: utils: Define 'target-hurd?' predicate., guix-commits, 2021/07/14
- 06/22: net-base: Don't cross-compile., guix-commits, 2021/07/14
- 14/22: openssl: Use G-exp machinery for referring to outputs., guix-commits, 2021/07/14
- 20/22: glib: Look up "tzdata" in 'native-inputs', not 'inputs'., guix-commits, 2021/07/14
- 21/22: libelf: Update configure script and config.guess and config.sub., guix-commits, 2021/07/14
- 15/22: openssl: Move documentation instead of copying and deleting it., guix-commits, 2021/07/14
- 19/22: glib: Verify the cross-compiled python is used in installed scripts., guix-commits, 2021/07/14
- 16/22: openssl: Move all man pages to separate output, not only man3., guix-commits, 2021/07/14
- 04/22: utils: Define a target-x86-32? and target-x86-64? predicate.,
guix-commits <=
- 01/22: utils: Define 'target-linux?' predicate., guix-commits, 2021/07/14
- 03/22: utils: Give 'target-mingw?' a docstring., guix-commits, 2021/07/14
- 08/22: libgpg-error: Remove trailing #f from phases., guix-commits, 2021/07/14
- 10/22: libgpg-error: Fix cross-compilation error., guix-commits, 2021/07/14
- 18/22: glib: Use a correct python in scripts when cross-compiling., guix-commits, 2021/07/14
- 17/22: openssl: Extract logic for computing CONFIGURE_TARGET_ARCH., guix-commits, 2021/07/14
- 11/22: python: Fix reference to input when cross-compiling., guix-commits, 2021/07/14
- 12/22: openssl: Remove trailing #t from phases., guix-commits, 2021/07/14
- 13/22: openssl: Make the #:phases argument a G-expression., guix-commits, 2021/07/14
- 22/22: build-system/meson: Support cross-compilation., guix-commits, 2021/07/14