Package: guix-patches;
Reported by: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
Date: Wed, 21 Jul 2021 00:47:01 UTC
Severity: normal
Tags: patch
Message #50 received at 49672 <at> debbugs.gnu.org (full text, mbox):
From: Thiago Jung Bauermann <bauermann <at> kolabnow.com> To: 49672 <at> debbugs.gnu.org Cc: Maxime Devos <maximedevos <at> telenet.be>, Thiago Jung Bauermann <bauermann <at> kolabnow.com> Subject: [PATCH v2 4/6] gnu: Use ‘current-target-nix-system’ for matches Date: Sun, 27 Mar 2022 18:40:24 -0300
Several packages try to match both ‘%current-target-system’ and ‘%current-system’ against lists of Nix system identifiers. This is a bug because while ‘%current-system’ does contain a Nix system identifier, ‘%current-target-system’ contains a GNU triplet, which is different. Some places also check whether the system identifier starts with “<arch>-linux”, which is a Nix system identifier. The GNU triplet identifier stored in ‘%current-target-system’ may not match the pattern if it includes a vendor field (e.g., “x86_64-unknown-linux-gnu”, or "i586-pc-gnu”). To fix these problems make these places use the function ‘current-target-nix-system’, which always returns a Nix system identifier. In the case of the “go” and “clisp” packages, this also fixes a bug where ‘%current-system’ and ‘%current-target-system’ were being checked in the wrong order. * gnu/packages/astronomy.scm (libpasastro)[arguments]<#:make-flags>: Use ‘current-target-nix-system’ to match list of Nix system identifiers. * gnu/packages/bootloaders.scm (u-boot-tools)[arguments]<#:phases>: Likewise. * gnu/packages/c.scm (tcc)[arguments]<#:configure-flags>: Likewise. * gnu/packages/compression.scm (zpaq)[arguments]<#:make-flags>: Likewise. * gnu/packages/debug.scm (american-fuzzy-lop): Likewise. (qemu-for-american-fuzzy-lop): Likewise. * gnu/packages/digest.scm (xxhash)[arguments]<#:make-flags>: Likewise. * gnu/packages/golang.scm (go-1.4)[arguments]<#:system>: Likewise. (go-1.14)[arguments]<#:system>: Likewise. * gnu/packages/java.scm (java-swt)[source]: Likewise. (java-jansi)[arguments]<#:phases>: Likewise. * gnu/packages/julia.scm (julia)[arguments]<#:make-flags>: Likewise. * gnu/packages/lisp.scm (clisp)[arguments]<#:configure-flags>: Likewise. * gnu/packages/make-bootstrap.scm (%bootstrap-tarballs)[arguments] <#:builder>: Likewise * gnu/packages/mes.scm (mes)[native-inputs]: Likewise. * gnu/packages/pascal.scm (fpc)[native-inputs]: Likewise. [arguments]<#:phases>: Likewise. * gnu/packages/video.scm (mplayer)[arguments]<#:phases>: Likewise. * gnu/packages/web.scm (nginx)[arguments]<#:phases>: Likewise. * gnu/packages/web.scm (nginx-accept-language-module)[arguments] <#:phases>: Likewise. --- gnu/packages/astronomy.scm | 4 ++-- gnu/packages/bootloaders.scm | 4 +--- gnu/packages/c.scm | 3 +-- gnu/packages/compression.scm | 6 ++---- gnu/packages/debug.scm | 6 ++---- gnu/packages/digest.scm | 3 +-- gnu/packages/golang.scm | 6 ++---- gnu/packages/java.scm | 4 ++-- gnu/packages/julia.scm | 3 +-- gnu/packages/lisp.scm | 3 +-- gnu/packages/make-bootstrap.scm | 2 +- gnu/packages/mes.scm | 3 +-- gnu/packages/pascal.scm | 6 ++---- gnu/packages/video.scm | 3 +-- gnu/packages/web.scm | 6 ++---- 15 files changed, 22 insertions(+), 40 deletions(-) diff --git a/gnu/packages/astronomy.scm b/gnu/packages/astronomy.scm index c209b1538f72..baa48e382ba4 100644 --- a/gnu/packages/astronomy.scm +++ b/gnu/packages/astronomy.scm @@ -1021,11 +1021,11 @@ (define-public libpasastro `(#:tests? #f #:make-flags (list - ,(match (or (%current-target-system) (%current-system)) + ,(match (current-target-nix-system) ((or "aarch64-linux" "armhf-linux" "i686-linux" "x86_64-linux") "OS_TARGET=linux") (_ #f)) - ,(match (or (%current-target-system) (%current-system)) + ,(match (current-target-nix-system) ("i686-linux" "CPU_TARGET=i386") ("x86_64-linux" "CPU_TARGET=x86_64") ((or "armhf-linux" "aarch64-linux") "CPU_TARGET=armv7l") diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm index 798764103117..40dd38fdd28a 100644 --- a/gnu/packages/bootloaders.scm +++ b/gnu/packages/bootloaders.scm @@ -640,9 +640,7 @@ (define-public u-boot-tools (invoke "test/image/test-imagetools.sh"))) ;; Only run full test suite on x86_64 systems, as many tests ;; assume x86_64. - ,@(if (string-match "^x86_64-linux" - (or (%current-target-system) - (%current-system))) + ,@(if (string-match "^x86_64-linux" (current-target-nix-system)) '((add-after 'check 'check-x86 (lambda* (#:key make-flags test-target #:allow-other-keys) (apply invoke "make" "mrproper" make-flags) diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm index d545d98938b0..f9e4c497de6a 100644 --- a/gnu/packages/c.scm +++ b/gnu/packages/c.scm @@ -90,8 +90,7 @@ (define-public tcc (assoc-ref %build-inputs "libc") "/lib") ,@(if (string-prefix? "armhf-linux" - (or (%current-target-system) - (%current-system))) + (current-target-nix-system)) `("--triplet=arm-linux-gnueabihf") '())) #:test-target "test")) diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm index 3edaecd9518f..7e906eceda52 100644 --- a/gnu/packages/compression.scm +++ b/gnu/packages/compression.scm @@ -1449,16 +1449,14 @@ (define-public zpaq #:make-flags (list (string-append "CPPFLAGS=-Dunix" - ,(match (or (%current-target-system) - (%current-system)) + ,(match (current-target-nix-system) ("x86_64-linux" "") ("i686-linux" "") (_ " -DNOJIT"))) ;; These should be safe, lowest-common-denominator instruction sets, ;; allowing for some optimisation while remaining reproducible. (string-append "CXXFLAGS=-O3 -DNDEBUG" - ,(match (or (%current-target-system) - (%current-system)) + ,(match (current-target-nix-system) ("x86_64-linux" " -march=nocona -mtune=generic") ("i686-linux" " -march=i686 -mtune=generic") ("armhf-linux" " -mtune=generic-armv7-a") diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm index 80685900ebb6..d96217c95b76 100644 --- a/gnu/packages/debug.scm +++ b/gnu/packages/debug.scm @@ -228,8 +228,7 @@ (define-public c-vise (license license:ncsa))) (define-public american-fuzzy-lop - (let ((machine (match (or (%current-target-system) - (%current-system)) + (let ((machine (match (current-target-nix-system) ("x86_64-linux" "x86_64") ("i686-linux" "i386") ("aarch64-linux" "aarch64") @@ -304,8 +303,7 @@ (define-public american-fuzzy-lop (define-public qemu-for-american-fuzzy-lop ;; afl only supports using a single afl-qemu-trace executable, so ;; we only build qemu for the native target. - (let ((machine (match (or (%current-target-system) - (%current-system)) + (let ((machine (match (current-target-nix-system) ("x86_64-linux" "x86_64") ("i686-linux" "i386") ("aarch64-linux" "aarch64") diff --git a/gnu/packages/digest.scm b/gnu/packages/digest.scm index 4211848fdb61..31e9d315cd07 100644 --- a/gnu/packages/digest.scm +++ b/gnu/packages/digest.scm @@ -82,8 +82,7 @@ (define-public xxhash (arguments (list #:make-flags #~(list #$(string-append "CC=" (cc-for-target)) - #$(match (or (%current-target-system) - (%current-system)) + #$(match (current-target-nix-system) ;; Detect vector instruction set at run time. ((or "i686-linux" "x86_64-linux") "DISPATCH=1") (_ "DISPATCH=0")) diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm index a8b845e3012a..e7ebf09f1c46 100644 --- a/gnu/packages/golang.scm +++ b/gnu/packages/golang.scm @@ -114,8 +114,7 @@ (define-public go-1.4 (guix build utils) (srfi srfi-1)) #:tests? #f ; Tests are run by the all.bash script. - ,@(if (string-prefix? "aarch64-linux" (or (%current-system) - (%current-target-system))) + ,@(if (string-prefix? "aarch64-linux" (current-target-nix-system)) '(#:system "armhf-linux") '()) #:phases @@ -264,8 +263,7 @@ (define-public go-1.14 (arguments (substitute-keyword-arguments (package-arguments go-1.4) ((#:system system) - (if (string-prefix? "aarch64-linux" (or (%current-system) - (%current-target-system))) + (if (string-prefix? "aarch64-linux" (current-target-nix-system)) "aarch64-linux" system)) ((#:phases phases) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index b27892841ec6..aead02d93c31 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -3483,7 +3483,7 @@ (define-public java-swt (file32 "x86") (file64 "x86_64")) (let-values (((hash file) - (match (or (%current-target-system) (%current-system)) + (match (current-target-nix-system) ("x86_64-linux" (values hash64 file64)) (_ (values hash32 file32))))) (origin @@ -12092,7 +12092,7 @@ (define-public java-jansi (lambda _ (let ((dir (string-append "build/classes/org/fusesource/" "jansi/internal/native/" - ,(match (or (%current-target-system) (%current-system)) + ,(match (current-target-nix-system) ("i686-linux" "Linux/x86") ("x86_64-linux" "Linux/x86_64") ("armhf-linux" "Linux/armv7") diff --git a/gnu/packages/julia.scm b/gnu/packages/julia.scm index 0bdac6617508..c1a1d185d544 100644 --- a/gnu/packages/julia.scm +++ b/gnu/packages/julia.scm @@ -452,8 +452,7 @@ (define-public julia ;; Passing the MARCH or JULIA_CPU_TARGET flag is necessary to build ;; binary substitutes for the supported architectures. See also ;; https://docs.julialang.org/en/v1/devdocs/sysimg/#Specifying-multiple-system-image-targets - ,(match (or (%current-target-system) - (%current-system)) + ,(match (current-target-nix-system) ("x86_64-linux" ;; These are the flags that upstream uses for their binaries. "JULIA_CPU_TARGET=generic;generic,-cx16,clone_all;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)") diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm index 361d6409d43a..e6e1aada5b1c 100644 --- a/gnu/packages/lisp.scm +++ b/gnu/packages/lisp.scm @@ -356,8 +356,7 @@ (define-public clisp (inputs (list libffcall ncurses readline libsigsegv)) (arguments `(#:configure-flags '(,@(if (string-prefix? "armhf-linux" - (or (%current-system) - (%current-target-system))) + (current-target-nix-system)) '("CFLAGS=-falign-functions=4") '()) "--with-dynamic-ffi" diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm index 4ea97368a99e..595630d22b58 100644 --- a/gnu/packages/make-bootstrap.scm +++ b/gnu/packages/make-bootstrap.scm @@ -897,7 +897,7 @@ (define out #$output) %build-inputs)))) (inputs (append (list %guile-bootstrap-tarball) - (match (or (%current-target-system) (%current-system)) + (match (current-target-nix-system) ((or "i686-linux" "x86_64-linux") (list %mescc-tools-bootstrap-tarball %mes-bootstrap-tarball diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm index a862d84fc8ce..e5e947cb4df9 100644 --- a/gnu/packages/mes.scm +++ b/gnu/packages/mes.scm @@ -179,8 +179,7 @@ (define-public mes (propagated-inputs (list mescc-tools nyacc-1.00.2)) (native-inputs (append (list guile-3.0) - (let ((target-system (or (%current-target-system) - (%current-system)))) + (let ((target-system (current-target-nix-system))) (cond ((string-prefix? "x86_64-linux" target-system) ;; Use cross-compiler rather than #:system "i686-linux" to get diff --git a/gnu/packages/pascal.scm b/gnu/packages/pascal.scm index af7857f08495..7a3260ccbbaf 100644 --- a/gnu/packages/pascal.scm +++ b/gnu/packages/pascal.scm @@ -89,8 +89,7 @@ (define-public fpc (list expat glibc ld-wrapper ncurses zlib)) (native-inputs ;; FPC is built with FPC, so we need bootstrap binaries. - `(("fpc-binary" ,(match (or (%current-target-system) - (%current-system)) + `(("fpc-binary" ,(match (current-target-nix-system) ("i686-linux" fpc-bootstrap-i386) ;;("powerpc64le-linux" fpc-bootstrap-ppc64le) ;;("powerpc-linux" fpc-bootstrap-ppc) @@ -103,8 +102,7 @@ (define-public fpc #:phases (let ((fpc-bootstrap-path (string-append (getcwd) "/" ,name "-" ,version "/fpc-bin")) - (arch ,(match (or (%current-target-system) - (%current-system)) + (arch ,(match (current-target-nix-system) ("i686-linux" "i386") ("x86_64-linux" "x86_64") (_ "unknown")))) diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm index dc05c0a22265..3684421ecaa7 100644 --- a/gnu/packages/video.scm +++ b/gnu/packages/video.scm @@ -2089,8 +2089,7 @@ (define-public mplayer (string-append "--prefix=" out) ;; Enable runtime cpu detection where supported, ;; and choose a suitable target. - ,@(match (or (%current-target-system) - (%current-system)) + ,@(match (current-target-nix-system) ("x86_64-linux" '("--enable-runtime-cpudetection" "--target=x86_64-linux")) diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm index 75aa5ce9078b..24535226ec20 100644 --- a/gnu/packages/web.scm +++ b/gnu/packages/web.scm @@ -413,8 +413,7 @@ (define-public nginx ,(let ((system "Linux") ; uname -s (release "3.2.0") ; uname -r ;; uname -m - (machine (match (or (%current-target-system) - (%current-system)) + (machine (match (current-target-nix-system) ("x86_64-linux" "x86_64") ("i686-linux" "i686") ("mips64el-linux" "mips64") @@ -603,8 +602,7 @@ (define-public nginx-accept-language-module ,(let ((system "Linux") ; uname -s (release "3.2.0") ; uname -r ;; uname -m - (machine (match (or (%current-target-system) - (%current-system)) + (machine (match (current-target-nix-system) ("x86_64-linux" "x86_64") ("i686-linux" "i686") ("mips64el-linux" "mips64")
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.