Add a cranelift compile-time feature to wasmtime (#3206)
* Remove unnecessary into_iter/map Forgotten from a previous refactoring, this variable was already of the right type! * Move `wasmtime_jit::Compiler` into `wasmtime` This `Compiler` struct is mostly a historical artifact at this point and wasn't necessarily pulling much weight any more. This organization also doesn't lend itself super well to compiling out `cranelift` when the `Compiler` here is used for both parallel iteration configuration settings as well as compilation. The movement into `wasmtime` is relatively small, with `Module::build_artifacts` being the main function added here which is a merging of the previous functions removed from the `wasmtime-jit` crate. * Add a `cranelift` compile-time feature to `wasmtime` This commit concludes the saga of refactoring Wasmtime and making Cranelift an optional dependency by adding a new Cargo feature to the `wasmtime` crate called `cranelift`, which is enabled by default. This feature is implemented by having a new cfg for `wasmtime` itself, `cfg(compiler)`, which is used wherever compilation is necessary. This bubbles up to disable APIs such as `Module::new`, `Func::new`, `Engine::precompile_module`, and a number of `Config` methods affecting compiler configuration. Checks are added to CI that when built in this mode Wasmtime continues to successfully build. It's hoped that although this is effectively "sprinkle `#[cfg]` until things compile" this won't be too too bad to maintain over time since it's also an use case we're interested in supporting. With `cranelift` disabled the only way to create a `Module` is with the `Module::deserialize` method, which requires some form of precompiled artifact. Two consequences of this change are: * `Module::serialize` is also disabled in this mode. The reason for this is that serialized modules contain ISA/shared flags encoded in them which were used to produce the compiled code. There's no storage for this if compilation is disabled. This could probably be re-enabled in the future if necessary, but it may not end up being all that necessary. * Deserialized modules are not checked to ensure that their ISA/shared flags are compatible with the host CPU. This is actually already the case, though, with normal modules. We'll likely want to fix this in the future using a shared implementation for both these locations. Documentation should be updated to indicate that `cranelift` can be disabled, although it's not really the most prominent documentation because this is expected to be a somewhat niche use case (albeit important, just not too common). * Always enable cranelift for the C API * Fix doc example builds * Fix check tests on GitHub Actions
This commit is contained in:
24
.github/workflows/main.yml
vendored
24
.github/workflows/main.yml
vendored
@@ -75,7 +75,7 @@ jobs:
|
||||
echo "${{ runner.tool_cache }}/mdbook/bin" >> $GITHUB_PATH
|
||||
cargo install --root ${{ runner.tool_cache }}/mdbook --version ${{ env.CARGO_MDBOOK_VERSION }} mdbook
|
||||
- run: (cd docs && mdbook build)
|
||||
- run: cargo build -p wasmtime-wasi --features wasmtime/wat
|
||||
- run: cargo build -p wasmtime-wasi --features wasmtime/wat,wasmtime/cranelift
|
||||
- run: (cd docs && mdbook test -L ../target/debug/deps)
|
||||
|
||||
# Build Rust API documentation
|
||||
@@ -124,18 +124,20 @@ jobs:
|
||||
- uses: ./.github/actions/install-rust
|
||||
|
||||
# Check some feature combinations of the `wasmtime` crate
|
||||
- run: cargo check --manifest-path crates/wasmtime/Cargo.toml --no-default-features
|
||||
- run: cargo check --manifest-path crates/wasmtime/Cargo.toml --features wat
|
||||
- run: cargo check --manifest-path crates/wasmtime/Cargo.toml --features lightbeam
|
||||
- run: cargo check --manifest-path crates/wasmtime/Cargo.toml --features jitdump
|
||||
- run: cargo check --manifest-path crates/wasmtime/Cargo.toml --features cache
|
||||
- run: cargo check --manifest-path crates/wasmtime/Cargo.toml --features async
|
||||
- run: cargo check --manifest-path crates/wasmtime/Cargo.toml --features uffd
|
||||
- run: cargo check -p wasmtime --no-default-features
|
||||
- run: cargo check -p wasmtime --no-default-features --features wat
|
||||
- run: cargo check -p wasmtime --no-default-features --features lightbeam
|
||||
- run: cargo check -p wasmtime --no-default-features --features jitdump
|
||||
- run: cargo check -p wasmtime --no-default-features --features cache
|
||||
- run: cargo check -p wasmtime --no-default-features --features async
|
||||
- run: cargo check -p wasmtime --no-default-features --features uffd
|
||||
- run: cargo check -p wasmtime --no-default-features --features cranelift
|
||||
- run: cargo check -p wasmtime --no-default-features --features cranelift,wat,async,cache
|
||||
|
||||
# Check some feature combinations of the `wasmtime-c-api` crate
|
||||
- run: cargo check --manifest-path crates/c-api/Cargo.toml --no-default-features
|
||||
- run: cargo check --manifest-path crates/c-api/Cargo.toml --features wat
|
||||
- run: cargo check --manifest-path crates/c-api/Cargo.toml --features wasi
|
||||
- run: cargo check -p wasmtime-c-api --no-default-features
|
||||
- run: cargo check -p wasmtime-c-api --no-default-features --features wat
|
||||
- run: cargo check -p wasmtime-c-api --no-default-features --features wasi
|
||||
|
||||
# Check a few builds of the cranelift backend
|
||||
# - only x86 backend support,
|
||||
|
||||
Reference in New Issue
Block a user