wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

wit-bindgen-rt: add option to regenerate binary artifacts

Open Fabian-Gruenbichler opened this issue 10 months ago • 6 comments

wit-bindgen-rt is now (since 1.86) part of rustc's transitive dep tree, it would be great if there were an option (e.g., a feature honored by build.rs?) to regenerate the included binary artifacts that could be used as part of building rustc. distros like Debian have this as requirement for distribution.

I can try to whip something up if this seems acceptable.

Fabian-Gruenbichler avatar Apr 30 '25 12:04 Fabian-Gruenbichler

I wouldn't be opposed to adding this, but I also think that implementing this is probably going to be trickier than expected. For example this won't really be tested at all so is likely to regress over time. Additionally you'll probably need to guarantee that the script to build these artifacts is all part of the wit-bindgen-rt crate which is not currently the case (and again would be un-tested).

The Rust compiler, while it transitively includes this crate, does not use this crate because the Rust compiler is not compiled to wasm. In that sense the objects could also be replaced with blank files, but I don't know the specifics of this policy and what the implications are for possible solutions.

alexcrichton avatar Apr 30 '25 15:04 alexcrichton

I haven't yet tried to build 1.86 at all, this just came up while reviewing the newly vendored files. I will see if removing them works out, then it's probably simpler for the time being..

IMHO it would still be great to have a way to rebuild them included in the published crate - at the latest it would be required as soon as the wit stack including wit-bindgen-rt is packaged itself for Debian, which will probably happen at some point if WASM continues to pick up steam ;)

Fabian-Gruenbichler avatar May 06 '25 07:05 Fabian-Gruenbichler

with rustc 1.91.1, the build of libstd for wasm targets now fails if the pre-compiled artifacts in wit-bindgen (-rt is no more ;)) are removed prior to building.. I'll once more see if I can work around this locally, but still wanted to make note of it here ;)

Fabian-Gruenbichler avatar Nov 28 '25 18:11 Fabian-Gruenbichler

the dep-chain there is

std ---wasi-p2 target---> wasi 0.14 -> wit-bindgen

for 1.91.1

Fabian-Gruenbichler avatar Nov 28 '25 18:11 Fabian-Gruenbichler

haven't found a way yet, seems like wit-bindgen including those files is now a hard dependency when building the stdlib for the wasi-p2 target.. if I am missing something I'd be glad to get additional pointers or hints!

Fabian-Gruenbichler avatar Nov 28 '25 19:11 Fabian-Gruenbichler

at least regenerating them seems pretty straight-forward, if it works as expected I will open a PR making the script more useful in that context, maybe it would be possible to run it from build.rs if the objects are missing or a cfg/env var/.. is set..

Fabian-Gruenbichler avatar Nov 28 '25 20:11 Fabian-Gruenbichler