From 58897bfb4bcd15b955d978e95dfd5c4abb5f35b7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 10 Feb 2025 10:26:25 -0600 Subject: [PATCH] Add a small `README.md` for `wit-bindgen-rt` (#1162) Requested in https://github.com/rust-lang/rust/pull/136395#issuecomment-2645783005 --- crates/guest-rust/rt/Cargo.toml | 2 +- crates/guest-rust/rt/README.md | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 crates/guest-rust/rt/README.md diff --git a/crates/guest-rust/rt/Cargo.toml b/crates/guest-rust/rt/Cargo.toml index d0a43412e..83294ec60 100644 --- a/crates/guest-rust/rt/Cargo.toml +++ b/crates/guest-rust/rt/Cargo.toml @@ -6,7 +6,7 @@ repository = { workspace = true } license = { workspace = true } homepage = 'https://github.com/bytecodealliance/wit-bindgen' description = """ -Runtime support for the `wit-bindgen` crate +Internal runtime support for the `wit-bindgen` crate. """ [dependencies] diff --git a/crates/guest-rust/rt/README.md b/crates/guest-rust/rt/README.md new file mode 100644 index 000000000..2c9c8b2cc --- /dev/null +++ b/crates/guest-rust/rt/README.md @@ -0,0 +1,22 @@ +# `wit-bindgen-rt` + +This is an internal implementation detail of the [`wit-bindgen`] crate. The +source for this crate lives at https://github.com/bytecodealliance/wit-bindgen +and this crate is located in `crates/guest-rust/rt` folder. The purpose of this +crate is to contain "runtime" code related to the macro-expansion of the +`wit_bindgen::generate!` macro such that the `wit-bindgen` crate dependency can +be removed in some situations. + +This crate contains a precompiled object file and archive at +`src/cabi_realloc.o` and `src/libwit_bindgen_cabi_realloc.a`. This is compiled +from the source `src/cabi_realloc.c` and is checked in as precompiled to avoid +needing a C compiler at compile-time which isn't always available. This object +file is only used on wasm targets. + +The object file is compiled by +[this script]https://github.com/bytecodealliance/wit-bindgen/blob/main/ci/rebuild-libcabi-realloc.sh) +and is verified in repository continuous integration that the checked-in +versions match what CI produces. + +[`wit-bindgen`]: https://crates.io/crates/wit-bindgen +