-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Build script is using code to compile Windows target instead of WASM target #14881
Comments
@rustbot label +A-cfg |
AFAICT this is cargo's @rustbot transfer cargo |
To run your build script on your host machine, Cargo always compiles it to your host platform, which is To get the target platform you main package compile to at "build script execution time", you'll need to read either If you do want to compile your build script to a certain target platform, see the unstable feature artifact dependencies. |
As this seems to be a misuse of |
Thanks for the quick response/triage. I'll add a quick README to the example repository with a reference to this information in case anyone stumbles upon it in the future. |
See rust-lang/cargo#14881 for rationale
This is a bug related to a
build.rs
file using conditional compilation macros to change it's behavior based on the target being compiled to (either WASM or Windows). The minimal example I was able to create is found in this repository here: https://github.com/FaceFTW/cfg-bugOriginally, I found the issue in this repository and had a hacky workaround in CI: https://github.com/FaceFTW/rust-pipes
I tried this:
Compiling the library target of the project for the
wasm32-unknown-unknown
target with Cargo using the following build script:build.rs
I expected to see this happen:
When running the following command, I should be able to find the following output from the build script indicating the build script is using the specific code for WASM targets:
cargo +nightly build --lib --release --target wasm32-unknown-unknown -vv
Instead, this happened:
When running the same command, I instead see that the build script is using code for Windows targets. The expected target from my understanding of the triple is
unknown
inwasm32-unknown-unknown
.cargo +nightly build --lib --release --target wasm32-unknown-unknown -vv
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: