-
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
Reconsider RUSTFLAGS artifact caching. #8716
Comments
My main pain point with RUSTFLAGS is xd009642/tarpaulin#416 (comment), which has some niche flags and wouldn't be helped much by this. AFAIK all of those flags are codegen/linking related though, and don't affect
Maybe there can be a way for I don't know enough about |
I believe this does because the filenames of object files show up as the codegen unit names in dwarf debug info (and probably PDB?). I suspect that everything else in the binary will be the same, but builds differing only in
I think this will work but I don't think it'll be too feasible if the default is to not hash RUSTFLAGS. The pain of rebuilding too much you only discover after-the-fact that you should have been hashing rustflags all along. I don't think we can hash-by-default though since it breaks the use cases you've mentioned.
I do think a Another possible solution could be adding a new variable like |
building static-linked runtimetest requires additional RUSTFLAGS env var. Unfortunately, the additional env var invalids the build cache, leading cargo rebuilding everytime. See rust-lang/cargo#8716 A temporary solution is to build runtimetest in a seperate `runtimetest-target` directory. Signed-off-by: Tony Duan <[email protected]>
building static-linked runtimetest requires additional RUSTFLAGS env var. Unfortunately, the additional env var invalids the build cache, leading cargo rebuilding everytime. See rust-lang/cargo#8716 A temporary solution is to build runtimetest in a seperate `runtimetest-target` directory. Signed-off-by: Tony Duan <[email protected]>
For some scenarios it is better to not set Rustflags for all crates in the dependency graph and instead only set it for the top-level crate. For example rust-lang/cargo#8716 can be avoided in some scenarios by setting the rustflags via rustc, which allows for faster rebuilds in such cases.
For some scenarios it is better to not set Rustflags for all crates in the dependency graph and instead only set it for the top-level crate. For example rust-lang/cargo#8716 can be avoided in some scenarios by setting the rustflags via rustc, which allows for faster rebuilds in such cases.
For some scenarios it is better to not set Rustflags for all crates in the dependency graph and instead only set it for the top-level crate. For example rust-lang/cargo#8716 can be avoided in some scenarios by setting the rustflags via rustc, which allows for faster rebuilds in such cases.
For some scenarios it is better to not set Rustflags for all crates in the dependency graph and instead only set it for the top-level crate. For example rust-lang/cargo#8716 can be avoided in some scenarios by setting the rustflags via rustc, which allows for faster rebuilds in such cases.
For some scenarios it is better to not set Rustflags for all crates in the dependency graph and instead only set it for the top-level crate. For example rust-lang/cargo#8716 can be avoided in some scenarios by setting the rustflags via rustc, which allows for faster rebuilds in such cases.
We've used a similar pattern in past projects. One thing that has changed is that we use `[target.'cfg(feature = "cargo-clippy")']` instead of `[build]`. This allows us to enforce this lint configuration locally and not just on CI. Using `rustflags` does mean that devs might encounter unexpected full rebuilds when switching between IDE and command line when using `cargo clippy`. This is a known issue[1]. For emacs, I just solved this by setting a different Cargo `target-directory` to the one used by default. A similar approach should work for other IDEs. [1]: rust-lang/cargo#8716.
We've used a similar pattern in past projects. One thing that has changed is that we use `[target.'cfg(feature = "cargo-clippy")']` instead of `[build]`. This allows us to enforce this lint configuration locally and not just on CI. Using `rustflags` does mean that devs might encounter unexpected full rebuilds when switching between IDE and command line when using `cargo clippy`. This is a known issue[1]. For emacs, I just solved this by setting a different Cargo `target-directory` to the one used by default. A similar approach should work for other IDEs. [1]: rust-lang/cargo#8716.
Since #6503, we've tests for cargo/tests/testsuite/rustflags.rs Lines 1481 to 1497 in 9c3c48f
@ehuss or @weihanglo any thoughts on another way of testing for |
…14826) ### What does this PR try to resolve? We have - `-C metadata` - `-C extra-filename` - Uniquifying build scripts - Uniquifying scraped documentation Currently, these are all the same value. For #8716, we might want to have `-C metadata` and `-C extra-filename` hash different parts of the `Unit`. I figured that this change helps to clarify intent so that even if we don't change the definitions, this could still be worth it. The last two I'm tracking as a `unit_id`. As we evolve the first two hashes, we can decide which would be a better fit for backing the `unit_id`. For scraping, I could have treated this as `-C extra-filename` but then we'd have a lot of `.expect()`s. I moved the accessors from `CompilationFiles` to `MetaInfo` so we could closely associate the documentation, API, and implementation. Making `CompilationFiles::c_metadata` the main entry point that gets documented would be weird because the hashing is associated with `MetaInfo` (umbrella type, was private, now `Metadata`) or `Metadata` (agnostic of each use, now `UnitHash`) ### How should we test and review this PR? ### Additional information
Terrible thought: run a regex on stderr to capture all |
…name This unblocks experimenting with having these diverge for rust-lang#8716
…name This unblocks experimenting with having these diverge for rust-lang#8716
…name This unblocks experimenting with having these diverge for rust-lang#8716
) ### What does this PR try to resolve? Fixes #8716 This splits `-C metdata` and `-C extra-filename` and adds `RUSTFLAGS` to `-C extra-filename` in the hope that we can still make PGO and reproducible builds work while caching artifacts per RUSTFLAGS used. ### How should we test and review this PR? ### Additional information
When RUSTFLAGS is changed between invocations, this can trigger a complete rebuild. This can be annoying, and the only workaround is to use a separate target directory for each RUSTFLAGS setting. I think we should revisit how this works, and see if there is a way to address the problems.
Motivation:
History:
--remap-path-prefix
from the hash, because it broke reproducible builds. 1.37 (2019-08-15)RUSTFLAGS
in-Cmetadata
#7417 Reverted Rustflags in metadata #6503 because it broke profile guided optimization. 1.39 (2019-11-07)Solutions?
I am uncertain what a good approach would be. Some rough ideas:
-C extra-filename
, and not-C metadata
. This should (probably) avoid the PGO problems, since the symbols won't change. However, this could still cause problems with reproducible builds if the rlib filename somehow leaks into the resulting binary (I don't have a reason to think it does, but it seems risky).The text was updated successfully, but these errors were encountered: