Wasm: #[no_mangle] for root level items in leaf crates #46294
Labels
A-FFI
Area: Foreign function interface (FFI)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
O-wasm
Target: WASM (WebAssembly), http://webassembly.org/
All the inline usages of Rust in js that I have seen have this
#[no_mangle]
attribute added to each function.E.g. see this example by @killercup , or this one by browserify.
I haven't coded any hybrid js+wasm yet, but to me it seems that having to specify the
#[no_mangle]
attribute in order to access wasm module exports via theexports
function at their original name is a bit of a boilerplate.So I wonder: can't we add a mode to rustc that allows you to omit the attribute?
Specifically, I would propose that there should be a
-Z root-no-mangle
(eventually -C) flag for rustc which automatically adds a#[no_mangle]
attribute to any function markedpub
that is in the root of the crate.This flag could be added by cargo to the leaf crate, at least in cases where it compiles actual inline Rust. I'm not so sure about larger codebases that are not inlined.
A few points:
#[no_mangle]
attribute stands in the way.cc @alexcrichton
The text was updated successfully, but these errors were encountered: