forked from NixOS/nix
-
Notifications
You must be signed in to change notification settings - Fork 7
WASM support #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
edolstra
wants to merge
20
commits into
main
Choose a base branch
from
wasm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+637
−9
Draft
WASM support #309
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
097f064
Add builtins.wasm
edolstra c127937
Disable AOT/JIT support in wasmedge
edolstra a8a6750
Fix some crashes
edolstra d6d322b
Merge remote-tracking branch 'detsys/main' into wasm
edolstra e7bfa9b
Merge remote-tracking branch 'detsys/main' into wasm
edolstra d049bf3
Switch to wasmtime
edolstra 8f23575
builtins.wasm: Propagate C++ exceptions from host functions
edolstra 0e42761
builtins.wasm: Use ValueVector
edolstra f1b8adf
builtins.wasm: Simplify the host interface
edolstra 56e9167
builtins.wasm: Allow wasm to apply Nix functions
edolstra 392c4d1
builtins.wasm: Add panic host function
edolstra 678873b
builtins.wasm: Improve error checking
edolstra 7fdd287
NixWasmContext: Remove functionName constructor argument
edolstra 23fb7c4
Cache WASM instances
edolstra 5b31e99
builtins.wasm: Use pre-instantiation to ensure deterministic execution
edolstra dd8f3b3
Add wasm32-wasip1 system type
edolstra f30e070
Rename realPathInSandbox() -> realPathInHost()
edolstra 3936d1f
Merge remote-tracking branch 'detsys/main' into wasm
edolstra da8848e
Don't build the wasmtime executable
edolstra d977b54
Remove unneeded wasmtime features
edolstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| { | ||
| lib, | ||
| stdenv, | ||
| rust_1_89, | ||
| fetchFromGitHub, | ||
| buildPackages, | ||
| cmake, | ||
| installShellFiles, | ||
| nix-update-script, | ||
| enableShared ? !stdenv.hostPlatform.isStatic, | ||
| enableStatic ? stdenv.hostPlatform.isStatic, | ||
| }: | ||
| rust_1_89.packages.stable.rustPlatform.buildRustPackage (finalAttrs: { | ||
| pname = "wasmtime"; | ||
| version = "40.0.0"; | ||
|
|
||
| src = fetchFromGitHub { | ||
| owner = "bytecodealliance"; | ||
| repo = "wasmtime"; | ||
| tag = "v${finalAttrs.version}"; | ||
| hash = "sha256-d5j+QSEWIVwVRMT/QGc6x3cVBTFZBpoxiBagmpLV1e8="; | ||
| fetchSubmodules = true; | ||
| }; | ||
|
|
||
| # Disable cargo-auditable until https://github.com/rust-secure-code/cargo-auditable/issues/124 is solved. | ||
| auditable = false; | ||
|
|
||
| cargoHash = "sha256-PIUJHkeGi8gao7n+SLzcxNYTl2KxKiwJZPW+sFYf0AY="; | ||
| cargoBuildFlags = [ | ||
| "--package" | ||
| "wasmtime-c-api" | ||
| "--no-default-features" | ||
| "--features cranelift,wasi,pooling-allocator,wat,demangle,gc-null" | ||
| ]; | ||
|
|
||
| outputs = [ | ||
| "out" | ||
| "lib" | ||
| ]; | ||
|
|
||
| nativeBuildInputs = [ | ||
| cmake | ||
| installShellFiles | ||
| ]; | ||
|
|
||
| doCheck = | ||
| with stdenv.buildPlatform; | ||
| # SIMD tests are only executed on platforms that support all | ||
| # required processor features (e.g. SSE3, SSSE3 and SSE4.1 on x86_64): | ||
| # https://github.com/bytecodealliance/wasmtime/blob/v9.0.0/cranelift/codegen/src/isa/x64/mod.rs#L220 | ||
| (isx86_64 -> sse3Support && ssse3Support && sse4_1Support) | ||
| && | ||
| # The dependency `wasi-preview1-component-adapter` fails to build because of: | ||
| # error: linker `rust-lld` not found | ||
| !isAarch64; | ||
|
|
||
| postInstall = | ||
| let | ||
| inherit (stdenv.hostPlatform.rust) cargoShortTarget; | ||
| in | ||
| '' | ||
| moveToOutput lib $lib | ||
| ${lib.optionalString (!enableShared) "rm -f $lib/lib/*.so{,.*}"} | ||
| ${lib.optionalString (!enableStatic) "rm -f $lib/lib/*.a"} | ||
|
|
||
| # copy the build.rs generated c-api headers | ||
| # https://github.com/rust-lang/cargo/issues/9661 | ||
| mkdir -p $out | ||
| cp -r target/${cargoShortTarget}/release/build/wasmtime-c-api-impl-*/out/include $out/include | ||
| '' | ||
| + lib.optionalString stdenv.hostPlatform.isDarwin '' | ||
| install_name_tool -id \ | ||
| $lib/lib/libwasmtime.dylib \ | ||
| $lib/lib/libwasmtime.dylib | ||
| ''; | ||
|
|
||
| passthru = { | ||
| updateScript = nix-update-script { | ||
| extraArgs = [ | ||
| "--version-regex" | ||
| "^v(\\d+\\.\\d+\\.\\d+)$" | ||
| ]; | ||
| }; | ||
| }; | ||
|
|
||
| meta = { | ||
| description = "Standalone JIT-style runtime for WebAssembly, using Cranelift"; | ||
| homepage = "https://wasmtime.dev/"; | ||
| license = [ | ||
| lib.licenses.asl20 | ||
| lib.licenses.llvm-exception | ||
| ]; | ||
| mainProgram = "wasmtime"; | ||
| maintainers = with lib.maintainers; [ | ||
| ereslibre | ||
| nekowinston | ||
| ]; | ||
| platforms = lib.platforms.unix; | ||
| changelog = "https://github.com/bytecodealliance/wasmtime/blob/v${finalAttrs.version}/RELEASES.md"; | ||
| }; | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,4 +9,5 @@ sources += files( | |
| 'fetchMercurial.cc', | ||
| 'fetchTree.cc', | ||
| 'fromTOML.cc', | ||
| 'wasm.cc', | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a copyright notice that points back to nixpkgs, since this is a verbatim copy of the package definition from there.