1{ rustPlatform, fetchFromGitHub, Security, lib, stdenv }:
2
3rustPlatform.buildRustPackage rec {
4 pname = "wasmtime";
5 version = "9.0.3";
6
7 src = fetchFromGitHub {
8 owner = "bytecodealliance";
9 repo = pname;
10 rev = "v${version}";
11 hash = "sha256-b/GioFixPpbCUiYfOLwJ1NCsLGqIm+v9ODuq6kD8JeE=";
12 fetchSubmodules = true;
13 };
14
15 cargoHash = "sha256-AYb6dbmvoFYbvgik9rdyOnxdHdnhR8thnrQShGxRLFA=";
16
17 cargoBuildFlags = [ "--package" "wasmtime-cli" "--package" "wasmtime-c-api" ];
18
19 outputs = [ "out" "dev" ];
20
21 buildInputs = lib.optional stdenv.isDarwin Security;
22
23 # SIMD tests are only executed on platforms that support all
24 # required processor features (e.g. SSE3, SSSE3 and SSE4.1 on x86_64):
25 # https://github.com/bytecodealliance/wasmtime/blob/v9.0.0/cranelift/codegen/src/isa/x64/mod.rs#L220
26 doCheck = with stdenv.buildPlatform; (isx86_64 -> sse3Support && ssse3Support && sse4_1Support);
27 cargoTestFlags = ["--package" "wasmtime-runtime"];
28
29 postInstall = ''
30 # move libs from out to dev
31 install -d -m 0755 $dev/lib
32 install -m 0644 ''${!outputLib}/lib/* $dev/lib
33 rm -r ''${!outputLib}/lib
34
35 install -d -m0755 $dev/include/wasmtime
36 install -m0644 $src/crates/c-api/include/*.h $dev/include
37 install -m0644 $src/crates/c-api/include/wasmtime/*.h $dev/include/wasmtime
38 install -m0644 $src/crates/c-api/wasm-c-api/include/* $dev/include
39 '' + lib.optionalString stdenv.isDarwin ''
40 install_name_tool -id \
41 $dev/lib/libwasmtime.dylib \
42 $dev/lib/libwasmtime.dylib
43 '';
44
45 meta = with lib; {
46 description =
47 "Standalone JIT-style runtime for WebAssembly, using Cranelift";
48 homepage = "https://wasmtime.dev/";
49 license = licenses.asl20;
50 maintainers = with maintainers; [ ereslibre matthewbauer ];
51 platforms = platforms.unix;
52 changelog = "https://github.com/bytecodealliance/wasmtime/blob/v${version}/RELEASES.md";
53 };
54}