rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.59k stars 100 forks source link

`rustflags = ["--cfg=web_sys_unstable_apis"]` in .cargo/config.toml not working #1486

Closed luxalpa closed 5 months ago

luxalpa commented 5 months ago

I'm trying to use web_sys. It works without cargo-clif. It also works if I set my environment variables to RUSTFLAGS=--cfg=web_sys_unstable_apis. But it doesn't seem to be able to pick it up from my .cargo/config.toml that's located in the project. I'm using Windows 11.

[build]
rustflags = ["--cfg=web_sys_unstable_apis", "-Z", "threads=8"]
bjorn3 commented 5 months ago

cargo-clif internally uses RUSTFLAGS to specify the codegen backend to use. This overrides build.rustflags. There is unfortunately no way that I know of to make cargo append rather than override it.

luxalpa commented 5 months ago

Does that mean that if I use the RUSTFLAGS environment variable workaround above, it will stop building with cranelift and use llvm instead?

If that is the case, does that mean that there is currently no way to use web-sys unstable apis together with cranelift (other than forking web-sys)?

bjorn3 commented 5 months ago

Does that mean that if I use the RUSTFLAGS environment variable workaround above, it will stop building with cranelift and use llvm instead?

cargo-clif does append to RUSTFLAGS rather than override it, so if you are using RUSTFLAGS, it will still use cranelift.

luxalpa commented 5 months ago

ah, now I understand what you're saying. Thanks! Should we close this issue?

bjorn3 commented 5 months ago

Yeah. For cargo-clif there isn't much I can do against it. And for the rustup distributed version choosing the cranelift backend is done in another way which doesn't suffer from this issue.