nongnu: Add wasm32-wasi-clang.

* nongnu/packages/wasm.scm (clang-from-llvm): New variable, imported from
upstream Guix.
(wasm32-wasi-clang): New variable.

Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
Pierre Langlois 2022-01-17 19:11:50 +00:00 committed by Jonathan Brielmaier
parent 1166f2979d
commit 3e649cb5c1
No known key found for this signature in database
GPG key ID: ECFC83988B4E4B9F

View file

@ -20,6 +20,7 @@
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix utils)
#:use-module (guix git-download) #:use-module (guix git-download)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (gnu packages llvm)) #:use-module (gnu packages llvm))
@ -104,3 +105,30 @@ other APIs.")
(string-append "../compiler-rt-" (string-append "../compiler-rt-"
#$(package-version clang-runtime-13) #$(package-version clang-runtime-13)
".src/lib/builtins")))))) ".src/lib/builtins"))))))
;; FIXME: Ideally we wouldn't need to build a separate compiler because clang
;; can support multiple targets at runtime. However Guix patches the default
;; clang with a specific clang-runtime package. It would be good to improve
;; upstream Guix's support for cross-compiling with clang.
(define clang-from-llvm (@@ (gnu packages llvm) clang-from-llvm))
(define-public wasm32-wasi-clang
(let ((base (clang-from-llvm llvm-13 wasm32-wasi-clang-runtime
"0zp1p6syii5iajm8v2c207s80arv00yz5ckfwimn5dng0sxiqqax")))
(package (inherit base)
(name "wasm32-wasi-clang")
(inputs
(modify-inputs (package-inputs base)
(prepend wasi-libc)))
(arguments
(substitute-keyword-arguments (package-arguments base)
((#:configure-flags flags)
#~(list "-DCLANG_INCLUDE_TESTS=True"
;; Use a sane default include directory.
(string-append "-DC_INCLUDE_DIRS="
#$wasi-libc
"/wasm32-wasi/include")))
((#:phases phases)
`(modify-phases ,phases
(delete 'symlink-cfi_ignorelist))))))))