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

rustc_flags applied only to top-level crate #235

Closed
cassiersg opened this issue May 31, 2022 · 2 comments
Closed

rustc_flags applied only to top-level crate #235

cassiersg opened this issue May 31, 2022 · 2 comments

Comments

@cassiersg
Copy link
Contributor

When rustc_flags are given to RustExtension, these flags are used only to build to top-level crate, and not the dependencies (at least for cdylib builds). This is due to using cargo rustc as build command, instead of using cargo build while setting the RUSTFLAGS environment variable (see https://doc.rust-lang.org/cargo/commands/cargo-rustc.html).

Is this behavior a bug ? If not, would you welcome a PR for an additional flag that would be applied to all crates built ?

As an example, my use-case is the flag -C target-feature=+avx2, which has to be applied to the dependencies.

@davidhewitt
Copy link
Member

Hi, sorry for the slow reply. I agree this is a bug, a PR would be very welcome!

@davidhewitt
Copy link
Member

I had a further thought about this and decided that it's possible there are valid use cases for rustc_flags, so I decided against changing them.

In #260 I documented this behavior and suggest using RUSTFLAGS as above. If an environment variable is inconvenient you can always have a .cargo/config file to set flags.

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

No branches or pull requests

2 participants