diff options
| author | Hilton Chain <hako@ultrarare.space> | 2026-06-21 15:05:32 +0800 |
|---|---|---|
| committer | Hilton Chain <hako@ultrarare.space> | 2026-07-06 16:08:22 +0800 |
| commit | 7b1076d64424bbe618b810e6023bd19b6a0dc8c7 (patch) | |
| tree | ffb2966ae60282da2f0318eefb35f90a1a74371d /gnu/packages/zig.scm | |
| parent | 144df629c2a3a4ef475c195371ce41003dc5ad89 (diff) | |
gnu: zig-0.10: Expand definiton.
* gnu/packages/zig.scm (zig-0.10): No longer inherit from zig-0.9 and expand
field values.
Merges: #9430
Diffstat (limited to 'gnu/packages/zig.scm')
| -rw-r--r-- | gnu/packages/zig.scm | 138 |
1 files changed, 97 insertions, 41 deletions
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm index 7344c496455..fec10c1d0cd 100644 --- a/gnu/packages/zig.scm +++ b/gnu/packages/zig.scm | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> | 3 | ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> |
| 4 | ;;; Copyright © 2021 Calum Irwin <calumirwin1@gmail.com> | 4 | ;;; Copyright © 2021 Calum Irwin <calumirwin1@gmail.com> |
| 5 | ;;; Copyright © 2022-2024 Efraim Flashner <efraim@flashner.co.il> | 5 | ;;; Copyright © 2022-2024 Efraim Flashner <efraim@flashner.co.il> |
| 6 | ;;; Copyright © 2023, 2024 Hilton Chain <hako@ultrarare.space> | 6 | ;;; Copyright © 2023, 2024, 2026 Hilton Chain <hako@ultrarare.space> |
| 7 | ;;; Copyright © 2025 dan <i@dan.games> | 7 | ;;; Copyright © 2025 dan <i@dan.games> |
| 8 | ;;; | 8 | ;;; |
| 9 | ;;; This file is part of GNU Guix. | 9 | ;;; This file is part of GNU Guix. |
| @@ -217,7 +217,6 @@ toolchain. Among other features it provides | |||
| 217 | 217 | ||
| 218 | (define-public zig-0.10 | 218 | (define-public zig-0.10 |
| 219 | (package | 219 | (package |
| 220 | (inherit zig-0.9) | ||
| 221 | (name "zig") | 220 | (name "zig") |
| 222 | (version "0.10.1") | 221 | (version "0.10.1") |
| 223 | (source | 222 | (source |
| @@ -231,49 +230,106 @@ toolchain. Among other features it provides | |||
| 231 | "zig-0.9-use-baseline-cpu-by-default.patch" | 230 | "zig-0.9-use-baseline-cpu-by-default.patch" |
| 232 | "zig-0.10-use-system-paths.patch" | 231 | "zig-0.10-use-system-paths.patch" |
| 233 | "zig-0.10-fix-runpath.patch")))) | 232 | "zig-0.10-fix-runpath.patch")))) |
| 233 | (build-system cmake-build-system) | ||
| 234 | (arguments | 234 | (arguments |
| 235 | (substitute-keyword-arguments arguments | 235 | (list |
| 236 | ((#:tests? _ #t) | 236 | #:tests? (not (%current-target-system)) |
| 237 | (not (%current-target-system))) | 237 | #:out-of-source? #f ;for tests |
| 238 | ((#:configure-flags flags ''()) | 238 | #:configure-flags |
| 239 | #~(cons "-DZIG_SHARED_LLVM=ON" | 239 | #~(list (string-append "-DZIG_LIB_DIR=" #$output "/lib/zig") |
| 240 | #$flags)) | 240 | "-DZIG_TARGET_MCPU=baseline" |
| 241 | ((#:phases phases '%standard-phases) | 241 | (string-append |
| 242 | #~(modify-phases #$phases | 242 | "-DZIG_TARGET_TRIPLE=" |
| 243 | #$@(if (target-riscv64?) | 243 | (zig-target |
| 244 | `((delete 'adjust-tests)) | 244 | #$(platform-target |
| 245 | '()) | 245 | (lookup-platform-by-target-or-system |
| 246 | (add-after 'patch-source-shebangs 'patch-more-shebangs | 246 | (or (%current-target-system) |
| 247 | (lambda* (#:key inputs #:allow-other-keys) | 247 | (%current-system)))))) |
| 248 | ;; Zig uses information about an ELF file to determine the | 248 | "-DZIG_USE_LLVM_CONFIG=ON" |
| 249 | ;; version of glibc and other data for native builds. | 249 | "-DZIG_SHARED_LLVM=ON") |
| 250 | (substitute* "lib/std/zig/system/NativeTargetInfo.zig" | 250 | #:imported-modules |
| 251 | (("/usr/bin/env") (search-input-file inputs "bin/clang++"))))) | 251 | (cons '(guix build zig-utils) |
| 252 | (replace 'check | 252 | %cmake-build-system-modules) |
| 253 | (lambda* (#:key tests? #:allow-other-keys) | 253 | #:modules |
| 254 | (when tests? | 254 | (cons '(guix build zig-utils) |
| 255 | ;; error(libc_installation): msvc_lib_dir may not be empty for | 255 | '((guix build cmake-build-system) |
| 256 | ;; windows-msvc. | 256 | (guix build utils))) |
| 257 | (unsetenv "ZIG_LIBC") | 257 | #:phases |
| 258 | (invoke (string-append #$output "/bin/zig") | 258 | #~(modify-phases %standard-phases |
| 259 | "build" "test" | 259 | (add-after 'patch-source-shebangs 'patch-more-shebangs |
| 260 | ;; We're not testing the compiler bootstrap chain. | 260 | (lambda* (#:key inputs #:allow-other-keys) |
| 261 | "-Dskip-stage1" | 261 | ;; Zig uses information about an ELF file to determine the |
| 262 | "-Dskip-stage2-tests" | 262 | ;; version of glibc and other data for native builds. |
| 263 | ;; Non-native tests try to link and execute non-native | 263 | (substitute* "lib/std/zig/system/NativeTargetInfo.zig" |
| 264 | ;; binaries. | 264 | (("/usr/bin/env") (search-input-file inputs "bin/clang++"))))) |
| 265 | "-Dskip-non-native")))))))) | 265 | (add-before 'configure 'zig-configure zig-configure) |
| 266 | (delete 'check) | ||
| 267 | (add-after 'install 'check | ||
| 268 | (lambda* (#:key tests? #:allow-other-keys) | ||
| 269 | (when tests? | ||
| 270 | ;; error(libc_installation): msvc_lib_dir may not be empty for | ||
| 271 | ;; windows-msvc. | ||
| 272 | (unsetenv "ZIG_LIBC") | ||
| 273 | (invoke (string-append #$output "/bin/zig") | ||
| 274 | "build" "test" | ||
| 275 | ;; We're not testing the compiler bootstrap chain. | ||
| 276 | "-Dskip-stage1" | ||
| 277 | "-Dskip-stage2-tests" | ||
| 278 | ;; Non-native tests try to link and execute non-native | ||
| 279 | ;; binaries. | ||
| 280 | "-Dskip-non-native")))) | ||
| 281 | (add-before 'check 'copy-libc-abi-tools | ||
| 282 | (lambda* (#:key inputs native-inputs #:allow-other-keys) | ||
| 283 | (mkdir-p "/tmp/libc-abi-tools") | ||
| 284 | (with-directory-excursion "/tmp/libc-abi-tools" | ||
| 285 | (copy-recursively | ||
| 286 | (dirname (search-input-file | ||
| 287 | (or native-inputs inputs) "consolidate.zig")) | ||
| 288 | ".") | ||
| 289 | (for-each make-file-writable (find-files "."))))) | ||
| 290 | (add-after 'copy-libc-abi-tools 'install-abilists | ||
| 291 | (lambda _ | ||
| 292 | (with-directory-excursion "/tmp/libc-abi-tools" | ||
| 293 | (invoke (string-append #$output "/bin/zig") | ||
| 294 | "run" "consolidate.zig") | ||
| 295 | (install-file | ||
| 296 | "abilists" | ||
| 297 | (string-append #$output "/lib/zig/libc/glibc")))))))) | ||
| 266 | (inputs | 298 | (inputs |
| 267 | (modify-inputs inputs | 299 | (list clang-15 ;Clang propagates llvm. |
| 268 | (prepend zlib `(,zstd "lib")) | 300 | lld-15 |
| 269 | (replace "clang" clang-15) | 301 | zlib |
| 270 | (replace "lld" lld-15))) | 302 | `(,zstd "lib"))) |
| 303 | ;; Zig compiles fine with GCC, but also needs native LLVM libraries. | ||
| 271 | (native-inputs | 304 | (native-inputs |
| 272 | (modify-inputs native-inputs | 305 | (list llvm-15 |
| 273 | (replace "libc-abi-tools" zig-0.10-libc-abi-tools) | 306 | zig-0.10-libc-abi-tools)) |
| 274 | (replace "llvm" llvm-15))) | 307 | (native-search-paths |
| 308 | (list $C_INCLUDE_PATH | ||
| 309 | $CPLUS_INCLUDE_PATH | ||
| 310 | $LIBRARY_PATH | ||
| 311 | (search-path-specification | ||
| 312 | (variable "GUIX_ZIG_PACKAGE_PATH") | ||
| 313 | (files '("src/zig"))))) | ||
| 314 | (synopsis "General purpose programming language and toolchain") | ||
| 315 | (description "Zig is a general-purpose programming language and | ||
| 316 | toolchain. Among other features it provides | ||
| 317 | @itemize | ||
| 318 | @item an Optional type instead of null pointers, | ||
| 319 | @item manual memory management, | ||
| 320 | @item generic data structures and functions, | ||
| 321 | @item compile-time reflection and compile-time code execution, | ||
| 322 | @item integration with C using zig as a C compiler, and | ||
| 323 | @item concurrency via async functions. | ||
| 324 | @end itemize") | ||
| 325 | (home-page "https://ziglang.org/") | ||
| 326 | ;; Currently building zig can take up to 10GB of RAM for linking stage1: | ||
| 327 | ;; https://github.com/ziglang/zig/issues/6485 | ||
| 328 | (supported-systems %64bit-supported-systems) | ||
| 329 | ;; Stage3 can take a lot of time and isn't verbose. | ||
| 275 | (properties `((max-silent-time . 9600) | 330 | (properties `((max-silent-time . 9600) |
| 276 | ,@(clang-compiler-cpu-architectures "15"))))) | 331 | ,@(clang-compiler-cpu-architectures "15"))) |
| 332 | (license license:expat))) | ||
| 277 | 333 | ||
| 278 | 334 | ||
| 279 | ;;; | 335 | ;;; |
