From patchwork Sat May 7 16:11:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 39145 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 28EB827BBEA; Sat, 7 May 2022 17:12:43 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D470527BBE9 for ; Sat, 7 May 2022 17:12:41 +0100 (BST) Received: from localhost ([::1]:46338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnN2u-00076y-TF for patchwork@mira.cbaines.net; Sat, 07 May 2022 12:12:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnN2K-00069U-9H for guix-patches@gnu.org; Sat, 07 May 2022 12:12:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58916) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nnN2K-00038p-09 for guix-patches@gnu.org; Sat, 07 May 2022 12:12:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nnN2J-0006Nc-SG for guix-patches@gnu.org; Sat, 07 May 2022 12:12:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55220] [PATCH v2 6/6] linux: Remove system->linux-architecture procedure. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 07 May 2022 16:12:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55220 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55220@debbugs.gnu.org Cc: Mathieu Othacehe Received: via spool by 55220-submit@debbugs.gnu.org id=B55220.165193991224463 (code B ref 55220); Sat, 07 May 2022 16:12:03 +0000 Received: (at 55220) by debbugs.gnu.org; 7 May 2022 16:11:52 +0000 Received: from localhost ([127.0.0.1]:52807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnN27-0006MP-Mf for submit@debbugs.gnu.org; Sat, 07 May 2022 12:11:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44346) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnN24-0006LD-5H for 55220@debbugs.gnu.org; Sat, 07 May 2022 12:11:48 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnN1z-00033k-0H for 55220@debbugs.gnu.org; Sat, 07 May 2022 12:11:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=IDHYNZ2s7hxWtRWuy1i5G+tA0WHEafKWM632k9zuSCM=; b=THrLyci1YomKWIffGDx+ CHySB2R3884ZQNyKBygrfRqTTgBbq+RkI/EaearvEzooU67HVUY4We1Z/HpkEX5RJ7vBnTcX4vuPh UVp8YJbwA55wVHmitivAXeg6+QbjNerc/ZKGBMEvMk3UyDM9meB9n8zHCc8A9l3UISxA0ycmtXL83 0k75+peBDO191hTQ0Dy615v3ykYPHyKFKqsdq0S3mKXgAz+2eB3tJ2m7+mmqOvuf0vKNEWu8IBqjx gQbmFyYj0C1HtVdNUdWzEcyZX8yrxCy4K6xKBDGhXGDamynI6VXxvYzzSxHP57cIdCBoB/iiXC/v+ bWBvkcnWErkSJw==; Received: from 71.125.192.77.rev.sfr.net ([77.192.125.71]:40324 helo=localhost.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nnN1x-0004uM-Jb; Sat, 07 May 2022 12:11:41 -0400 From: Mathieu Othacehe Date: Sat, 7 May 2022 18:11:26 +0200 Message-Id: <20220507161126.14553-7-othacehe@gnu.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220507161126.14553-1-othacehe@gnu.org> References: <20220507161126.14553-1-othacehe@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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. --- doc/guix.texi | 30 ++++++++++++++------------ gnu/packages/bioinformatics.scm | 11 ++++++---- gnu/packages/cross-base.scm | 4 +++- gnu/packages/instrumentation.scm | 8 ++++--- gnu/packages/linux.scm | 34 +++++++++++------------------- guix/build-system/linux-module.scm | 4 ++-- 6 files changed, 45 insertions(+), 46 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 6757c105dc..1dc1474ec7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -39896,20 +39896,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 ae35087964..d23f5fa9e0 100644 --- a/gnu/packages/bioinformatics.scm +++ b/gnu/packages/bioinformatics.scm @@ -161,6 +161,7 @@ (define-module (gnu packages bioinformatics) #: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 @@ (define-public ncbi-vdb ;; 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 @@ (define-module (gnu packages cross-base) #: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 @@ (define xlinux-headers `(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 ab986bfcc7..1271619ad6 100644 --- a/gnu/packages/instrumentation.scm +++ b/gnu/packages/instrumentation.scm @@ -42,6 +42,7 @@ (define-module (gnu packages instrumentation) #: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 @@ (define-public uftrace (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 828bd4e208..c5d30f937b 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -158,6 +158,7 @@ (define-module (gnu packages linux) #: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 @@ (define-module (gnu packages linux) #: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 @@ (define (make-linux-libre-headers* version gnu-revision source) (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 @@ (define* (make-linux-libre* version gnu-revision source supported-systems ,@(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 @@ (define* (make-linux-libre* version gnu-revision source supported-systems (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 @@ (define (default-linux) (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