[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
57/72: build-system: zig: Support cross compilation.
From: |
guix-commits |
Subject: |
57/72: build-system: zig: Support cross compilation. |
Date: |
Thu, 21 Nov 2024 07:19:51 -0500 (EST) |
hako pushed a commit to branch wip-zig-bootstrap
in repository guix.
commit 696118788656665b7fb509d676cd45bf4ca059d4
Author: Hilton Chain <hako@ultrarare.space>
AuthorDate: Sun Nov 17 02:42:35 2024 +0800
build-system: zig: Support cross compilation.
* guix/build/zig-build-system.scm (configure): New procedure.
(build): Add "--libc" argument.
(set-cc,set-zig-global-cache-dir): Delete procedures.
(%standard-phases): Adjust accordingly.
Change-Id: I08d15add2b249f7016f9cbb07f151ecf469fe656
---
guix/build/zig-build-system.scm | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/guix/build/zig-build-system.scm b/guix/build/zig-build-system.scm
index 8352a73324..302d096976 100644
--- a/guix/build/zig-build-system.scm
+++ b/guix/build/zig-build-system.scm
@@ -34,14 +34,23 @@
;; 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" "zig-cache")
-(define* (set-zig-global-cache-dir #:rest args)
- (setenv "ZIG_GLOBAL_CACHE_DIR" global-cache-dir))
+ ;; Configure file required for `--libc' option of `zig build'.
+ (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)))
(define* (build #:key
zig-build-flags
@@ -63,6 +72,7 @@
,@(if zig-release-type
(list (string-append "-Drelease-" zig-release-type))
'())
+ "--libc" "/tmp/guix-zig-libc-paths"
,@zig-build-flags)))
(format #t "running: ~s~%" call)
(apply invoke call)))
@@ -91,9 +101,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)))
- 30/72: gnu: Add zig-0.10.0-3660., (continued)
- 30/72: gnu: Add zig-0.10.0-3660., guix-commits, 2024/11/21
- 24/72: gnu: Add zig-0.10.0-1891., guix-commits, 2024/11/21
- 35/72: gnu: Add zig-0.10.0-3980., guix-commits, 2024/11/21
- 38/72: gnu: Add zig-0.11.0-149., guix-commits, 2024/11/21
- 43/72: gnu: Add zig-0.11.0-638., guix-commits, 2024/11/21
- 45/72: gnu: Add zig-0.11.0-761., guix-commits, 2024/11/21
- 54/72: gnu: Add zig-0.12.0-109., guix-commits, 2024/11/21
- 42/72: gnu: Add zig-0.11.0-631., guix-commits, 2024/11/21
- 55/72: gnu: Add zig-0.13., guix-commits, 2024/11/21
- 60/72: gnu: zig: Build reproducibly., guix-commits, 2024/11/21
- 57/72: build-system: zig: Support cross compilation.,
guix-commits <=
- 69/72: gnu: Add zig-diffz., guix-commits, 2024/11/21
- 72/72: gnu: Add zig-zls-0.13., guix-commits, 2024/11/21
- 64/72: gnu: Add zig-wayland., guix-commits, 2024/11/21
- 41/72: gnu: Add zig-0.11.0-587., guix-commits, 2024/11/21
- 51/72: gnu: Add zig-0.11.0-3506., guix-commits, 2024/11/21
- 47/72: gnu: Add zig-0.11.0-3245., guix-commits, 2024/11/21
- 53/72: gnu: Add zig-0.12., guix-commits, 2024/11/21
- 59/72: gnu: zig: Respect the PKG_CONFIG environment variable., guix-commits, 2024/11/21
- 44/72: gnu: Add zig-0.11.0-702., guix-commits, 2024/11/21
- 70/72: gnu: Add zig-known-folders., guix-commits, 2024/11/21