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

[target.'cfg(all(target_arch="x86_64", not(debug_assertions)))'] in .cargo/config doesn't seem to work #5777

Open
Boscop opened this issue Jul 23, 2018 · 5 comments
Labels
A-cfg-expr Area: Platform cfg expressions A-configuration Area: cargo config files and env vars A-target-dependencies Area: [target.'cfg(foo)'.dependencies] S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@Boscop
Copy link

Boscop commented Jul 23, 2018

I have this in my .cargo/config:

[target.'cfg(all(target_arch="x86_64", not(debug_assertions)))'] 
rustflags = ["-Ctarget-feature=+crt-static", "-Ctarget-cpu=haswell"]

But when I do a release build and check the .exe with Dependency Walker, it STILL linked dynamically to vcruntime140.dll, so the cfg doesn't seem to work, why?

Here, someone is using both of these cfg variables in a .cargo/config file, too..

EDIT: It also doesn't work when I do cargo build --release --target=x86_64-pc-windows-msvc

@alexcrichton
Copy link
Member

I believe this is a "bug" with the execution of rustc --print cfg unfortunately. When this is executed it's not passed opt-level flags, so it is always running with debug_assertions enabled (indicating that cfg is always enabled for resolution purposes)

@buybackoff
Copy link

buybackoff commented Jan 30, 2020

-Zconfig-profile unstable feature and TiKV script https://github.com/tikv/tikv/blob/master/scripts/run-cargo.sh are relevant.

@Boscop
Copy link
Author

Boscop commented Feb 9, 2020

@buybackoff So with -Zconfig-profile, can I specify rustflags per profile?

@Systemcluster
Copy link
Contributor

Systemcluster commented May 12, 2020

What's the workaround for this? Configurations inside [target.'cfg(debug_assertions)'] or variations thereof seem to be completely ignored in case of rustc --print cfg, and the cfg(debug_assertions) section is always applied even during release builds. The documentation only states Do not try to match on debug_assertions or Cargo features like feature="foo". with no additional info.

There is also no option of specifying rustflags in a [profile.] section (which was requested in #7878).

The use-case here is simple but I assume very common: Using different target-cpu, target-feature and strip flags for relase and debug builds.

@epage epage added the S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. label Oct 23, 2023
@ghtz08
Copy link

ghtz08 commented Oct 27, 2023

@buybackoff So with -Zconfig-profile, can I specify rustflags per profile?

cargo -Z profile-rustflags,on rustc 1.75.0-nightly (aa1a71e9e 2023-10-26)

@epage epage added the A-target-dependencies Area: [target.'cfg(foo)'.dependencies] label Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cfg-expr Area: Platform cfg expressions A-configuration Area: cargo config files and env vars A-target-dependencies Area: [target.'cfg(foo)'.dependencies] S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

7 participants