Skip to content
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

Add make target for building wasmer-api with js feature as cdylib #5226

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

maminrayej
Copy link
Contributor

Since Rust 1.59.0, using:

#![cfg_attr(feature = "js", crate_type = "cdylib")]

has been deprecated. Seems like in Rust 1.84.0, this is going to be a hard error, so building the wasmer crate with the js feature enabled, will result in an error (and does result an error now if you try to build with the latest nightly).

I've tried multiple ways to solve this issue, namely:

  • Setting a conditional cfg in lib/api/Cargo.toml to set the crate-type to cdylib when the js feature is enabled. This did not work. Cargo will emit a warning that such a config is just ignored. You can also confirm that by seeing that wasmer.wasm was not generated.
  • I tried to pass flags to rustc via lib/api/build.rs and RUSTFLAGS, but neither worked.

Finally I've settled on the solution proposed by this PR. For convenience, I added a make target for this specific kind of build. I can confirm that running this target with the latest nightly, correctly produces the desired wasmer.wasm file.

Resolves #5214.

@syrusakbary syrusakbary merged commit c9035d3 into main Nov 7, 2024
71 of 72 checks passed
@syrusakbary syrusakbary deleted the make-target-for-api-js branch November 7, 2024 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't compile with js feature on nightly rustc
2 participants