diff options
Diffstat (limited to 'guix')
-rw-r--r-- | guix/build-system/zig.scm | 118 | ||||
-rw-r--r-- | guix/build/zig-build-system.scm | 7 | ||||
-rw-r--r-- | guix/platforms/x86.scm | 10 | ||||
-rw-r--r-- | guix/ui.scm | 4 | ||||
-rw-r--r-- | guix/utils.scm | 12 |
5 files changed, 126 insertions, 25 deletions
diff --git a/guix/build-system/zig.scm b/guix/build-system/zig.scm index 215178ceb4..1fa4782a2e 100644 --- a/guix/build-system/zig.scm +++ b/guix/build-system/zig.scm @@ -83,6 +83,79 @@ #:system system #:guile-for-build guile))) +(define* (zig-cross-build name + #:key + source target + build-inputs target-inputs host-inputs + (phases '%standard-phases) + (outputs '("out")) + (search-paths '()) + (native-search-paths '()) + (tests? #t) + (test-target #f) + (zig-build-flags ''()) + (zig-test-flags ''()) + (zig-destdir "out") + (zig-test-destdir "test-out") + (zig-release-type #f) + (system (%current-system)) + (guile #f) + (imported-modules %zig-build-system-modules) + (modules '((guix build zig-build-system) + (guix build utils)))) + "Build SOURCE using Zig, and with INPUTS." + (define builder + (with-imported-modules imported-modules + #~(begin + (use-modules #$@(sexp->gexp modules)) + + (define %build-host-inputs + #+(input-tuples->gexp build-inputs)) + + (define %build-target-inputs + (append #$(input-tuples->gexp host-inputs) + #+(input-tuples->gexp target-inputs))) + + (define %build-inputs + (append %build-host-inputs %build-target-inputs)) + + (define %outputs + #$(outputs->gexp outputs)) + + (zig-build #:name #$name + #:source #+source + #:system #$system + #:phases #$phases + #:outputs %outputs + #:target #$target + #:test-target #$test-target + #:inputs %build-target-inputs + #:native-inputs %build-host-inputs + #:search-paths '#$(map search-path-specification->sexp + search-paths) + #:native-search-paths '#$(map + search-path-specification->sexp + native-search-paths) + #:zig-build-flags #$zig-build-flags + #:zig-test-flags #$zig-test-flags + #:zig-release-type #$zig-release-type + #:zig-destdir #$zig-destdir + #:zig-test-destdir #$zig-test-destdir + #:tests? #$tests? + #:search-paths '#$(sexp->gexp + (map search-path-specification->sexp + search-paths)))))) + + (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) + system #:graft? #f))) + (gexp->derivation name builder + #:system system + #:target target + #:graft? #f + #:substitutable? substitutable? + #:guile-for-build guile))) + + (define* (lower name #:key source inputs native-inputs outputs system target (zig (default-zig)) @@ -93,27 +166,30 @@ (define private-keywords '(#:target #:zig #:inputs #:native-inputs #:outputs)) - ;; TODO: support cross-compilation - ;; It's as simple as adding some build flags to `zig-build-flags` - ;; -Dtarget=aarch64-linux-musl, for example. - (and (not target) - (bag - (name name) - (system system) - (target target) - (host-inputs `(,@(if source - `(("source" ,source)) - '()) - ,@inputs - - ;; Keep the standard inputs of 'gnu-build-system' - ;; TODO: do we need this? - ,@(standard-packages))) - (build-inputs `(("zig" ,zig) - ,@native-inputs)) - (outputs outputs) - (build zig-build) - (arguments (strip-keyword-arguments private-keywords arguments))))) + (bag + (name name) + (system system) + (target target) + (build-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@`(("zig" ,zig)) + ,@native-inputs + ,@(if target '() inputs) + ,@(if target + ;; Use the standard cross inputs of + ;; 'gnu-build-system'. + (standard-cross-packages target 'host) + '()) + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (host-inputs (if target inputs '())) + (target-inputs (if target + (standard-cross-packages target 'target) + '())) + (outputs outputs) + (build (if target zig-cross-build zig-build)) + (arguments (strip-keyword-arguments private-keywords arguments)))) (define zig-build-system (build-system diff --git a/guix/build/zig-build-system.scm b/guix/build/zig-build-system.scm index d414ebfb17..8352a73324 100644 --- a/guix/build/zig-build-system.scm +++ b/guix/build/zig-build-system.scm @@ -47,6 +47,7 @@ zig-build-flags zig-release-type ;; "safe", "fast" or "small" empty for a ;; debug build" + target #:allow-other-keys) "Build a given Zig package." @@ -56,6 +57,9 @@ "--prefix-lib-dir" "lib" "--prefix-exe-dir" "bin" "--prefix-include-dir" "include" + ,@(if target + (list (string-append "-Dtarget=" target)) + '()) ,@(if zig-release-type (list (string-append "-Drelease-" zig-release-type)) '()) @@ -65,9 +69,10 @@ (define* (check #:key tests? zig-test-flags + target #:allow-other-keys) "Run all the tests" - (when tests? + (when (and tests? (not target)) (let ((old-destdir (getenv "DESTDIR"))) (setenv "DESTDIR" "test-out") ;; Avoid colisions with the build output (let ((call `("zig" "build" "test" diff --git a/guix/platforms/x86.scm b/guix/platforms/x86.scm index 4ed5638c14..0c8fc7296c 100644 --- a/guix/platforms/x86.scm +++ b/guix/platforms/x86.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.org> +;;; Copyright © 2023, 2024 Efraim Flashner <efraim@flashner.co.il> ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,6 +22,7 @@ #:use-module (guix records) #:export (i686-linux x86_64-linux + x86_64-linux-x32 i686-mingw x86_64-mingw i586-gnu)) @@ -41,6 +43,14 @@ (rust-target "x86_64-unknown-linux-gnu") (glibc-dynamic-linker "/lib/ld-linux-x86-64.so.2"))) +(define x86_64-linux-x32 + (platform + (target "x86_64-linux-gnux32") + (system #f) + (linux-architecture "x86_64") + (rust-target "x86_64-unknown-linux-gnux32") + (glibc-dynamic-linker "/lib/ld-linux-x32.so.2"))) + (define i686-mingw (platform (target "i686-w64-mingw32") diff --git a/guix/ui.scm b/guix/ui.scm index e3bf07212f..962d291d2e 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012-2023 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012-2024 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013, 2018 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com> @@ -555,7 +555,7 @@ See the \"Application Setup\" section in the manual, for more info.\n")) (leave-on-EPIPE (simple-format #t "~a (~a) ~a~%" command %guix-package-name %guix-version) - (format #t "Copyright ~a 2023 ~a" + (format #t "Copyright ~a 2024 ~a" ;; TRANSLATORS: Translate "(C)" to the copyright symbol ;; (C-in-a-circle), if this symbol is available in the user's ;; locale. Otherwise, do not translate "(C)"; leave it as-is. */ diff --git a/guix/utils.scm b/guix/utils.scm index 8e71f97e1c..e4e9d922e7 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -7,7 +7,7 @@ ;;; Copyright © 2015 David Thompson <davet@gnu.org> ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2018, 2020 Marius Bakke <marius@gnu.org> -;;; Copyright © 2020, 2021 Efraim Flashner <efraim@flashner.co.il> +;;; Copyright © 2020, 2021, 2024 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com> @@ -97,6 +97,7 @@ target-x86-32? target-x86-64? target-x86? + target-x32? target-arm32? target-aarch64? target-arm? @@ -634,6 +635,8 @@ returned by `config.guess'." (else triplet)))) (cond ((string-match "^arm[^-]*-([^-]+-)?linux-gnueabihf" triplet) "armhf-linux") + ;; Otherwise it will show up as x86_64-linux... which isn't wrong. + ((string-match "x86_64-linux-gnux32" triplet) "x86_64-linux-gnux32") ((string-match "^([^-]+)-([^-]+-)?linux-gnu.*" triplet) => (lambda (m) @@ -710,6 +713,13 @@ a character other than '@'." architecture (x86_64)?" (string-prefix? "x86_64-" target)) +(define* (target-x32? #:optional (target (or (%current-target-system) + (%current-system)))) + "Is the architecture of TARGET a variant of Intel/AMD's 64-bit +architecture (x86_64) using 32-bit data types?" + (and (target-x86-64? target) + (string-suffix? "gnux32" target))) + (define* (target-x86? #:optional (target (or (%current-target-system) (%current-system)))) (or (target-x86-32? target) (target-x86-64? target))) |