me
/
guix
Archived
1
0
Fork 0

gnu: zig-0.10: Inherit from zig-0.9.

* gnu/packages/zig.scm (zig-0.9): Expand definition.
(zig-0.10): Inherit from zig-0.9.

Change-Id: I36c273ac3f08982f598fa934571c1b83437cb977
master
Hilton Chain 2023-10-23 22:38:50 +08:00
parent 1680e3c77f
commit f0682a6388
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292
1 changed files with 89 additions and 92 deletions

View File

@ -30,10 +30,10 @@
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages llvm)) #:use-module (gnu packages llvm))
(define-public zig-0.10 (define-public zig-0.9
(package (package
(name "zig") (name "zig")
(version "0.10.1") (version "0.9.1")
(source (source
(origin (origin
(method git-fetch) (method git-fetch)
@ -42,57 +42,66 @@
(commit version))) (commit version)))
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 "1sh5xjsksl52i4cfv1qj36sz5h0ln7cq4pdhgs3960mk8a90im7b")) (base32 "0nfvgg23sw50ksy0z0ml6lkdsvmd0278mq29m23dbb2jsirkhry7"))
(patches (search-patches "zig-do-not-link-against-librt.patch")))) (patches (search-patches "zig-0.9-riscv-support.patch"
"zig-use-system-paths.patch"
"zig-do-not-link-against-librt.patch"))))
(build-system cmake-build-system) (build-system cmake-build-system)
(inputs
(list clang-15 ; Clang propagates llvm.
lld-15
zlib
(list zstd "lib")))
;; Zig compiles fine with GCC, but also needs native LLVM libraries.
(native-inputs
(list llvm-15))
(arguments (arguments
(list (list
#:configure-flags #:configure-flags
#~(list #$@(if (%current-target-system) #~(list #$@(if (%current-target-system)
(list (string-append "-DZIG_TARGET_TRIPLE=" (list (string-append "-DZIG_TARGET_TRIPLE="
(%current-target-system))) (%current-target-system)))
'()) '()))
"-DZIG_TARGET_MCPU=baseline" #:out-of-source? #f ; for tests
"-DZIG_SHARED_LLVM=ON" ;; There are too many unclear test failures.
(string-append "-DZIG_LIB_DIR=" #$output "/lib/zig")) #:tests? (not (or (target-riscv64?)
#:validate-runpath? #f ;TODO: zig binary can't find ld-linux. (%current-target-system)))
#:out-of-source? #f ;for tests
#:phases #:phases
#~(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'set-env-variables #$@(if (target-riscv64?)
;; It is unclear why all these tests fail to build.
`((add-after 'unpack 'adjust-tests
(lambda _
(substitute* "build.zig"
((".*addRuntimeSafetyTests.*") "")
((".*addRunTranslatedCTests.*") ""))
(substitute* "test/standalone.zig"
;; These tests fail to build on riscv64-linux.
;; They both contain 'exe.linkSystemLibrary("c");'
((".*shared_library.*") "")
((".*mix_o_files.*") "")
;; ld.lld: error: undefined symbol: __tls_get_addr
;; Is this symbol x86 only in glibc?
((".*link_static_lib_as_system_lib.*") "")))))
'())
(add-after 'configure 'set-cache-dir
(lambda _ (lambda _
;; Set CC, since the stage 2 zig relies on it to find the libc
;; installation, and otherwise silently links against its own.
(setenv "CC" #$(cc-for-target))
;; Set cache dir, otherwise Zig looks for `$HOME/.cache'. ;; Set cache dir, otherwise Zig looks for `$HOME/.cache'.
(setenv "ZIG_GLOBAL_CACHE_DIR" (setenv "ZIG_GLOBAL_CACHE_DIR"
(string-append (getcwd) "/zig-cache")))) (string-append (getcwd) "/zig-cache"))))
(add-after 'patch-source-shebangs 'patch-more-shebangs
(lambda* (#:key inputs #:allow-other-keys)
;; Zig uses information about /usr/bin/env to determine the
;; version of glibc and other data.
(substitute* "lib/std/zig/system/NativeTargetInfo.zig"
(("/usr/bin/env") (search-input-file inputs "/bin/env")))))
(delete 'check) (delete 'check)
(add-after 'install 'check (add-after 'install 'check
(lambda* (#:key tests? #:allow-other-keys) (lambda* (#:key tests? #:allow-other-keys)
(when tests? (when tests?
(invoke (string-append #$output "/bin/zig") (invoke (string-append #$output "/bin/zig")
"build" "test" ;; Testing the standard library takes >7.5GB RAM, and
;; We're not testing the compiler bootstrap chain. ;; will fail if it is OOM-killed. The 'test-toolchain'
"-Dskip-stage1" ;; target skips standard library and doc tests.
"build" "test-toolchain"
;; Stage 2 is experimental, not what we run with `zig',
"-Dskip-stage2-tests" "-Dskip-stage2-tests"
;; Non-native tests try to link and execute non-native ;; Non-native tests try to link and execute non-native
;; binaries. ;; binaries.
"-Dskip-non-native"))))))) "-Dskip-non-native")))))))
(inputs
(list clang-13 ;Clang propagates llvm.
lld-13))
;; Zig compiles fine with GCC, but also needs native LLVM libraries.
(native-inputs
(list llvm-13))
(native-search-paths (native-search-paths
(list (list
(search-path-specification (search-path-specification
@ -123,11 +132,11 @@ toolchain. Among other features it provides
(properties `((max-silent-time . 9600))) (properties `((max-silent-time . 9600)))
(license license:expat))) (license license:expat)))
(define-public zig-0.9 (define-public zig-0.10
(package (package
(inherit zig-0.10) (inherit zig-0.9)
(name "zig") (name "zig")
(version "0.9.1") (version "0.10.1")
(source (source
(origin (origin
(method git-fetch) (method git-fetch)
@ -136,64 +145,52 @@ toolchain. Among other features it provides
(commit version))) (commit version)))
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 "0nfvgg23sw50ksy0z0ml6lkdsvmd0278mq29m23dbb2jsirkhry7")) (base32 "1sh5xjsksl52i4cfv1qj36sz5h0ln7cq4pdhgs3960mk8a90im7b"))
(patches (search-patches "zig-0.9-riscv-support.patch" (patches (search-patches "zig-do-not-link-against-librt.patch"))))
"zig-use-system-paths.patch"
"zig-do-not-link-against-librt.patch"))))
(inputs
(list clang-13 ; Clang propagates llvm.
lld-13))
;; Zig compiles fine with GCC, but also needs native LLVM libraries.
(native-inputs
(list llvm-13))
(arguments (arguments
(list (substitute-keyword-arguments (package-arguments zig-0.9)
#:configure-flags ((#:configure-flags flags ''())
#~(list #$@(if (%current-target-system) #~(cons* "-DZIG_TARGET_MCPU=baseline"
(list (string-append "-DZIG_TARGET_TRIPLE=" "-DZIG_SHARED_LLVM=ON"
(%current-target-system))) (string-append "-DZIG_LIB_DIR=" #$output "/lib/zig")
'())) #$flags))
#:out-of-source? #f ; for tests ;; TODO: zig binary can't find ld-linux.
;; There are too many unclear test failures. ((#:validate-runpath? _ #t) #f)
#:tests? (not (or (target-riscv64?) ((#:tests? _ #t) #t)
(%current-target-system))) ((#:phases phases '%standard-phases)
#:phases #~(modify-phases #$phases
#~(modify-phases %standard-phases #$@(if (target-riscv64?)
(add-after 'configure 'set-cache-dir `((delete 'adjust-tests))
(lambda _ '())
;; Set cache dir, otherwise Zig looks for `$HOME/.cache'. (add-after 'unpack 'set-CC
(setenv "ZIG_GLOBAL_CACHE_DIR" (lambda _
(string-append (getcwd) "/zig-cache")))) ;; Set CC, since the stage 2 zig relies on it to find the libc
#$@(if (target-riscv64?) ;; installation, and otherwise silently links against its own.
;; It is unclear why all these tests fail to build. (setenv "CC" #$(cc-for-target))))
`((add-after 'unpack 'adjust-tests (add-after 'patch-source-shebangs 'patch-more-shebangs
(lambda _ (lambda* (#:key inputs #:allow-other-keys)
(substitute* "build.zig" ;; Zig uses information about /usr/bin/env to determine the
((".*addRuntimeSafetyTests.*") "") ;; version of glibc and other data.
((".*addRunTranslatedCTests.*") "")) (substitute* "lib/std/zig/system/NativeTargetInfo.zig"
(substitute* "test/standalone.zig" (("/usr/bin/env") (search-input-file inputs "/bin/env")))))
;; These tests fail to build on riscv64-linux. (replace 'check
;; They both contain 'exe.linkSystemLibrary("c");' (lambda* (#:key tests? #:allow-other-keys)
((".*shared_library.*") "") (when tests?
((".*mix_o_files.*") "") (invoke (string-append #$output "/bin/zig")
;; ld.lld: error: undefined symbol: __tls_get_addr "build" "test"
;; Is this symbol x86 only in glibc? ;; We're not testing the compiler bootstrap chain.
((".*link_static_lib_as_system_lib.*") ""))))) "-Dskip-stage1"
'()) "-Dskip-stage2-tests"
(delete 'check) ;; Non-native tests try to link and execute non-native
(add-after 'install 'check ;; binaries.
(lambda* (#:key tests? #:allow-other-keys) "-Dskip-non-native"))))))))
(when tests? (inputs
(invoke (string-append #$output "/bin/zig") (modify-inputs (package-inputs zig-0.9)
;; Testing the standard library takes >7.5GB RAM, and (prepend zlib `(,zstd "lib"))
;; will fail if it is OOM-killed. The 'test-toolchain' (replace "clang" clang-15)
;; target skips standard library and doc tests. (replace "lld" lld-15)))
"build" "test-toolchain" (native-inputs
;; Stage 2 is experimental, not what we run with `zig', (modify-inputs (package-native-inputs zig-0.9)
(replace "llvm" llvm-15)))))
"-Dskip-stage2-tests"
;; Non-native tests try to link and execute non-native
;; binaries.
"-Dskip-non-native")))))))))
(define-public zig zig-0.10) (define-public zig zig-0.10)