andrewdavidmackenzie opened issue #3406:
Feature
Currently I use wasmtime as a WASM runtime for embedding wasm execution in my rust project.
Compiling wasmtime and dependencies is quite a bit longer than the other wasm runtime my project supports.I see the cranelift compile for cranelift-native included and was wondering if it could be made optional via a feature.
Benefit
Faster compile times, locally and in CI.
Implementation
Use rust "features" to allow opt-in or opt-out (via disable-all and then opt in on some) of some subset of wasmtime/cranelift functionality.
Alternatives
Can't think of any obvious ones.
bjorn3 commented on issue #3406:
There are pretty much no features of cranelift-codegen that aren't used that aren't required for wasm compilation. There are a couple of other smaller crates that are part of cranelift, but wasmtime only depends on those that are actually needed for wasm compilation (eg cranelift-wasm and it's dependency cranelift-frontend)
I see the cranelift compile for cranelift-native included and was wondering if it could be made optional via a feature.
Wasmtime doesn't depend on the cranelift-native crate, so it shouldn't be compiled in the first place.
You can disable the default features of wasmtime. This will disable support for perf jitdump (only compiled on linux anyway and used to assist with profiling using
perf
), disable reading textual wat files, disable parallel compilation (avoids a dependency on rayon), and disable support for wasi-nn (neural networks). If you are using wasmtime as library instead of executable, disabling the default features will also disable cranelift entirely (instead you have to load files pre-compiled by wasmtime, you probably want to re-enable the feature), disable support for caching compilation results and disable support forasync fn
.Together this will reduce the dependency count to just 57 crates.
Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 Compiling syn v1.0.72 Compiling autocfg v1.0.1 Compiling cc v1.0.68 Compiling serde_derive v1.0.126 Checking cfg-if v1.0.0 Compiling serde v1.0.126 Compiling semver v1.0.3 Compiling libc v0.2.99 Compiling crc32fast v1.2.1 Compiling memchr v2.4.0 Checking stable_deref_trait v1.2.0 Checking fallible-iterator v0.2.0 Checking hashbrown v0.9.1 Compiling target-lexicon v0.12.0 Compiling log v0.4.14 Compiling anyhow v1.0.40 Checking wasmparser v0.80.1 Checking adler v1.0.2 Checking bitflags v1.3.2 Checking ppv-lite86 v0.2.10 Checking more-asserts v0.2.1 Checking rustc-demangle v0.1.19 Checking itoa v0.4.7 Checking once_cell v1.7.2 Checking linux-raw-sys v0.0.24 Compiling glob v0.3.0 Checking lazy_static v1.4.0 Compiling wasmtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/wasmtime) Compiling paste v1.0.5 Compiling indexmap v1.6.2 Compiling miniz_oxide v0.4.4 Compiling memoffset v0.6.4 Checking gimli v0.25.0 Compiling backtrace v0.3.61 Compiling wasmtime-runtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/runtime) Compiling psm v0.1.13 Compiling cpp_demangle v0.3.2 Compiling quote v1.0.9 Compiling rustc_version v0.4.0 Checking getrandom v0.2.3 Checking region v2.2.0 Checking addr2line v0.16.0 Checking rand_core v0.6.2 Compiling io-lifetimes v0.3.1 Compiling rsix v0.23.2 Checking rand_chacha v0.3.0 Checking rand v0.8.3 Compiling thiserror-impl v1.0.25 Checking thiserror v1.0.25 Checking cranelift-entity v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/entity) Checking bincode v1.3.3 Checking object v0.26.0 Checking wasmtime-types v0.30.0 (/home/bjorn/Projects/wasmtime/crates/types) Checking wasmtime-environ v0.30.0 (/home/bjorn/Projects/wasmtime/crates/environ) Checking wasmtime-jit v0.30.0 (/home/bjorn/Projects/wasmtime/crates/jit)
Enabling cranelift support brings it up to 70 crates.
I guess there could be an option to disable WASI support entirely, which should save some time.
bjorn3 edited a comment on issue #3406:
There are pretty much no features of cranelift-codegen that aren't used that aren't required for wasm compilation. There are a couple of other smaller crates that are part of cranelift, but wasmtime only depends on those that are actually needed for wasm compilation (eg cranelift-wasm and it's dependency cranelift-frontend)
I see the cranelift compile for cranelift-native included and was wondering if it could be made optional via a feature.
Wasmtime doesn't depend on the cranelift-native crate, so it shouldn't be compiled in the first place.
You can disable the default features of wasmtime. This will disable support for perf jitdump (only compiled on linux anyway and used to assist with profiling using
perf
), disable reading textual wat files, disable parallel compilation (avoids a dependency on rayon), and disable support for wasi-nn (neural networks). If you are using wasmtime as library instead of executable, disabling the default features will also disable cranelift entirely (instead you have to load files pre-compiled by wasmtime, you probably want to re-enable the feature), disable support for caching compilation results and disable support forasync fn
.Together this will reduce the dependency count to just 57 crates.
<details>
Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 Compiling syn v1.0.72 Compiling autocfg v1.0.1 Compiling cc v1.0.68 Compiling serde_derive v1.0.126 Checking cfg-if v1.0.0 Compiling serde v1.0.126 Compiling semver v1.0.3 Compiling libc v0.2.99 Compiling crc32fast v1.2.1 Compiling memchr v2.4.0 Checking stable_deref_trait v1.2.0 Checking fallible-iterator v0.2.0 Checking hashbrown v0.9.1 Compiling target-lexicon v0.12.0 Compiling log v0.4.14 Compiling anyhow v1.0.40 Checking wasmparser v0.80.1 Checking adler v1.0.2 Checking bitflags v1.3.2 Checking ppv-lite86 v0.2.10 Checking more-asserts v0.2.1 Checking rustc-demangle v0.1.19 Checking itoa v0.4.7 Checking once_cell v1.7.2 Checking linux-raw-sys v0.0.24 Compiling glob v0.3.0 Checking lazy_static v1.4.0 Compiling wasmtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/wasmtime) Compiling paste v1.0.5 Compiling indexmap v1.6.2 Compiling miniz_oxide v0.4.4 Compiling memoffset v0.6.4 Checking gimli v0.25.0 Compiling backtrace v0.3.61 Compiling wasmtime-runtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/runtime) Compiling psm v0.1.13 Compiling cpp_demangle v0.3.2 Compiling quote v1.0.9 Compiling rustc_version v0.4.0 Checking getrandom v0.2.3 Checking region v2.2.0 Checking addr2line v0.16.0 Checking rand_core v0.6.2 Compiling io-lifetimes v0.3.1 Compiling rsix v0.23.2 Checking rand_chacha v0.3.0 Checking rand v0.8.3 Compiling thiserror-impl v1.0.25 Checking thiserror v1.0.25 Checking cranelift-entity v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/entity) Checking bincode v1.3.3 Checking object v0.26.0 Checking wasmtime-types v0.30.0 (/home/bjorn/Projects/wasmtime/crates/types) Checking wasmtime-environ v0.30.0 (/home/bjorn/Projects/wasmtime/crates/environ) Checking wasmtime-jit v0.30.0 (/home/bjorn/Projects/wasmtime/crates/jit)
</details>
Enabling cranelift support brings it up to 70 crates.
<details>
Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 Compiling syn v1.0.72 Compiling autocfg v1.0.1 Compiling serde_derive v1.0.126 Compiling serde v1.0.126 Checking cfg-if v1.0.0 Checking hashbrown v0.9.1 Compiling cc v1.0.68 Checking fallible-iterator v0.2.0 Checking stable_deref_trait v1.2.0 Compiling semver v1.0.3 Compiling log v0.4.14 Compiling libc v0.2.99 Compiling target-lexicon v0.12.0 Compiling crc32fast v1.2.1 Compiling cranelift-entity v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/entity) Compiling cranelift-codegen-shared v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen/shared) Compiling memchr v2.4.0 Compiling anyhow v1.0.40 Checking wasmparser v0.80.1 Checking rustc-hash v1.1.0 Checking smallvec v1.6.1 Checking more-asserts v0.2.1 Checking bitflags v1.3.2 Checking ppv-lite86 v0.2.10 Checking adler v1.0.2 Checking itoa v0.4.7 Checking either v1.6.1 Checking rustc-demangle v0.1.19 Checking linux-raw-sys v0.0.24 Checking once_cell v1.7.2 Compiling glob v0.3.0 Checking lazy_static v1.4.0 Compiling wasmtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/wasmtime) Compiling paste v1.0.5 Compiling indexmap v1.6.2 Compiling miniz_oxide v0.4.4 Compiling memoffset v0.6.4 Compiling cranelift-codegen-meta v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen/meta) Compiling backtrace v0.3.61 Compiling wasmtime-runtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/runtime) Compiling psm v0.1.13 Checking itertools v0.10.0 Compiling cpp_demangle v0.3.2 Compiling quote v1.0.9 Checking regalloc v0.0.31 Compiling rustc_version v0.4.0 Checking getrandom v0.2.3 Checking region v2.2.0 Checking rand_core v0.6.2 Compiling io-lifetimes v0.3.1 Compiling rsix v0.23.2 Checking rand_chacha v0.3.0 Checking rand v0.8.3 Compiling cranelift-codegen v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen) Compiling thiserror-impl v1.0.25 Checking thiserror v1.0.25 Checking bincode v1.3.3 Checking gimli v0.25.0 Checking object v0.26.0 Checking wasmtime-types v0.30.0 (/home/bjorn/Projects/wasmtime/crates/types) Checking cranelift-bforest v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/bforest) Checking addr2line v0.16.0 Checking wasmtime-environ v0.30.0 (/home/bjorn/Projects/wasmtime/crates/environ) Checking wasmtime-jit v0.30.0 (/home/bjorn/Projects/wasmtime/crates/jit) Checking cranelift-frontend v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/frontend) Checking cranelift-native v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/native) Checking cranelift-wasm v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/wasm) Checking wasmtime-cranelift v0.30.0 (/home/bjorn/Projects/wasmtime/crates/cranelift)
</details>
I guess there could be an option to disable WASI support entirely, which should save some time.
bjorn3 edited a comment on issue #3406:
There are pretty much no features of cranelift-codegen that aren't used that aren't required for wasm compilation. There are a couple of other smaller crates that are part of cranelift, but wasmtime only depends on those that are actually needed for wasm compilation (eg cranelift-wasm and it's dependency cranelift-frontend)
I see the cranelift compile for cranelift-native included and was wondering if it could be made optional via a feature.
Wasmtime doesn't depend on the cranelift-native crate, so it shouldn't be compiled in the first place.
You can disable the default features of wasmtime. This will disable support for perf jitdump (only compiled on linux anyway and used to assist with profiling using
perf
), disable reading textual wat files, disable parallel compilation (avoids a dependency on rayon), and disable support for wasi-nn (neural networks). If you are using wasmtime as library instead of executable, disabling the default features will also disable cranelift entirely (instead you have to load files pre-compiled by wasmtime, you probably want to re-enable the feature), disable support for caching compilation results and disable support forasync fn
.Together this will reduce the dependency count to just 57 crates.
<details>
Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 Compiling syn v1.0.72 Compiling autocfg v1.0.1 Compiling cc v1.0.68 Compiling serde_derive v1.0.126 Checking cfg-if v1.0.0 Compiling serde v1.0.126 Compiling semver v1.0.3 Compiling libc v0.2.99 Compiling crc32fast v1.2.1 Compiling memchr v2.4.0 Checking stable_deref_trait v1.2.0 Checking fallible-iterator v0.2.0 Checking hashbrown v0.9.1 Compiling target-lexicon v0.12.0 Compiling log v0.4.14 Compiling anyhow v1.0.40 Checking wasmparser v0.80.1 Checking adler v1.0.2 Checking bitflags v1.3.2 Checking ppv-lite86 v0.2.10 Checking more-asserts v0.2.1 Checking rustc-demangle v0.1.19 Checking itoa v0.4.7 Checking once_cell v1.7.2 Checking linux-raw-sys v0.0.24 Compiling glob v0.3.0 Checking lazy_static v1.4.0 Compiling wasmtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/wasmtime) Compiling paste v1.0.5 Compiling indexmap v1.6.2 Compiling miniz_oxide v0.4.4 Compiling memoffset v0.6.4 Checking gimli v0.25.0 Compiling backtrace v0.3.61 Compiling wasmtime-runtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/runtime) Compiling psm v0.1.13 Compiling cpp_demangle v0.3.2 Compiling quote v1.0.9 Compiling rustc_version v0.4.0 Checking getrandom v0.2.3 Checking region v2.2.0 Checking addr2line v0.16.0 Checking rand_core v0.6.2 Compiling io-lifetimes v0.3.1 Compiling rsix v0.23.2 Checking rand_chacha v0.3.0 Checking rand v0.8.3 Compiling thiserror-impl v1.0.25 Checking thiserror v1.0.25 Checking cranelift-entity v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/entity) Checking bincode v1.3.3 Checking object v0.26.0 Checking wasmtime-types v0.30.0 (/home/bjorn/Projects/wasmtime/crates/types) Checking wasmtime-environ v0.30.0 (/home/bjorn/Projects/wasmtime/crates/environ) Checking wasmtime-jit v0.30.0 (/home/bjorn/Projects/wasmtime/crates/jit)
</details>
Enabling cranelift support brings it up to 70 crates.
<details>
Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 Compiling syn v1.0.72 Compiling autocfg v1.0.1 Compiling serde_derive v1.0.126 Compiling serde v1.0.126 Checking cfg-if v1.0.0 Checking hashbrown v0.9.1 Compiling cc v1.0.68 Checking fallible-iterator v0.2.0 Checking stable_deref_trait v1.2.0 Compiling semver v1.0.3 Compiling log v0.4.14 Compiling libc v0.2.99 Compiling target-lexicon v0.12.0 Compiling crc32fast v1.2.1 Compiling cranelift-entity v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/entity) Compiling cranelift-codegen-shared v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen/shared) Compiling memchr v2.4.0 Compiling anyhow v1.0.40 Checking wasmparser v0.80.1 Checking rustc-hash v1.1.0 Checking smallvec v1.6.1 Checking more-asserts v0.2.1 Checking bitflags v1.3.2 Checking ppv-lite86 v0.2.10 Checking adler v1.0.2 Checking itoa v0.4.7 Checking either v1.6.1 Checking rustc-demangle v0.1.19 Checking linux-raw-sys v0.0.24 Checking once_cell v1.7.2 Compiling glob v0.3.0 Checking lazy_static v1.4.0 Compiling wasmtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/wasmtime) Compiling paste v1.0.5 Compiling indexmap v1.6.2 Compiling miniz_oxide v0.4.4 Compiling memoffset v0.6.4 Compiling cranelift-codegen-meta v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen/meta) Compiling backtrace v0.3.61 Compiling wasmtime-runtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/runtime) Compiling psm v0.1.13 Checking itertools v0.10.0 Compiling cpp_demangle v0.3.2 Compiling quote v1.0.9 Checking regalloc v0.0.31 Compiling rustc_version v0.4.0 Checking getrandom v0.2.3 Checking region v2.2.0 Checking rand_core v0.6.2 Compiling io-lifetimes v0.3.1 Compiling rsix v0.23.2 Checking rand_chacha v0.3.0 Checking rand v0.8.3 Compiling cranelift-codegen v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen) Compiling thiserror-impl v1.0.25 Checking thiserror v1.0.25 Checking bincode v1.3.3 Checking gimli v0.25.0 Checking object v0.26.0 Checking wasmtime-types v0.30.0 (/home/bjorn/Projects/wasmtime/crates/types) Checking cranelift-bforest v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/bforest) Checking addr2line v0.16.0 Checking wasmtime-environ v0.30.0 (/home/bjorn/Projects/wasmtime/crates/environ) Checking wasmtime-jit v0.30.0 (/home/bjorn/Projects/wasmtime/crates/jit) Checking cranelift-frontend v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/frontend) Checking cranelift-native v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/native) Checking cranelift-wasm v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/wasm) Checking wasmtime-cranelift v0.30.0 (/home/bjorn/Projects/wasmtime/crates/cranelift)
</details>
I guess there could be an option to disable WASI support entirely for the executable, which should save some time.
bjorn3 edited a comment on issue #3406:
There are pretty much no features of cranelift-codegen that aren't used that aren't required for wasm compilation. There are a couple of other smaller crates that are part of cranelift, but wasmtime only depends on those that are actually needed for wasm compilation (eg cranelift-wasm and it's dependency cranelift-frontend)
I see the cranelift compile for cranelift-native included and was wondering if it could be made optional via a feature.
<strike>Wasmtime doesn't depend on the cranelift-native crate, so it shouldn't be compiled in the first place.</strike>
Edit: It does. It is used to figure out which target it needs to compile for in the first place and which features your cpu supports so it can for example use SIMD instructions: https://github.com/bytecodealliance/wasmtime/blob/1532516a363eed88b5a36726a1710411a9883049/crates/cranelift/src/builder.rs#L48
You can disable the default features of wasmtime. This will disable support for perf jitdump (only compiled on linux anyway and used to assist with profiling using
perf
), disable reading textual wat files, disable parallel compilation (avoids a dependency on rayon), and disable support for wasi-nn (neural networks). If you are using wasmtime as library instead of executable, disabling the default features will also disable cranelift entirely (instead you have to load files pre-compiled by wasmtime, you probably want to re-enable the feature), disable support for caching compilation results and disable support forasync fn
.Together this will reduce the dependency count to just 57 crates.
<details>
Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 Compiling syn v1.0.72 Compiling autocfg v1.0.1 Compiling cc v1.0.68 Compiling serde_derive v1.0.126 Checking cfg-if v1.0.0 Compiling serde v1.0.126 Compiling semver v1.0.3 Compiling libc v0.2.99 Compiling crc32fast v1.2.1 Compiling memchr v2.4.0 Checking stable_deref_trait v1.2.0 Checking fallible-iterator v0.2.0 Checking hashbrown v0.9.1 Compiling target-lexicon v0.12.0 Compiling log v0.4.14 Compiling anyhow v1.0.40 Checking wasmparser v0.80.1 Checking adler v1.0.2 Checking bitflags v1.3.2 Checking ppv-lite86 v0.2.10 Checking more-asserts v0.2.1 Checking rustc-demangle v0.1.19 Checking itoa v0.4.7 Checking once_cell v1.7.2 Checking linux-raw-sys v0.0.24 Compiling glob v0.3.0 Checking lazy_static v1.4.0 Compiling wasmtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/wasmtime) Compiling paste v1.0.5 Compiling indexmap v1.6.2 Compiling miniz_oxide v0.4.4 Compiling memoffset v0.6.4 Checking gimli v0.25.0 Compiling backtrace v0.3.61 Compiling wasmtime-runtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/runtime) Compiling psm v0.1.13 Compiling cpp_demangle v0.3.2 Compiling quote v1.0.9 Compiling rustc_version v0.4.0 Checking getrandom v0.2.3 Checking region v2.2.0 Checking addr2line v0.16.0 Checking rand_core v0.6.2 Compiling io-lifetimes v0.3.1 Compiling rsix v0.23.2 Checking rand_chacha v0.3.0 Checking rand v0.8.3 Compiling thiserror-impl v1.0.25 Checking thiserror v1.0.25 Checking cranelift-entity v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/entity) Checking bincode v1.3.3 Checking object v0.26.0 Checking wasmtime-types v0.30.0 (/home/bjorn/Projects/wasmtime/crates/types) Checking wasmtime-environ v0.30.0 (/home/bjorn/Projects/wasmtime/crates/environ) Checking wasmtime-jit v0.30.0 (/home/bjorn/Projects/wasmtime/crates/jit)
</details>
Enabling cranelift support brings it up to 70 crates.
<details>
Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 Compiling syn v1.0.72 Compiling autocfg v1.0.1 Compiling serde_derive v1.0.126 Compiling serde v1.0.126 Checking cfg-if v1.0.0 Checking hashbrown v0.9.1 Compiling cc v1.0.68 Checking fallible-iterator v0.2.0 Checking stable_deref_trait v1.2.0 Compiling semver v1.0.3 Compiling log v0.4.14 Compiling libc v0.2.99 Compiling target-lexicon v0.12.0 Compiling crc32fast v1.2.1 Compiling cranelift-entity v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/entity) Compiling cranelift-codegen-shared v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen/shared) Compiling memchr v2.4.0 Compiling anyhow v1.0.40 Checking wasmparser v0.80.1 Checking rustc-hash v1.1.0 Checking smallvec v1.6.1 Checking more-asserts v0.2.1 Checking bitflags v1.3.2 Checking ppv-lite86 v0.2.10 Checking adler v1.0.2 Checking itoa v0.4.7 Checking either v1.6.1 Checking rustc-demangle v0.1.19 Checking linux-raw-sys v0.0.24 Checking once_cell v1.7.2 Compiling glob v0.3.0 Checking lazy_static v1.4.0 Compiling wasmtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/wasmtime) Compiling paste v1.0.5 Compiling indexmap v1.6.2 Compiling miniz_oxide v0.4.4 Compiling memoffset v0.6.4 Compiling cranelift-codegen-meta v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen/meta) Compiling backtrace v0.3.61 Compiling wasmtime-runtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/runtime) Compiling psm v0.1.13 Checking itertools v0.10.0 Compiling cpp_demangle v0.3.2 Compiling quote v1.0.9 Checking regalloc v0.0.31 Compiling rustc_version v0.4.0 Checking getrandom v0.2.3 Checking region v2.2.0 Checking rand_core v0.6.2 Compiling io-lifetimes v0.3.1 Compiling rsix v0.23.2 Checking rand_chacha v0.3.0 Checking rand v0.8.3 Compiling cranelift-codegen v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen) Compiling thiserror-impl v1.0.25 Checking thiserror v1.0.25 Checking bincode v1.3.3 Checking gimli v0.25.0 Checking object v0.26.0 Checking wasmtime-types v0.30.0 (/home/bjorn/Projects/wasmtime/crates/types) Checking cranelift-bforest v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/bforest) Checking addr2line v0.16.0 Checking wasmtime-environ v0.30.0 (/home/bjorn/Projects/wasmtime/crates/environ) Checking wasmtime-jit v0.30.0 (/home/bjorn/Projects/wasmtime/crates/jit) Checking cranelift-frontend v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/frontend) Checking cranelift-native v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/native) Checking cranelift-wasm v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/wasm) Checking wasmtime-cranelift v0.30.0 (/home/bjorn/Projects/wasmtime/crates/cranelift)
</details>
I guess there could be an option to disable WASI support entirely for the executable, which should save some time.
bjorn3 commented on issue #3406:
This is a rough breakdown of dependencies in categories:
<details>
# various utils Compiling autocfg v1.0.1 Compiling cc v1.0.68 Checking cfg-if v1.0.0 Compiling memchr v2.4.0 Checking fallible-iterator v0.2.0 Checking stable_deref_trait v1.2.0 Compiling paste v1.0.5 Compiling log v0.4.14 Checking lazy_static v1.4.0 Checking rustc-hash v1.1.0 Checking itertools v0.10.0 Checking once_cell v1.7.2 Compiling semver v1.0.3 Checking more-asserts v0.2.1 Compiling glob v0.3.0 Checking itoa v0.4.7 Compiling memoffset v0.6.4 Compiling rustc_version v0.4.0 Compiling psm v0.1.13 # data structures Checking either v1.6.1 Checking bitflags v1.3.2 Checking hashbrown v0.9.1 Compiling indexmap v1.6.2 Checking smallvec v1.6.1 # proc-macro related things Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 Compiling syn v1.0.72 Compiling quote v1.0.9 # (de)serialization Compiling serde_derive v1.0.126 Compiling serde v1.0.126 Checking bincode v1.3.3 # object file parsing Checking adler v1.0.2 Compiling miniz_oxide v0.4.4 Compiling crc32fast v1.2.1 Checking object v0.26.0 # debuginfo handling and backtrace generation Checking gimli v0.25.0 Checking addr2line v0.16.0 Checking rustc-demangle v0.1.19 Compiling cpp_demangle v0.3.2 Compiling backtrace v0.3.61 # cranelift Compiling target-lexicon v0.12.0 Checking regalloc v0.0.31 Compiling cranelift-entity v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/entity) Compiling cranelift-codegen-shared v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen/shared) Compiling cranelift-codegen-meta v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen/meta) Compiling cranelift-codegen v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/codegen) Checking cranelift-bforest v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/bforest) Checking cranelift-frontend v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/frontend) Checking cranelift-native v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/native) # webassembly handling Checking wasmparser v0.80.1 Checking cranelift-wasm v0.77.0 (/home/bjorn/Projects/wasmtime/cranelift/wasm) Checking wasmtime-cranelift v0.30.0 (/home/bjorn/Projects/wasmtime/crates/cranelift) # randomness Checking ppv-lite86 v0.2.10 Checking getrandom v0.2.3 Checking rand_core v0.6.2 Checking rand_chacha v0.3.0 Checking rand v0.8.3 # error handling utils Compiling anyhow v1.0.40 Compiling thiserror-impl v1.0.25 Checking thiserror v1.0.25 # os interaction Compiling libc v0.2.99 Checking linux-raw-sys v0.0.24 Compiling io-lifetimes v0.3.1 Compiling rsix v0.23.2 Checking region v2.2.0 Compiling wasmtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/wasmtime) Compiling wasmtime-runtime v0.30.0 (/home/bjorn/Projects/wasmtime/crates/runtime) Checking wasmtime-types v0.30.0 (/home/bjorn/Projects/wasmtime/crates/types) Checking wasmtime-environ v0.30.0 (/home/bjorn/Projects/wasmtime/crates/environ) Checking wasmtime-jit v0.30.0 (/home/bjorn/Projects/wasmtime/crates/jit)
</details>
andrewdavidmackenzie commented on issue #3406:
Thanks for your rapid and extensive reply.
Reviewing output, I stand corrected. It's docs and checking that hit the native stuff:
Compiling cranelift-codegen v0.77.0 Documenting flowsamples v0.36.0 (/Users/andrew/workspace/flow/samples) Checking cranelift-frontend v0.77.0 Checking cranelift-native v0.77.0 Checking cranelift-wasm v0.77.0
Thanks for the other suggestions, I will try them!
(Feel free to close issue if you agree)
andrewdavidmackenzie commented on issue #3406:
Maybe for the benefit of others, I ended up with this, which is enough for me to load and execute a WASM module (compiled with rustc) to .wasm
wasmtime = { version = "0.30.0", default-features = false, features = ["cranelift"], optional = true }
alexcrichton commented on issue #3406:
I'm going to close this issue because I don't think there's an obvious low-hanging fruit to pick here and otherwise refactoring to reduce build times is always a welcome improvement and doesn't necessarily need an issue to track.
alexcrichton closed issue #3406:
Feature
Currently I use wasmtime as a WASM runtime for embedding wasm execution in my rust project.
Compiling wasmtime and dependencies is quite a bit longer than the other wasm runtime my project supports.I see the cranelift compile for cranelift-native included and was wondering if it could be made optional via a feature.
Benefit
Faster compile times, locally and in CI.
Implementation
Use rust "features" to allow opt-in or opt-out (via disable-all and then opt in on some) of some subset of wasmtime/cranelift functionality.
Alternatives
Can't think of any obvious ones.
Last updated: Dec 23 2024 at 13:07 UTC