-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Linker error when building a proc-macro crate that uses wasm-bindgen
#3457
Comments
I think this is an issue with having to detect that this is a proc macro and not defining any FFI points. Though I'm surprised it doesn't do that already, as it should detect the target as not being May I ask what the use-case is for this anyway? |
I wonder then what changed in Rust 1.70 so that it stopped working? Also it seems that in some dependent crates it works if one sets
The crate https://docs.rs/wasm-bindgen-derive which adds some missing functionality (handling |
I have no clue, pretty strange.
Why would you depend on |
Good point :) That was my first proc-macro, and I guess I misunderstood the details of the build process. I would still like to restrict the |
On a second thought, while this does serve as a workaround, it is still very useful to have explicit dependencies in a proc-macro crate, even if they are technically "unused". The user of the proc-macro will have to have those, so it is much better to enforce it right away rather than rely on the user to explicitly add them. Plus, of course, there's an issue of the proper version bounds - even without the undocumented stuff, how do I communicate to the user "this proc-macro requires |
You can't re-export the dependencies from your proc-macro crate, so it's pointless. The user will still have to explicitly add them.
There is a disadvantage to "documenting by adding as a dependency", the user will have increased compile times. Proc-macros are compiled for the target the compiler is being run on, but dependencies that are for the application itself have to be compiled for the application target. So in this case In any case, this should be fixed nevertheless. |
I would personally take safety over compilation times, but I see your point. It seems that this problem is generally solved by Even better, of course, if those two issues (#2370 and #111) could be resolved, then the whole |
What do you mean with "safety"? How do you gain safety by this approach?
Do you mean gate |
Suppose a crate that uses
I don't think adding a feature would be considered a breaking change.
It will ensure that the code |
Ah, yes! Got confused by the word "safety".
It is, because users are currently relying on this feature always being available, if it's gated behind a crate feature users will have to opt-in, which they currently can't, because the crate feature doesn't exist yet. So that's pretty breaking. I think what you could do for
That way you make sure that users have the correct version of Just to clarify: |
Uh, what feature? Neither |
What? I'm confused 🤣. |
No, I meant adding a feature that would supply |
You mean into I'm not sure exactly what it does, but if what it does is address #2370 and #111, then I would say no. I would rather fix the |
That would indeed be ideal. Also sorry for dragging on this thread :) |
No problem at all! GitHub is probably not the right medium for something like this though. |
Describe the Bug
Linker error when building a proc-macro crate that uses
wasm-bindgen
.Steps to Reproduce
Cargo.toml
:src/lib.rs
:Expected Behavior
cargo build
succeeds.Actual Behavior
Linker error on
cargo build
:Running
cargo build
produces:Additional Context
Reproduces on: Ubuntu 20.04.3 LTS x86_64, rustc 1.70.0 (90c541806 2023-05-31)
Works on MacOS 13.3.1, same rustc
Works on the Ubuntu machine when downgrading to Rust 1.69:
The text was updated successfully, but these errors were encountered: