-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Emit used rustc invocation in the save-analysis file #54356
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
One thing I was wondering was the current directory - should we include it in the save-analysis for the invocation or maybe we can assume that everything is relative to the directory of the save analysis file itself and just hope for the user to set it properly using |
Including crate_name from session options might not be a good idea, since it can be inferred and we include it in the |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
As discussed, I removed the extra info, such as This now includes the associated output file for the compilation (e.g. However, I forgot that to make save-analysis data able to refer to each other, that's exactly why crate disambiguators were added to save-analysis in the first place - we can use this information to generate the dependency information, instead. @nrc do you think we should hold off including the |
pub fn filename_for_metadata(sess: &Session, | ||
crate_name: &str, | ||
outputs: &OutputFilenames) -> PathBuf { | ||
let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename); |
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.
Changed the formatting while moving to mimick filename_for_input
.filter(|(i, _)| !remap_arg_indices.contains(i)) | ||
.map(|(_, arg)| { | ||
match input { | ||
Input::File(ref path) if path == Path::new(&arg) => { |
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.
I decided to propagate Input
so that I can directly compare the argument to the non-mapped version (Input
seems to be the only place where we can get input file before it's remapped, apart from scanning the cmd) to replace it with the mapped version.
I was also thinking about trying to remap every argument and see if it matches the already remapped local_crate_source_file
but that seemed like it's considerably more mechanical work and more error-prone, so in the end I decided against it.
_ => path.to_string(), | ||
pub fn make_filename_string(&self, file: &SourceFile) -> String { | ||
match &file.name { | ||
FileName::Real(path) if !file.name_was_remapped => { |
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.
In practice every file that's going through SourceMap
will be remapped but here it seemed to be a missing case for not-yet-remapped absolute path so I included it for the sake of completeness.
@@ -218,15 +219,6 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool { | |||
false | |||
} | |||
|
|||
fn filename_for_metadata(sess: &Session, crate_name: &str, outputs: &OutputFilenames) -> PathBuf { |
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.
Moved it so I can only depend on librustc_codegen_utils
in the save analysis crate (see here)
@nrc hopefully this should be ready to review again (once rust-dev-tools/rls-data#19 lands). |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/Cargo.toml
Outdated
@@ -57,6 +57,7 @@ cargo = { path = "tools/cargo" } | |||
# that we're shipping as well (to ensure that the rustfmt in RLS and the | |||
# `rustfmt` executable are the same exact version). | |||
rustfmt-nightly = { path = "tools/rustfmt" } | |||
rls-data = { git = "https://github.com/Xanewok/rls-data", branch = "compilation-options" } |
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.
can use 0.18.1 now
I would include it some how, the less we rely on users 'doing the right thing', the better |
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.
r+ with the output stuff removed (unless it is needed).
@@ -110,6 +112,24 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { | |||
} | |||
} | |||
|
|||
// Returns path to the compilation output (e.g. libfoo-12345678.rmeta) | |||
pub fn compilation_output(&self, crate_name: &str) -> PathBuf { |
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.
I thought you said you were removing the output stuff? (Which seems like a good idea to me).
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 this doesn't use the file-based approach to figure out dependencies (crate disambiguators are used instead) but if we decide to somehow use save-analysis to lower this info further into low level file-based dep graph (potentially for Cargo build system integration? or maybe we shouldn't use save-analysis for that?) then we need some kind of related file input/output.
I removed CrateSource
because one-of-dylib-rlib-rmeta-is-some format is clunky to work with but left this for the reasons explained above. Should I remove this as well?
Edit: CompilationOptions::output
is now in rls-data 0.18.1 so we'd need to remove it from there as well.
@bors: r+ |
📌 Commit e5e0d8cfdc452c30b273ab716ac14c9f33fde359 has been approved by |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
This function isn't strictly tied to LLVM (it's more of a utility) and it's now near an analogous, almost identical `filename_for_input` (for rlibs and so forth). Also this means not depending on the backend when one wants to know the accurate .rmeta output filename.
This is `command`, `directory` and `output` file.
e5e0d8c
to
58a8621
Compare
@nrc rebased and hopefully works now. |
@bors: r+ |
📌 Commit 58a8621 has been approved by |
Emit used rustc invocation in the save-analysis file Blocked on rust-dev-tools/rls-data#19. (I'm guessing it won't pass CI due to an out-of-tree git dependency) This should allow RLS to recreate a Rust compilation build plan from the save-analysis files alone, which should be useful when fetching those from external build systems, most notably Buck now. Also this includes some more potentially useful compilation-specific options (e.g. sysroot or the actual path to extern crates) but that's not required for the build plan bits. cc @jsgf @alexcrichton r? @nrc
☀️ Test successful - status-appveyor, status-travis |
Tested on commit rust-lang/rust@80e6e3e. Direct link to PR: <rust-lang/rust#54356> 💔 rls on windows: test-pass → build-fail (cc @nrc, @rust-lang/infra). 💔 rls on linux: test-pass → build-fail (cc @nrc, @rust-lang/infra).
Fix RLS toolstate after #54356 merge Fixes toolstate regression caused by #54356. The `save::process_crate` now needs to be passed an additional `&Input`, this change contains the RLS equivalent of [this](https://github.com/rust-lang/rust/pull/54356/files#diff-707a0eda6b2f1a0537abc3d23133748cR983). r? @kennytm (or @nrc if you're not away yet)
Blocked on rust-dev-tools/rls-data#19. (I'm guessing it won't pass CI due to an out-of-tree git dependency)
This should allow RLS to recreate a Rust compilation build plan from the save-analysis files alone, which should be useful when fetching those from external build systems, most notably Buck now.
Also this includes some more potentially useful compilation-specific options (e.g. sysroot or the actual path to extern crates) but that's not required for the build plan bits.
cc @jsgf @alexcrichton
r? @nrc