summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2022-05-07 16:45:40 +0200
committerMathieu Othacehe <othacehe@gnu.org>2022-05-22 15:15:33 +0200
commitb55310603f0df7d5ae02d47cb8d4be58bf1d41ca (patch)
treefae12dd0399909cb09b3162934f198803f4a19cc
parent4cf7d0f836d08fd41aab02e1f6793146ce3cad8d (diff)
linux: Remove system->linux-architecture procedure.
* gnu/packages/linux.scm (system->linux-architecture): Remove it. (make-linux-libre-headers*, make-linux-libre*): Adapt them. * guix/build-system/linux-module.scm (system->arch): Adapt it. * gnu/packages/instrumentation.scm (uftrace): Ditto. * gnu/packages/cross-base.scm (cross-kernel-headers): Ditto. * gnu/packages/bioinformatics.scm (ncbi-vdb): Ditto. * doc/guix.texi (Porting to a new platform): Update it.
-rw-r--r--doc/guix.texi30
-rw-r--r--gnu/packages/bioinformatics.scm11
-rw-r--r--gnu/packages/cross-base.scm4
-rw-r--r--gnu/packages/instrumentation.scm8
-rw-r--r--gnu/packages/linux.scm34
-rw-r--r--guix/build-system/linux-module.scm4
6 files changed, 45 insertions, 46 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 761fceb9c3..df9cbf4851 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -40276,20 +40276,22 @@ one:
guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
@end example
-For this to work, the @code{glibc-dynamic-linker} procedure in
-@code{(gnu packages bootstrap)} must be augmented to return the right
-file name for libc's dynamic linker on that platform; likewise,
-@code{system->linux-architecture} in @code{(gnu packages linux)} must be
-taught about the new platform.
-
-Once these are built, the @code{(gnu packages bootstrap)} module needs
-to be updated to refer to these binaries on the target platform. That
-is, the hashes and URLs of the bootstrap tarballs for the new platform
-must be added alongside those of the currently supported platforms. The
-bootstrap Guile tarball is treated specially: it is expected to be
-available locally, and @file{gnu/local.mk} has rules to download it for
-the supported architectures; a rule for the new platform must be added
-as well.
+For this to work, it is first required to register a new platform as
+defined in the @code{(gnu platform)} module. A platform is making the
+connection between a GNU triplet (@pxref{Specifying Target Triplets, GNU
+configuration triplets,, autoconf, Autoconf}), the equivalent
+@var{system} in Nix notation, the name of the
+@var{glibc-dynamic-linker}, and the corresponding Linux architecture
+name if applicable.
+
+Once the bootstrap tarball are built, the @code{(gnu packages
+bootstrap)} module needs to be updated to refer to these binaries on the
+target platform. That is, the hashes and URLs of the bootstrap tarballs
+for the new platform must be added alongside those of the currently
+supported platforms. The bootstrap Guile tarball is treated specially:
+it is expected to be available locally, and @file{gnu/local.mk} has
+rules to download it for the supported architectures; a rule for the new
+platform must be added as well.
In practice, there may be some complications. First, it may be that the
extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
diff --git a/gnu/packages/bioinformatics.scm b/gnu/packages/bioinformatics.scm
index 33bf0921d1..2a312b1989 100644
--- a/gnu/packages/bioinformatics.scm
+++ b/gnu/packages/bioinformatics.scm
@@ -161,6 +161,7 @@
#:use-module (gnu packages wget)
#:use-module (gnu packages xml)
#:use-module (gnu packages xorg)
+ #:use-module (gnu platform)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match))
@@ -6576,10 +6577,12 @@ simultaneously.")
;; architecture name ("i386") instead of the target system prefix
;; ("i686").
(mkdir (string-append (assoc-ref outputs "out") "/ilib"))
- (copy-recursively (string-append "build/ncbi-vdb/linux/gcc/"
- ,(system->linux-architecture
- (or (%current-target-system)
- (%current-system)))
+ (copy-recursively (string-append
+ "build/ncbi-vdb/linux/gcc/"
+ ,(platform-linux-architecture
+ (lookup-platform-by-target-or-system
+ (or (%current-target-system)
+ (%current-system))))
"/rel/ilib")
(string-append (assoc-ref outputs "out")
"/ilib"))
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 66412b9e92..427fefbcd2 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -30,6 +30,7 @@
#:use-module (gnu packages linux)
#:use-module (gnu packages hurd)
#:use-module (gnu packages mingw)
+ #:use-module (gnu platform)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix utils)
@@ -345,7 +346,8 @@ target that libc."
`(modify-phases ,phases
(replace 'build
(lambda _
- (setenv "ARCH" ,(system->linux-architecture target))
+ (setenv "ARCH" ,(platform-linux-architecture
+ (lookup-platform-by-target target)))
(format #t "`ARCH' set to `~a' (cross compiling)~%"
(getenv "ARCH"))
diff --git a/gnu/packages/instrumentation.scm b/gnu/packages/instrumentation.scm
index c9ca9083e4..c5062388f8 100644
--- a/gnu/packages/instrumentation.scm
+++ b/gnu/packages/instrumentation.scm
@@ -42,6 +42,7 @@
#:use-module (gnu packages swig)
#:use-module (gnu packages tbb)
#:use-module (gnu packages xml)
+ #:use-module (gnu platform)
#:use-module (guix build-system cmake)
#:use-module (guix build-system copy)
#:use-module (guix build-system gnu)
@@ -312,9 +313,10 @@ line for tracing control, a @code{lttng-ctl} library for tracing control and a
(modify-phases %standard-phases
(replace 'configure
(lambda* (#:key outputs target #:allow-other-keys)
- (let ((arch ,(system->linux-architecture
- (or (%current-target-system)
- (%current-system)))))
+ (let ((arch ,(platform-linux-architecture
+ (lookup-platform-by-target-or-system
+ (or (%current-target-system)
+ (%current-system))))))
(setenv "ARCH"
(cond
((string=? arch "arm64") "aarch64")
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 7b564e7ef1..4101d4897b 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -158,6 +158,7 @@
#:use-module (gnu packages groff)
#:use-module (gnu packages selinux)
#:use-module (gnu packages swig)
+ #:use-module (gnu platform)
#:use-module (guix build-system cmake)
#:use-module (guix build-system copy)
#:use-module (guix build-system gnu)
@@ -181,20 +182,6 @@
#:use-module (ice-9 match)
#:use-module (ice-9 regex))
-(define-public (system->linux-architecture arch)
- "Return the Linux architecture name for ARCH, a Guix system name such as
-\"x86_64-linux\" or a target triplet such as \"arm-linux-gnueabihf\"."
- (let ((arch (car (string-split arch #\-))))
- (cond ((string=? arch "i686") "i386")
- ((string-prefix? "mips" arch) "mips")
- ((string-prefix? "arm" arch) "arm")
- ((string-prefix? "aarch64" arch) "arm64")
- ((string-prefix? "alpha" arch) "alpha")
- ((string-prefix? "powerpc" arch) "powerpc") ;including "powerpc64le"
- ((string-prefix? "s390" arch) "s390")
- ((string-prefix? "riscv" arch) "riscv")
- (else arch))))
-
(define-public (system->defconfig system)
"Some systems (notably powerpc-linux) require a special target for kernel
defconfig. Return the appropriate make target if applicable, otherwise return
@@ -567,9 +554,10 @@ corresponding UPSTREAM-SOURCE (an origin), using the given DEBLOB-SCRIPTS."
(delete 'configure)
(replace 'build
(lambda _
- (let ((arch ,(system->linux-architecture
- (or (%current-target-system)
- (%current-system))))
+ (let ((arch ,(platform-linux-architecture
+ (lookup-platform-by-target-or-system
+ (or (%current-target-system)
+ (%current-system)))))
(defconfig ,(system->defconfig
(or (%current-target-system)
(%current-system))))
@@ -807,8 +795,9 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
,@(match (and configuration-file
(configuration-file
- (system->linux-architecture
- (or (%current-target-system) (%current-system)))
+ (platform-linux-architecture
+ (lookup-platform-by-target-or-system
+ (or (%current-target-system) (%current-system))))
#:variant (version-major+minor version)))
(#f ;no config for this platform
'())
@@ -839,9 +828,10 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
(setenv "KBUILD_BUILD_HOST" "guix")
;; Set ARCH and CROSS_COMPILE.
- (let ((arch #$(system->linux-architecture
- (or (%current-target-system)
- (%current-system)))))
+ (let ((arch #$(platform-linux-architecture
+ (lookup-platform-by-target-or-system
+ (or (%current-target-system)
+ (%current-system))))))
(setenv "ARCH" arch)
(format #t "`ARCH' set to `~a'~%" (getenv "ARCH"))
diff --git a/guix/build-system/linux-module.scm b/guix/build-system/linux-module.scm
index e82a9ca65c..761ebe25b1 100644
--- a/guix/build-system/linux-module.scm
+++ b/guix/build-system/linux-module.scm
@@ -50,8 +50,8 @@
(module-ref module 'linux-libre)))
(define (system->arch system)
- (let ((module (resolve-interface '(gnu packages linux))))
- ((module-ref module 'system->linux-architecture) system)))
+ (let ((module (resolve-interface '(gnu platform))))
+ ((module-ref module 'lookup-platform-by-target-or-system) system)))
(define (make-linux-module-builder linux)
(package