Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upApply RUSTFLAGS arguments to rustc builds #2241
Conversation
rust-highfive
assigned
huonw
Dec 22, 2015
This comment has been minimized.
This comment has been minimized.
rust-highfive
commented
Dec 22, 2015
|
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
rust-highfive
assigned
alexcrichton
and unassigned
huonw
Dec 22, 2015
This comment has been minimized.
This comment has been minimized.
|
Cargo may want to start tracking at a finer grain of why dependencies are being compiled the way they are. For example if a plugin has a dependency then the dependency will be compiled for the host architecture, but it'll have RUSTFLAGS applied to it even when the plugin doesn't. I would personally expect that the entire subgraphs of dependencies only used by plugins wouldn't get RUSTFLAGS treatment. Also, could this have a few acceptance tests as well? e.g. fails-to-compile unless RUSTFLAGS is parsed properly. |
This comment has been minimized.
This comment has been minimized.
|
I'll try to figure out how to propagate the plugin-ness to dependencies. re tests there is no error case in cargo's parsing of RUSTFLAGS. It only splits on space. Are there other tests you would like to see? |
This comment has been minimized.
This comment has been minimized.
|
I've got a patch that makes plugin deps not use RUSTFLAGS, but have discovered the build scripts have this same problem. |
This comment has been minimized.
This comment has been minimized.
|
It may actually be easier to just check That does mean that plugins and build scripts will get custom flags for a vanilla |
Zoxc
referenced this pull request
Jan 16, 2016
Closed
Passing target specific command line options to rustc #2284
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
referenced this pull request
Jan 25, 2016
Closed
Add a --sysroot option to build and rustc commands #2312
This comment has been minimized.
This comment has been minimized.
|
One other test I thought of recently to add is to ensure that changing |
alexcrichton
referenced this pull request
Feb 2, 2016
Merged
Add -C link-dead-code option (to improve kcov code coverage) #31368
brson
force-pushed the
brson:rustflags
branch
from
4b9c4a6
to
642ab17
Feb 17, 2016
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton I updated the patch to make the logic much simpler. What I've got is:
This doesn't seem to capture your "it would also apply to Kind::Host if host == target" suggestion, but still all my test cases pass. Can you think of a test case that requires your suggested rule? I'll look at the recompilation and parsing matters now. |
This comment has been minimized.
This comment has been minimized.
|
Looks good to me! The recompilation will probably come about by modifying this structure . |
brson
force-pushed the
brson:rustflags
branch
2 times, most recently
from
522db58
to
86acbc8
Feb 17, 2016
brson
added
the
relnotes
label
Feb 17, 2016
brson
force-pushed the
brson:rustflags
branch
from
86acbc8
to
1cc087d
Feb 17, 2016
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton I've added a patch to recompile when RUSTFLAGS changes. @Zoxc I'm not sure how to make RUSTFLAGS support spaces. I looked for precedent with CFLAGS and couldn't find it. Simple escaping with |
alexcrichton
reviewed
Feb 17, 2016
| @@ -342,6 +351,7 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) | |||
| deps: deps, | |||
| local: local, | |||
| memoized_hash: Mutex::new(None), | |||
| rustflags: env::var("RUSTFLAGS").ok(), | |||
This comment has been minimized.
This comment has been minimized.
alexcrichton
Feb 17, 2016
Member
Could this use the methods on the context instead? That way if you use RUSTFLAGS with --target you won't recompile any build scripts or plugins (as they're not affected by this env var anyway)
alexcrichton
reviewed
Feb 17, 2016
| @@ -421,6 +431,7 @@ pub fn prepare_build_cmd<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) | |||
| deps: Vec::new(), | |||
| local: local, | |||
| memoized_hash: Mutex::new(None), | |||
| rustflags: env::var("RUSTFLAGS").ok(), | |||
This comment has been minimized.
This comment has been minimized.
alexcrichton
Feb 17, 2016
Member
This is fine to leave as empty because running the build script itself (what this fingerprint is for) doesn't actually depend on RUSTFLAGS. Compilation of the build script should be covered by the fingerprint above I believe
This comment has been minimized.
This comment has been minimized.
|
Could you also add a test for if |
This comment has been minimized.
This comment has been minimized.
|
@brson Maybe Pascal style escaping with |
This comment has been minimized.
This comment has been minimized.
|
I recommend shell-like quoting (e.g. bash If no semantics attached to |
japaric
referenced this pull request
Feb 17, 2016
Closed
use cargo-sysroot instead of rust-libcore #2
This comment has been minimized.
This comment has been minimized.
|
|
japaric
referenced this pull request
Mar 4, 2016
Closed
[WIP] per profile sysroot via Cargo.toml #2436
brson
force-pushed the
brson:rustflags
branch
from
06bc455
to
aa29143
Mar 4, 2016
This comment has been minimized.
This comment has been minimized.
|
I've added another commit that also draws rustflags from the config file according to the following scheme:
All are lists, so argument lists with spaces work. None of these allow extra flags to be passed to build scripts and plugins when Edit: it's important to note that because the config options are lists, there aren't corresponding |
alexcrichton
reviewed
Mar 7, 2016
|
|
||
| // First try RUSTFLAGS from the environment | ||
| if let Some(a) = env::var("RUSTFLAGS").ok() { | ||
| let args = a.split(" ").map(str::trim).map(str::to_string); |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Mar 7, 2016
Member
This may want a filter_map for "not empty" for environment variables like " -l foo --sysroot bar"
alexcrichton
reviewed
Mar 7, 2016
| @@ -19,11 +19,11 @@ dependencies = [ | |||
| "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", | |||
| "libgit2-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | |||
| "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | |||
| "num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", | |||
| "regex 0.1.48 (registry+https://github.com/rust-lang/crates.io-index)", | |||
| "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", | |||
This comment has been minimized.
This comment has been minimized.
alexcrichton
Mar 7, 2016
Member
Out of curiosity, was this updated required to get the patch to land? Or was this just a routine updated?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Looks like some tests on travis are failing, but they probably just need a I'm curious what the difference between |
brson
added some commits
Feb 17, 2016
This comment has been minimized.
This comment has been minimized.
They are almost the same. The difference is that |
brson
force-pushed the
brson:rustflags
branch
from
aa29143
to
2f01868
Mar 16, 2016
This comment has been minimized.
This comment has been minimized.
|
I've removed the |
This comment has been minimized.
This comment has been minimized.
|
I did have to |
This comment has been minimized.
This comment has been minimized.
|
This was the build error
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 16, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors: retry force clean |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 17, 2016
This comment has been minimized.
This comment has been minimized.
|
|
brson commentedDec 22, 2015
Cargo will use RUSTFLAGS for building everything that is not a build script
or plugin. It does not apply to these targets because they may be for
a different platform that 'normal' builds.
Closes #2112