1{ rustPlatform, fetchFromGitHub, Security, lib, stdenv }:
2
3rustPlatform.buildRustPackage rec {
4 pname = "wasmtime";
5 version = "20.0.2";
6
7 src = fetchFromGitHub {
8 owner = "bytecodealliance";
9 repo = pname;
10 rev = "v${version}";
11 hash = "sha256-zXBVqSBq/dLY8oEs0dNZxtjs4H1aKTJYeeazysHvh3w=";
12 fetchSubmodules = true;
13 };
14
15 # Disable cargo-auditable until https://github.com/rust-secure-code/cargo-auditable/issues/124 is solved.
16 auditable = false;
17 cargoHash = "sha256-jFqLUWdW/UfOc843aWO7RNDx1E6sBhUWB5Xw2+A2u90=";
18 cargoBuildFlags = [ "--package" "wasmtime-cli" "--package" "wasmtime-c-api" ];
19
20 outputs = [ "out" "dev" ];
21
22 buildInputs = lib.optional stdenv.isDarwin Security;
23
24 # SIMD tests are only executed on platforms that support all
25 # required processor features (e.g. SSE3, SSSE3 and SSE4.1 on x86_64):
26 # https://github.com/bytecodealliance/wasmtime/blob/v9.0.0/cranelift/codegen/src/isa/x64/mod.rs#L220
27 doCheck = with stdenv.buildPlatform; (isx86_64 -> sse3Support && ssse3Support && sse4_1Support);
28 cargoTestFlags = ["--package" "wasmtime-runtime"];
29
30 postInstall = ''
31 # move libs from out to dev
32 install -d -m 0755 $dev/lib
33 install -m 0644 ''${!outputLib}/lib/* $dev/lib
34 rm -r ''${!outputLib}/lib
35
36 install -d -m0755 $dev/include/wasmtime
37 install -m0644 $src/crates/c-api/include/*.h $dev/include
38 install -m0644 $src/crates/c-api/include/wasmtime/*.h $dev/include/wasmtime
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 mainProgram = "wasmtime";
51 maintainers = with maintainers; [ ereslibre matthewbauer ];
52 platforms = platforms.unix;
53 changelog = "https://github.com/bytecodealliance/wasmtime/blob/v${version}/RELEASES.md";
54 };
55}