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

Allow user to override component type custom section name (or else generate a random name)

Open dicej opened this issue 2 years ago • 1 comments

Currently, wit-bindgen generates the custom section name using the format "component-type:{world_name}". This can lead to issues when linking separately-compiled code together, each containing code built from wit-bindgen code using the same world, because wasm-ld will concatenate identically-named custom sections together, resulting in something wit-component can't parse.

This came up while adding WASI Preview 2 support to wasi-libc based on wit-bindgen-generated C bindings and then later linking libc.a into a program that also uses wit-bindgen-generated bindings targeting the same world. Ideally, wasi-libc would use a custom section name with a big random name that's unlikely to conflict with application code.

Alternatively, wit-bindgen could just generate a big random name by default.

dicej avatar Dec 07 '23 22:12 dicej

Nice find. Lets add a suffix to the section name that wit-component and others will ignore that is the crate name, filename, crate version of where the proc macro is invoked? and provide a way to give the suffix in the wit-bindgen CLI for the other languages as well. That way builds stay reproducible...

pchickey avatar Dec 07 '23 23:12 pchickey