Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions pkgs/development/interpreters/wasmer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,32 @@
llvmPackages,
libffi,
libxml2,
makeWrapper,
bash,
make,
withLLVM ? true,
withSinglepass ? true,
}:

rustPlatform.buildRustPackage rec {
pname = "wasmer";
version = "5.0.4";
version = "6.0.0";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6.0.1 has been released; consider updating directly to that version


src = fetchFromGitHub {
owner = "wasmerio";
repo = pname;
tag = "v${version}";
hash = "sha256-rP0qvSb9PxsTMAq0hpB+zdSTHvridyCVdukLUYxdao8=";
hash = "sha256-Qx5bHCzdh3RqB5r93sa01mPyxN2EQWPWcIXJs1MrUHs=";
};

useFetchCargoVendor = true;
cargoHash = "sha256-Fympp2A04viibo4U79FiBSJIeGDUWS34OOwebCks6S0=";
cargoHash = "sha256-/Kcd9vZu5QstIEjDYaJ/ddXUIXL1F8Omi+Bm4jtOKcg=";

nativeBuildInputs = [
rustPlatform.bindgenHook
makeWrapper
bash
make
];

buildInputs = lib.optionals withLLVM [
Expand Down Expand Up @@ -57,6 +63,22 @@ rustPlatform.buildRustPackage rec {
# Tests are failing due to `Cannot allocate memory` and other reasons
doCheck = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, the build fails because cargo-auditable currently passes the enabled features to all crates in the workspace, which breaks the c-api for some reason (see rust-secure-code/cargo-auditable#124).

For reference, here is the error I am getting:

> cargo metadata failure: error: Package `wasmer-c-api v6.0.1 (/build/source/lib/c-api)` does
  not have feature `wasmer-compiler-cranelift`. It has an optional dependency with that
  name, but that dependency uses the "dep:" syntax in the features table, so it does not
  have an implicit feature with that name.
> Dependency `wasmer-compiler-cranelift` would be enabled by these features:
>        - `cranelift`

The easiest fix is to add auditable = false; here, which is what a few other packages like wasmtime and wasm-tools already do.

postBuild = ''
# Prepare and build the Wasmer C-API
sed -i 's|SHELL=/usr/bin/env bash|SHELL=${bash}/bin/bash|' Makefile
make build-capi
make package-capi
'';

postInstall = ''
# Install the C-API headers, libs, etc.
cp -r package/* $out/

# Ensure the CLI can locate its assets
makeWrapper "$out/bin/wasmer" \
--set WASMER_DIR "$out"
'';
Comment on lines +66 to +80
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make build-capi calls cargo again and builds most of the things we built before again. The final package will also include a lot of duplicate code, as the wasmer executable does not use the wasmer C-API.

Consider a separate package for the c-abi and add that as an optional dependency to wasmer.


meta = {
description = "Universal WebAssembly Runtime";
mainProgram = "wasmer";
Expand Down
1 change: 1 addition & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16751,6 +16751,7 @@ with pkgs;

wasmer = callPackage ../development/interpreters/wasmer {
llvmPackages = llvmPackages_18;
make = pkgs.make;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no pkgs.make. Maybe you meant gnumake

};

wavm = callPackage ../development/interpreters/wavm {
Expand Down
Loading