forked from NixOS/nix
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Merged
Wasm support #309
Changes from 38 commits
Commits
Show all changes
44 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 65f3b44
Merge remote-tracking branch 'detsys/main' into wasm
edolstra 6147736
Add experimental feature `wasm-builtin`
edolstra 8bc414c
Add experimental feature `wasm-derivations`
edolstra 7a0a233
Update wasmtime to 40.0.2, add Nixpkgs acknowledgment
edolstra 26db0d1
builtins.wasm: Add make_app host function for creating lazy function …
edolstra cd76ab4
builtins.wasm: Force evaluation of the result
edolstra 55653c8
builtins.wasm: Add basic path primitives
edolstra 22551fa
builtins.wasm: Add a read_file host function that supports binary files
edolstra bff5696
builtins.wasm: Add get_attr host function
edolstra b878824
WASM -> Wasm
edolstra e201484
builtins.wasm: Reserve value ID 0
edolstra 4cfd6f2
Fix misleading variable name
edolstra 9e1a9be
builtins.wasm: Replace assertions
edolstra 0ec1c42
builtins.wasm: Check memory export
edolstra aab9373
builtins.wasm: Catch all exceptions
edolstra a303760
builtins.wasm: Check return type
edolstra 7761fb0
builtins.wasm: Check file size
edolstra 57ac520
realisePath(): Move into EvalState
edolstra a4dc41c
Document the Wasm host interface
edolstra 7ab6777
builtins.wasm: Check ValueIds
edolstra 3aa4799
builtins.wasm: Fix endianness issues
edolstra bc707ee
builtins.wasm: Make thread-safe
edolstra 094b65a
WASI: Enable access to $TMPDIR
edolstra ea1beab
Revert "builtins.wasm: Fix endianness issues"
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
Some comments aren't visible on the classic Files Changed page.
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,74 @@ | ||
| # Stripped-down version of https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/wa/wasmtime/package.nix, | ||
| # license: https://github.com/NixOS/nixpkgs/blob/master/COPYING | ||
| { | ||
| lib, | ||
| stdenv, | ||
| rust_1_89, | ||
| fetchFromGitHub, | ||
| cmake, | ||
| enableShared ? !stdenv.hostPlatform.isStatic, | ||
| enableStatic ? stdenv.hostPlatform.isStatic, | ||
| }: | ||
| rust_1_89.packages.stable.rustPlatform.buildRustPackage (finalAttrs: { | ||
| pname = "wasmtime"; | ||
| version = "40.0.2"; | ||
|
|
||
| src = fetchFromGitHub { | ||
| owner = "bytecodealliance"; | ||
| repo = "wasmtime"; | ||
| tag = "v${finalAttrs.version}"; | ||
| hash = "sha256-4y9WpCdyuF/Tp2k/1d5rZxwYunWNdeibEsFgHcBC52Q="; | ||
| fetchSubmodules = true; | ||
| }; | ||
|
|
||
| # Disable cargo-auditable until https://github.com/rust-secure-code/cargo-auditable/issues/124 is solved. | ||
| auditable = false; | ||
|
|
||
| cargoHash = "sha256-aTPgnuBvOIqg1+Sa2ZLdMTLujm8dKGK5xpZ3qHpr3f8="; | ||
| cargoBuildFlags = [ | ||
| "--package" | ||
| "wasmtime-c-api" | ||
| "--no-default-features" | ||
| "--features cranelift,wasi,pooling-allocator,wat,demangle,gc-null" | ||
| ]; | ||
|
|
||
| outputs = [ | ||
| "out" | ||
| "lib" | ||
| ]; | ||
|
|
||
| nativeBuildInputs = [ | ||
| cmake | ||
| ]; | ||
|
|
||
| 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 | ||
| ''; | ||
| }) |
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
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.
Uh oh!
There was an error while loading. Please reload this page.