-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Using build.rustflags is awkward right now #3052
Comments
"-C target-cpu=native" is a single argument (i.e. there’s no shell which does argument splitting for you), so what the target binary really receives is not Alas, you cannot do such splitting either, because that would preclude people from passing over stuff (i.e. filenames) with spaces in it. |
I dunno, I would expect that the command is simply concatenated together and passed to the shell, as that's less work (a huge priority of cargo's) and more flexible. You can pass files with spaces in them the same way as people have done for my entire life, by escaping the space with Either way I think we can agree that passing the flag twice is wrong. |
@CamJN did you happen to also have Also we can and should accept configuration like: [build]
rustflags = "-C target-cpu=native" 99% of the time splitting on spaces is all you want, and the list ( |
@alexcrichton nope, both RUSTFLAGS and CARGO_BUILD_RUSTFLAGS are unset. A repo which exhibits the behavior: https://github.com/CamJN/min
|
Weird! In any case I'm going to tag this as an easy bug as it should be pretty easy to knock out. There's basically a point where we call |
If the config with the |
Yup, that's the same issue. |
Implemented string lookup for `build.rustflags` config key This addresses the immediate issue described in #3052 . I am, however, unsure about the current state of the deeper issues mentioned in that issue, but if needed, I can take stab at them as well. :)
Is this still an issue? I can see that the PR #3356 has been merged |
Indeed! |
Based on #2535 and rust-lang/rust#23238 and rust-lang/rust#13841. I thought I could add
to my ~/.cargo/config file to pass that flag to my builds. But that breaks everything. Turns out I have to use
["-C", "target-cpu=native"]
which is weird but it works, so w/e. However when I runcargo build --verbose
I noticed that the-C target-cpu=native
flag gets passed to rustc twice in immediate succession. ie:rustc src/main.rs --crate-name min --crate-type bin -g --out-dir /Users/camdennarzt/Developer/Rust/min/target/debug --emit=dep-info,link -L dependency=/Users/camdennarzt/Developer/Rust/min/target/debug -L dependency=/Users/camdennarzt/Developer/Rust/min/target/debug/deps -C target-cpu=native -C target-cpu=native
rustc: 1.11.0
cargo: 0.11.0 (259324c 2016-05-20)
uname -a: Darwin SECUR-T.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
The text was updated successfully, but these errors were encountered: