summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHilton Chain <[email protected]>2024-11-17 02:42:35 +0800
committerHilton Chain <[email protected]>2024-12-31 10:56:33 +0800
commit6fc811d02afe792f7ec09b2aa92a87b9ce191321 (patch)
tree30fe3b5b046af384a340404da5bb665b72b6f161
parent8808ea98ae1429232a1b7df35e1b75f4c9bac42b (diff)
build/zig: Really support cross compilation.
* guix/build/zig-build-system.scm (configure): New procedure. (set-cc,set-zig-global-cache-dir): Delete procedures. (%standard-phases): Adjust accordingly. Change-Id: I08d15add2b249f7016f9cbb07f151ecf469fe656
-rw-r--r--guix/build/zig-build-system.scm29
1 files changed, 19 insertions, 10 deletions
diff --git a/guix/build/zig-build-system.scm b/guix/build/zig-build-system.scm
index 8352a73324..93a5d91536 100644
--- a/guix/build/zig-build-system.scm
+++ b/guix/build/zig-build-system.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2023 Ekaitz Zarraga <[email protected]>
+;;; Copyright © 2024 Hilton Chain <[email protected]>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -34,14 +35,24 @@
;; https://github.com/riverwm/river/blob/master/PACKAGING.md
(define global-cache-dir "zig-cache")
-(define* (set-cc #:rest args)
- ;; TODO: Zig needs the gcc-toolchain in order to find the libc.
- ;; we need to think about how to solve this in the build system
- ;; directly: --libc
- (setenv "CC" "gcc"))
+(define* (configure #:key inputs target #:allow-other-keys)
+ ;; Set cache dir, otherwise Zig looks for `$HOME/.cache'.
+ (setenv "ZIG_GLOBAL_CACHE_DIR" global-cache-dir)
-(define* (set-zig-global-cache-dir #:rest args)
- (setenv "ZIG_GLOBAL_CACHE_DIR" global-cache-dir))
+ ;; Libc paths for target.
+ (let ((libc (assoc-ref inputs (if target "cross-libc" "libc")))
+ (port (open-file "/tmp/guix-zig-libc-paths" "w" #:encoding "utf8")))
+ (display
+ (string-append "\
+include_dir=" libc "/include
+sys_include_dir=" libc "/include
+crt_dir=" libc "/lib
+msvc_lib_dir=
+kernel32_lib_dir=
+gcc_dir=")
+ port)
+ (close-port port))
+ (setenv "ZIG_LIBC" "/tmp/guix-zig-libc-paths"))
(define* (build #:key
zig-build-flags
@@ -91,9 +102,7 @@
(define %standard-phases
(modify-phases gnu:%standard-phases
(delete 'bootstrap)
- (delete 'configure)
- (add-before 'build 'set-zig-global-cache-dir set-zig-global-cache-dir)
- (add-before 'build 'set-cc set-cc)
+ (replace 'configure configure)
(replace 'build build)
(replace 'check check)
(replace 'install install)))