* Add wasmtime-c-api-impl to the list of crates to publish
* Enable rustdoc and publishing for c-api crate
* Provide paths to c-api headers as cargo links metadata
* Add a README section about using wasm-c-api in a rust crate
* In C API doc comment, mention use case for crates w/ C bindings
* Enable publishing for wasmtime-c-api-macros (prtest:full)
* Move c-api crates later in the publishing sequence (prtest:full)
Looks like it's been awhile since our last update. I've updated the
dependency here and additionally vetted the various dependency upgrades.
I notably did not vet `zstd-sys` since that would require vetting all of
zstd's C implementation itself which I am not, nor do I suspect many of
are, equipped to do. In lieu of that I've updated the exemption of
`zstd-sys` to the newer version.
Closes#7869
* Update and add lots of docs, mostly for components
When I originally implemented the embedding API for the component model
I left a lot of `// TODO: say more here` style comments assuming I'd
come back around before stabilization. While I didn't quite make it in
time for Wasmtime 17 this is my attempt to improve things for the
future. This should add substantive documentation for all component-model
related things and flesh out some more details here and there. Nowhere
near comprehensive but, hey, Rome wasn't built in a day either.
* Update crates/wasmtime/src/runtime/component/component.rs
Co-authored-by: Jeff Parsons <jeff@parsons.io>
* Update crates/wasmtime/src/runtime/component/component.rs
Co-authored-by: Jeff Parsons <jeff@parsons.io>
---------
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
Co-authored-by: Jeff Parsons <jeff@parsons.io>
* Add C API for GuestProfiler
* GuestProfiler C API: remove unsafe and add docs
* Fix clang-format complaints
* rename to wasmtime_guestprofiler_t for consistency, change to passing tuples by struct type, clarify docs
* rustfmt
* out is marked "own" too
* gate on profiling feature
* Fix handling of `Tunables` on cross-compiles
This commit fixes how Wasmtime handles `Tunables` when targetting
non-host platforms (or namely platforms with different pointer widths).
Previously the host's `Tunables` would always be used instead of the
target's tunables which meant that modules couldn't be loaded on the
other platform due to the host having differing tunables by default.
This commit updates tunables in `wasmtime::Config` to all be optional
and loading the actual `Tunables` is deferred until the target is known
during `Engine`-creation time.
* Fix warning
* Shuffle some items around in `wasmtime`
This is a follow-up to #7766 with some more changes and reorganization.
These are some small items here and there which shouldn't have any
actual impact on functionality but are intended to reorganize a bit.
Changes here include:
* Move component artifact definitions to `wasmtime-environ` as core
module ones already live there.
* Rename the module with module artifacts from `instantiate` to
`module_artifacts`.
* Make `wasmtime-jit-icache-coherence` an optional dependency as only
the `runtime` feature requires it.
* Reorganize serialized metadata for wasmtime ELF files to consolidate
everything back into `wasmtime::engine::serialization`. This is to
prevent the definition of the serialization format being spread across
a few files.
* Touching up the `serialization` module to compile in all builds of the
`wasmtime` crate.
* fix docs typo
---------
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
Currently translation of Wasm code uses the `FUNCREF_MASK` constant
which has type `usize` but this type is not always appropriate in
cross-compiled situations. This commit fixes the usage of `FUNCREF_MASK`
by using the platform-independent value (a negative value) along with
some extra asserts and an explantation of how to update if necessary.
Purely mechanical, no functional changes.
This is to help differentiate between value types (i32, i64, reference types,
etc...) and defined types (function signatures, struct definitions, array
definitions).
* Add `runtime` feature to `wasmtime` crate
This feature can be disabled to build `wasmtime` only for compilation.
This can be useful when cross-compiling, especially on a target that
can't run wasmtime itself (e.g. `wasm32`).
* prtest:full
* don't round pages without runtime feature
* fix async assertions
* move profiling into runtime
* enable runtime for wasmtime-wasi
* enable runtime for c-api
* fix build_artifacts in non-cache case
* fix miri extensions
* enable runtime for wast
* enable runtime for explorer
* support cranelift all-arch on wasm32
* add doc links for `WeakEngine`
* simplify lib runtime cfgs
* move limits and resources to runtime
* move stack to runtime
* move coredump and debug to runtime
* add runtime to coredump and async features
* add wasm32 build job
* combine engine modules
* single compile mod
* remove allow for macro paths
* add comments
* wasmtime: Rename `SignatureFooBar` to `TypeFooBar`
No functional changes, just the following mechanical renames:
* `VMSharedSignatureIndex` to `VMSharedTypeIndex`
* `SignatureIndex` to `TypeIndex`
* `SignatureRegistry` to `TypeRegistry`
* and more
This is intended to start paving the way for Wasm GC support, where there are
more than just function signatures in a Wasm module's type section, and we are
going to need to register non-function-signature types in the registry as well,
for things like casting between reference types and passing reference types
across Wasm modules.
* Reintroduce different index types for module-interned types vs Wasm-index-space types
* Fix a couple unused-import warnings
* feat: support component instance import type introspection
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor: implement `import_types` on `Linker`
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor: flatten `types::ComponentItem` members
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor: remove `types` re-exports
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* feat: implement component type introspection
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* chore: derive `Debug` for `Field`
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor: return `ExactSizeIterator` for component function parameters/results
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* tests: add `introspection` test
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* chore: derive `Clone` on `ComponentItem` types
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* feat: support module and instance type introspection
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* Enable all winch tests on windows
prtest:mingw-x64
* Plumb through x64 unwind info creation
* Add the frame regs unwind info
* Emit UnwindInfo::SaveReg instructions
* Review feedback
* Comment the offset_downward_to_clobbers value
* Enable the component model by default
This commit enables the component model by default in the embedding API
and the CLI. This means that an opt-in of `-W component-model` is no
longer required and additionally `.wasm_component_model(true)` is no
longer required. Note that this won't impact existing embeddings since
the component model feature doesn't do much less `wasmtime::component`
is used, and if that's being used this is probably good news for you.
* Fix non-component model build
* WASI: copy in the version 0.2.0 wits
* wasmtime's wits: use versions 0.2.0 of wasi packages
* bindgens and other fixed version strings: change 0.2.0-rc-etc to 0.2.0
Previously temporary streams created as part of the preview1 adapter in
the wasmtime-wasi crate were left open which meant that they continued
to occupy space in the resource table and the underlying file
accidentally wasn't ever actually closed.
cc #7813
* update Wasmi fuzzing oracle to version 0.31.0
This allows us to enable the bulk-memory, reference-types and tail-call Wasm proposals for the Wasmi fuzzing oracle.
* apply rustfmt
* be more explicit about supported Wasm features
* align Wasmi config to input config
I am not sure if this is how it is intended to be used. Please review and provide feedback.
* remove duplicate threads_enabled
* remove min and max tables
We can do this since Wasmi supports reference-types Wasm proposal.
* add comment about config mutation
* use Wasmi v0.31.1
* be more explicit about supported Wasm features
* add comment about config mutation
* update wasmi_arena to v0.4.1
* preview 1 test-programs: fdflags_sync always unsupported
we never pursued making the fdflags_sync supported on any platform. rather than carry around this baggage, delete the configuration variable and make the single test that considered it always assert that fdflags_sync is not supported.
* fix warning
* Update to the latest wasi-io and wasi-sockets.
The only changes here are documentation changes in the Wit files. This
is just updating things so that it's easier to see what's up to date.
* Update wasi-http's copy of wasi-sockets too.
* Remove `+ Sync` constraints from preview2 implementation
* Only use mutable references in WasiView to guarantee unique access to Preview2 resources. Removed the _mut suffixes to align with WasiHttpView.
* Always use Descriptor::Directory for directories, regardless of whether they were preopened or opened using open_at. This fixes build errors regarding overlapping mutable lifetimes introduced in the previous commit.
* Remove some more `+ Sync`s
* Remove one more
* typo
* Fix build errors on Rust <= 1.73. Code already compiled fine on >= 1.74
* wasmtime: add EngineWeak which has ::upgrade, created by Engine::weak
Engine is, internally, just an Arc<EngineInner>, so this is trivial to implement -
EngineWeak is a Weak<EngineInner>.
This behavior is desirable because `Engine::increment_epoch` typically
happens in a worker thread, which in turn requires additional machinery
to discard the `Engine` once it is no longer needed. If instead the
worker thread holds an `EngineWeak`, it can stop ticking when all
consumers of the `Engine` have dropped it. This has been documented as a
suggestion in `increment_epoch`.
For an example of additional machinery which is simplified by this change, see 25edee0700/lib/src/execute.rs (L108-L116))
Co-authored-by: John Van Enk <vanenkj@gmail.com>
* add a test
---------
Co-authored-by: John Van Enk <vanenkj@gmail.com>
* mpk: allow configuring MPK from the command line
This allows the following usage:
```console
$ wasmtime --pooling-allocator=y --memory-protection-keys=y ...
```
* mpk: add CLI test for failure
* review: move `bail!` outside the pooling allocator block
* fix: use absolute dependency path
This mirrors how traits for the host are all called `Host` and it avoids
name clashes with types that share the name of the interface they are in.
I've also added some simple debugging of macro-generated code to get
better error messages.
Closes#7775
* fix: allow dynamic owned resources to be used as borrowed parameters
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* tests: add `can_use_own_for_borrow` test
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* mpk: also force MPK during benchmarking
This change takes advantage of the `WASMTIME_TEST_FORCE_MPK` environment
variable to force its use in the `call.rs` benchmarks. I see differences
in several cases when running:
```console
$ taskset --cpu-list 0-15 cargo bench -- async
$ WASMTIME_TEST_FORCE_MPK=1 taskset --cpu-list 0-15 cargo bench -- async
```
To properly isolate the MPK effects, this adds a `sync-pool` option
(`IsAsync::NoPooling`).
* mpk: disable PKRU read unless logging is turned on
After noticing some minor effects with this PKRU read, I chose to avoid
it unless logging is enabled. A perfectly valid alternative would be to
remove the logging altogether, but I have found this very helpful when
trying to troubleshoot MPK issues.
* mpk: inline PKRU functions
To avoid any unnecessary call overhead, we hint to the compiler that
`pkru::read` and `pkru::write` should be inlined.
* wasi: pull in contents of wasi-sockets, wasi-http, and wasi-cli 0.2.0-rc-2024-01-16
* command-extended and test worlds: use rc-2024-01-16
* sockets implementation: v6only is now mandatory
* adapter: cli imports and exports are from rc-2024-01-16 now
* eliminate ipv6-only methods and tests
* a v6_client.blocking_connect(net, v4_listener) will always fail
with INVAL right away.
* eliminate the paths where a v6 client is allowed to connect to v4.
* eliminate the udp_dual_stack_conversation from udp_sample_application
* component-basic: update wasi:cli version
* wasi-http: sync wit directory
* wasi-http: fix import version
* code review from dave
* test both ipv4 address on v6 socket, and ipv6-mapped-ipv4 on v6 socket, both fail
* Move `jit` crate to `environ`
Move the platform agnostic parts of the crate `wasmtime-jit` to
`wasmtime-environ`. This is the first part of the refactoring discussed
here: https://github.com/bytecodealliance/wasmtime/issues/7652 and a
follow up will move the remaining parts of `wasmtime-jit` so that the
crate can be deleted.
* Move `jit` crate to `wasmtime`
Move the remaining parts of `wasmtime-jit` to the `wasmtime` crate and
remove `wasmtime-jit`. This is part of the refactoring discussed in
https://github.com/bytecodealliance/wasmtime/issues/7652.
* undo toml formatting
* Trigger pipeline: prtest:full
* Remove `jit` directory
* move `ProfilingAgent` out of `profiling` feature
* add links to ELF_NAME_DATA
* Add a small test checking that pollables can be used many times
* Tests where two commands have their stdin/stdout piped together
* Pipe together wasmtime subprocesses instead of managing the buffer
* Update the wasm-tools family of crates
Brings in support for validating gc instructions, but they're all left
disabled for now.
* Update fuzz test case generation
* More test fixes, remove stray files
* More test fixes
* Rebase
Previously, `first_non_empty_{c}io_vec` always returned `Ok(None)` for buffers
residing in shared memories since they cannot, in general, safely be represented
as slices. That caused e.g. `wasi-libc` to spin forever when trying to write to
stdout using `fd_write` since it always got `Ok(0)` and never made progress.
This commit changes the return type of both functions to use `GuestPtr` instead
of `GuestSlice{Mut}`, allowing safe access to shared guest memory.
Big thanks to Alex Crichton for narrowing this down and suggesting the fix.
Fixes#7745
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
The file copy added for shared libraries is not needed and unused, it's not done for static builds and everywhere refers to WASMTIME_BUILD_PRODUCT or the original file in cargo's output.