-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unsupported custom section: '__wasm_bindgen_unstable'
#92
Comments
Can you post an example which reproduces this? |
Hi @koute, here's a minimal example: https://github.com/flodiebold/wasm_bindgen_cargo_web.
In general, any use of wasm_bindgen seems to produce this for me. |
Ah, right. |
Supporting wasm-bindgen would be wonderful! It took me a while to debug the situation and realize this isn't supported . Maybe put a note to the readme? |
Hi @koute! Can we expect progress on this in the near future? ) I would love to see both P.S. Now it fails not during the building process, but on opening the web page: |
@mvlabat I still haven't fully thought out how to integrate those two, but it is on my TODO list. There are a few ways we could go about here:
If you have any thoughts regarding this I'd love to hear them. |
I can't speak for @alexcrichton, but maybe a very stripped down and simplified version of the Something that provides the absolute barest functionality, and stdweb can then build the |
We definitely want to support a macro like Along those lines it'd be great to see what the stripped down and simplified version looks like. If it requires features that still require some design on the wasm-bindgen side of things we could always add a small implementation and work around the difficulties on wasm-bindgen/wasm-pack to unblock this! |
@alexcrichton Let's me quickly describe the current implementation of the underlying mechanism through which my The let value: i32 = 123;
js_raw!("console.log($0);", value); and generates something like the following code: (not exactly, but that's not important) {
extern "C" {
pub fn __cargo_web_snippet_$code_hash(arg: i32);
}
__cargo_web_snippet_$code_hash(value)
} and generates a JSON file like this: {
"name": "__cargo_web_snippet_$code_hash",
"code": "console.log($0);",
"arg_count": 1
} which is saved to: (I originally used custom sections, but that cannot work until rust-lang/rust#56639 is fixed.) Then "__cargo_web_snippet_$code_hash": function($0) {
console.log($0);
} So would something like this be acceptable as-is? If not what changes would have to be made? One problem I can see here in bringing this as-is is that procedural macros don't know where the |
So my understanding is that the biggest issue right now is the lack of custom sections, and custom sections will basically solve all the problems? If so, then pushing hard on 56639 sounds like a good idea. Maybe it can be fixed by |
As this is a procedural macro it seems pretty reasonable that wasm-bindgen would have enough support for this one day. For example I could imagine something like for the snippet above:
#[wasm_bindgen(module = "/path/to/fooXXXXX.js")]
extern {
fn the_function(a: i32);
}
unsafe {
the_function(value)
}
And I think that'd all end up working? |
Doesn't the |
It does use custom sections, yes, but it employs a number of tricks to ensure that it doesn't hit that issue. |
So is there actually a way to always force a custom section to be emitted or something? When I tried to use custom sections for my |
There sort of is, I explained a bit on the bug but this is just how linkers, object files, and the Rust compilation model works. The wasm-bindgen macro generates exported functions in the same object file as custom sections and the exported functions force the custom sections to be included. The exported functions are later removed by wasm-bindgen itself. |
Not sure if I have something configured wrong, but I get this error all the time
The text was updated successfully, but these errors were encountered: