-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Take commandline arguments into account for incr. comp. #35340
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
use syntax::feature_gate::UnstableFeatures; | ||
use syntax::parse::token::InternedString; | ||
|
||
pub trait DepTrackingHash { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some types, like DefPath
, it'd be nice to have access to a tcx
-- maybe add that as an argument? (of course they can get it through TLS too, but...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This trait wasn't really meant to be used for something other than commandline arguments. However, if we decide that we want to use it for the ICH, that would certainly be possible.
f7af64e
to
a61e3ff
Compare
cc @nrc regarding |
debuginfo: DebugInfoLevel [TRACKED], | ||
lint_opts: Vec<(String, lint::Level)> [TRACKED], | ||
lint_cap: Option<lint::Level> [TRACKED], | ||
describe_lints: bool [UNTRACKED], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ps I love this [UNTRACKED]
notation. Such a beautiful use of macros.
That said, this is a good example of the backwards compat sort of thing that macros are supposed to disallow. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, this is a good example of the backwards compat sort of thing that macros are supposed to disallow. ;)
To clarify: imagine if types were extended to support T[...]
; in that case, this would not parse anymore. Personally I think it's fine to leave it as is, but you could also add some separator token like ;
or ,
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it turns out that there's almost no common character allowed directly after a ty
production :)
;
and ,
probably would be allowed, but I think they are kind of misleading in this context. I'll just leave it the way it is. We can always change it easily if need be.
@jonas-schievink might also be interested in this |
($t:ty) => ( | ||
impl DepTrackingHash for Vec<$t> { | ||
fn hash(&self, hasher: &mut SipHasher, error_format: ErrorOutputType) { | ||
let mut elems = self.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man. I guess this is good but kind of sucks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I have a better idea =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ps seems mildly better to make a vector of indices and sort that:
let mut elems: Vec<_> = (0..self.len()).collect();
elems.sort_by(|i, j| self[i].cmp(&self[j]));
for (index, original_index) in elems.iter().enumerate() {
self[original_index].hash();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right :)
On the other hand, this code is executed exactly once for a tiny amount of data...
r=me modulo nits and resolving the questions that @alexcrichton raised =) |
I think all my points are resolved, I didn't realize that incrementality was only up to codegen and linking wasn't incremental. In that case I think this is good to go modulo taking native libraries into account which affect dllimport on MSVC |
It will hopefully be so at least for EDIT: And the MSVC linker can do that too, I think. |
@bors r=nikomatsakis I think I've addressed all the nits. |
📌 Commit 845e37b has been approved by |
Regarding |
☔ The latest upstream changes (presumably #34845) made this pull request unmergeable. Please resolve the merge conflicts. |
Commandline arguments influence whether incremental compilation can use its compilation cache and thus their changes relative to previous compilation sessions need to be taking into account. This commit makes sure that one has to specify for every commandline argument whether it influences incremental compilation or not.
.. and use it to purge the incremental compilation cache if necessary.
The 'cfg' in the Options struct is only the commandline-specified subset of the crate configuration and it's almost always wrong to read that instead of the CrateConfig in HIR crate node.
OK, I could reproduce the test failure after a rebase (I guess it contained a change that bors' merge already had too), and it seems that there's something wrong with either macros or extern crates: If the
Without the |
26fd699
to
67f19e5
Compare
@bors r=nikomatsakis |
📌 Commit 67f19e5 has been approved by |
…sakis Take commandline arguments into account for incr. comp. Implements the conservative strategy described in #33727. From now one, every time a new commandline option is added, one has to specify if it influences the incremental compilation cache. I've tried to implement this as automatic as possible: One just has to added either the `[TRACKED]` or the `[UNTRACKED]` marker next to the field. The `Options`, `CodegenOptions`, and `DebuggingOptions` definitions in `session::config` show plenty of examples. The PR removes some cruft from `session::config::Options`, mostly unnecessary copies of flags also present in `DebuggingOptions` or `CodeGenOptions` in the same struct. One notable removal is the `cfg` field that contained the values passed via `--cfg` commandline arguments. I chose to remove it because (1) its content is only a subset of what later is stored in `hir::Crate::config` and it's pretty likely that reading the cfgs from `Options` would not be what you wanted, and (2) we could not incorporate it into the dep-tracking hash of the `Options` struct because of how the test framework works, leaving us with a piece of untracked but vital data. It is now recommended (just as before) to access the crate config via the `krate()` method in the HIR map. Because the `cfg` field is not present in the `Options` struct any more, some methods in the `CompilerCalls` trait now take the crate config as an explicit parameter -- which might constitute a breaking change for plugin authors.
💔 Test failed - auto-linux-64-debug-opt |
@bors retry |
@bors retry This seems spurious ... |
@alexcrichton Can we increase the timeout? And/or add |
I've not been watching bors over the past week or so, can we open an issue about this? It would be good to have all information related to this in one issue (I don't know the context here) |
See #35628 for the timeout. |
⌛ Testing commit 67f19e5 with merge d6ae9eb... |
💔 Test failed - auto-linux-64-debug-opt |
@bors retry |
…sakis Take commandline arguments into account for incr. comp. Implements the conservative strategy described in #33727. From now one, every time a new commandline option is added, one has to specify if it influences the incremental compilation cache. I've tried to implement this as automatic as possible: One just has to added either the `[TRACKED]` or the `[UNTRACKED]` marker next to the field. The `Options`, `CodegenOptions`, and `DebuggingOptions` definitions in `session::config` show plenty of examples. The PR removes some cruft from `session::config::Options`, mostly unnecessary copies of flags also present in `DebuggingOptions` or `CodeGenOptions` in the same struct. One notable removal is the `cfg` field that contained the values passed via `--cfg` commandline arguments. I chose to remove it because (1) its content is only a subset of what later is stored in `hir::Crate::config` and it's pretty likely that reading the cfgs from `Options` would not be what you wanted, and (2) we could not incorporate it into the dep-tracking hash of the `Options` struct because of how the test framework works, leaving us with a piece of untracked but vital data. It is now recommended (just as before) to access the crate config via the `krate()` method in the HIR map. Because the `cfg` field is not present in the `Options` struct any more, some methods in the `CompilerCalls` trait now take the crate config as an explicit parameter -- which might constitute a breaking change for plugin authors.
Implements the conservative strategy described in #33727.
From now one, every time a new commandline option is added, one has to specify if it influences the incremental compilation cache. I've tried to implement this as automatic as possible: One just has to added either the
[TRACKED]
or the[UNTRACKED]
marker next to the field. TheOptions
,CodegenOptions
, andDebuggingOptions
definitions insession::config
show plenty of examples.The PR removes some cruft from
session::config::Options
, mostly unnecessary copies of flags also present inDebuggingOptions
orCodeGenOptions
in the same struct.One notable removal is the
cfg
field that contained the values passed via--cfg
commandline arguments. I chose to remove it because (1) its content is only a subset of what later is stored inhir::Crate::config
and it's pretty likely that reading the cfgs fromOptions
would not be what you wanted, and (2) we could not incorporate it into the dep-tracking hash of theOptions
struct because of how the test framework works, leaving us with a piece of untracked but vital data.It is now recommended (just as before) to access the crate config via the
krate()
method in the HIR map.Because the
cfg
field is not present in theOptions
struct any more, some methods in theCompilerCalls
trait now take the crate config as an explicit parameter -- which might constitute a breaking change for plugin authors.