Commit | Line | Data |
---|---|---|
9f2c5e90 | 1 | ;;; GNU Guix --- Functional package management for GNU |
567c4f44 | 2 | ;;; Copyright © 2021 Liliana Marie Prikler <liliana.prikler@gmail.com> |
9f2c5e90 | 3 | ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> |
65045871 | 4 | ;;; Copyright © 2021 Calum Irwin <calumirwin1@gmail.com> |
3cbef19a | 5 | ;;; Copyright © 2022 Efraim Flashner <efraim@flashner.co.il> |
9f2c5e90 LMP |
6 | ;;; |
7 | ;;; This file is part of GNU Guix. | |
8 | ;;; | |
9 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
10 | ;;; under the terms of the GNU General Public License as published by | |
11 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
12 | ;;; your option) any later version. | |
13 | ;;; | |
14 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
15 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | ;;; GNU General Public License for more details. | |
18 | ;;; | |
19 | ;;; You should have received a copy of the GNU General Public License | |
20 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
21 | ||
22 | (define-module (gnu packages zig) | |
23 | #:use-module (guix packages) | |
24 | #:use-module (guix git-download) | |
25 | #:use-module ((guix licenses) #:prefix license:) | |
26 | #:use-module (guix build-system cmake) | |
27 | #:use-module (gnu packages) | |
28 | #:use-module (gnu packages llvm)) | |
29 | ||
30 | (define-public zig | |
31 | (package | |
32 | (name "zig") | |
32cf6a8e | 33 | (version "0.9.1") |
9f2c5e90 LMP |
34 | (source |
35 | (origin | |
36 | (method git-fetch) | |
37 | (uri (git-reference | |
38 | (url "https://github.com/ziglang/zig.git") | |
39 | (commit version))) | |
40 | (file-name (git-file-name name version)) | |
41 | (sha256 | |
32cf6a8e | 42 | (base32 "0nfvgg23sw50ksy0z0ml6lkdsvmd0278mq29m23dbb2jsirkhry7")) |
738da660 | 43 | (patches (search-patches "zig-use-system-paths.patch")))) |
9f2c5e90 LMP |
44 | (build-system cmake-build-system) |
45 | (inputs | |
65045871 | 46 | (list clang-13 ; Clang propagates llvm. |
e9473ed4 | 47 | lld-13)) |
9f2c5e90 LMP |
48 | ;; Zig compiles fine with GCC, but also needs native LLVM libraries. |
49 | (native-inputs | |
65045871 | 50 | (list llvm-13)) |
9f2c5e90 LMP |
51 | (arguments |
52 | `(#:configure-flags | |
53 | (list ,@(if (%current-target-system) | |
54 | (string-append "-DZIG_TARGET_TRIPLE=" | |
55 | (%current-target-system)) | |
56 | '())) | |
57 | #:out-of-source? #f ; for tests | |
58 | #:phases | |
59 | (modify-phases %standard-phases | |
60 | (add-after 'configure 'set-cache-dir | |
61 | (lambda _ | |
62 | ;; Set cache dir, otherwise Zig looks for `$HOME/.cache'. | |
63 | (setenv "ZIG_GLOBAL_CACHE_DIR" | |
64 | (string-append (getcwd) "/zig-cache")))) | |
65 | (delete 'check) | |
66 | (add-after 'install 'check | |
67 | (lambda* (#:key outputs tests? #:allow-other-keys) | |
68 | (when tests? | |
69 | (invoke (string-append (assoc-ref outputs "out") "/bin/zig") | |
70 | ;; Testing the standard library takes >7.5GB RAM, and | |
71 | ;; will fail if it is OOM-killed. The 'test-toolchain' | |
72 | ;; target skips standard library and doc tests. | |
73 | "build" "test-toolchain" | |
74 | ;; Stage 2 is experimental, not what we run with `zig', | |
75 | ;; and stage 2 tests require a lot of RAM. | |
76 | "-Dskip-stage2-tests" | |
77 | ;; Non-native tests try to link and execute non-native | |
78 | ;; binaries. | |
79 | "-Dskip-non-native"))))))) | |
80 | (native-search-paths | |
81 | (list | |
82 | (search-path-specification | |
83 | (variable "C_INCLUDE_PATH") | |
84 | (files '("include"))) | |
85 | (search-path-specification | |
86 | (variable "CPLUS_INCLUDE_PATH") | |
87 | (files '("include/c++" "include"))) | |
88 | (search-path-specification | |
89 | (variable "LIBRARY_PATH") | |
90 | (files '("lib" "lib64"))))) | |
91 | (synopsis "General purpose programming language and toolchain") | |
92 | (description "Zig is a general-purpose programming language and | |
93 | toolchain. Among other features it provides | |
94 | @itemize | |
95 | @item an Optional type instead of null pointers, | |
96 | @item manual memory management, | |
97 | @item generic data structures and functions, | |
98 | @item compile-time reflection and compile-time code execution, | |
99 | @item integration with C using zig as a C compiler, and | |
100 | @item concurrency via async functions. | |
101 | @end itemize") | |
102 | (home-page "https://github.com/ziglang/zig") | |
3cbef19a EF |
103 | ;; Currently building zig can take up to 10GB of RAM for linking stage1: |
104 | ;; https://github.com/ziglang/zig/issues/6485 | |
105 | (supported-systems %64bit-supported-systems) | |
9f2c5e90 | 106 | (license license:expat))) |