I notice rust 1.70 enabled the target features sign-ext and mutable-global by default. This is .. a little disruptive but we can adapt. I want to make a testcase that exhibits uses of both of these features, however, and am struggling a bit. I can do sign-ext
by using some inline asm!
to pick out the required instruction, but I'm wondering: is there a rust construct that causes a mutable global export? If I make a normal mut static
and #[no_mangle]
it, I think it exports an immutable global that has a linear-memory address of the mutable variable. Is the only viable approach here to write a module in .wat
?
I can't figure out anything to put in global_asm!
that might work
Yeah rust and llvm have no native ability to export globals in wasm, so you'll need probably global asm to get the linking metadata to be present
and when that fails you can roll your own object file
@Alex Crichton I'm trying to find an example of global_asm
with wasm and coming up short -- it doesn't look like I can jam arbitrary wat in there -- what's the supported syntax?
oh geez I guess I can infer something by reading this https://llvm.org/doxygen/WebAssemblyAsmParser_8cpp_source.html
Yeah global_asm!
has funky syntax and honestly I'm not so sure of it myself. I think last I checked I was poking around various test cases in LLVM to figure out what to do since I don't think it's documented anywhere. It's definitely not arbitrary s-expr wasm stuff
ok. I wound up just using a utility crate we use to programmatically build wasms. who knows if any rust constructs actually correspond! haha
Graydon Hoare has marked this topic as resolved.
Last updated: Dec 23 2024 at 13:07 UTC