summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Langlois <pierre.langlois@gmx.com>2022-01-17 19:11:50 +0000
committerJonathan Brielmaier <jonathan.brielmaier@web.de>2022-01-23 15:51:30 +0100
commit3e649cb5c1621e60994f05c4eebb81331fac61f5 (patch)
tree52ed802662f882dd3b9f86168b28d895fff27d1b
parent1166f2979dde8dc5622ef0d5e2020a6239ca453a (diff)
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>
-rw-r--r--nongnu/packages/wasm.scm28
1 files changed, 28 insertions, 0 deletions
diff --git a/nongnu/packages/wasm.scm b/nongnu/packages/wasm.scm
index 6d9fe5e1..3c0a8b55 100644
--- a/nongnu/packages/wasm.scm
+++ b/nongnu/packages/wasm.scm
@@ -20,6 +20,7 @@
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix utils)
#:use-module (guix git-download)
#:use-module (guix build-system gnu)
#:use-module (gnu packages llvm))
@@ -104,3 +105,30 @@ other APIs.")
(string-append "../compiler-rt-"
#$(package-version clang-runtime-13)
".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))))))))