-
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
Implement debuginfo path remapping #38348
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
(note that I'd like to discuss in tools triage tmw, but seems good to me) |
Yes, let's discuss it at the meeting. |
Seems like functionality we need. Thanks @sanxiyn! Can this be used to let us create seperate Is this unstable? Can it be tested? No test cases here. |
Can we get negative test cases too, for when this feature isn't supported? Does it e.g. work on windows? |
Separate debuginfo is a different problem. GDB has ways of handling this: https://www.sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html |
6a201be
to
d65e2f1
Compare
Here is a summary of what we discussed in the tools meeting:
A usability concerns that was raised:
Also, as @brson said, there should be an auto-test for this. A codegen test that checks the generated LLVM IR would probably work best. @sanxiyn Are you still up to this? |
Also, I wanted to note that we should be careful if the prefix includes more than just the root source directory. I am finding stuff like this (below) in debug info of a Rust binary. A naive matching of
and
|
Are those actually paths? They look like library names, which are typically more restricted. As I've noted in the issue, to actually be fool-proof here we need to allow each path to be a separate argument. |
Does this mean paths that contain The reason I ask is because we at the reproducible builds project are in the process of specifying the format of a standardised environment variable for this, that different compilers can all support, and we are trying to decide (e.g.) what to use as a separator characters. It would be good to get many different compiler writers' opinions on this. We also have the constraint that multiple mappings would have to be joined up into a single string, for this envvar. |
Yeah, looks like we forgot about Windows drive letters :( In today's Tools Team meeting we've discussed several options (none of which is particularly appealing):
A couple more that occurred to me later:
|
We should probably just avoid getting into the whole cross-platform shell/filename escaping business. I'd be for either going the json-file route or just allow an arbitrary number of |
That's a very good point. |
I still think it's fine just having one argument If this is still not convincing to the Rust team, then I suggest that instead of doing complex position-based logic, you define It would allow things like |
That's pretty much what I had in mind. |
A couple of points:
|
Yes, and this is the same behaviour as GCC. If one wanted This should be fine - if both At the Reproducible Builds project we have some interest in getting multiple build tools to adopt the same approach (roughly what's been described here, and what GCC does), and adding this complexity would likely hinder adoption. |
100% OK with matching gcc behaviour. I guess the user could include the '/' if they wanted to enforce matching directory boundaries. |
for (old, new) in sess.opts.debug_prefix_map.clone() { | ||
if path.starts_with(&old) { | ||
return new + &path[old.len()..]; | ||
} |
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.
It seems unnecessary to clone the whole map first; it would be better to iterate references, then only clone the "new" once we've found a match.
@@ -669,7 +678,10 @@ pub fn file_metadata(cx: &CrateContext, path: &str, full_path: &Option<String>) | |||
} | |||
}); | |||
|
|||
file_metadata_(cx, path, file_name, &work_dir) | |||
let sess = cx.sess(); | |||
let remap_file_name = remap_path(sess, file_name); |
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 ends up matching against a full path rather than the path passed on the command line. The let file_name
expression above ends up using the full_path
parameter if its present (which it always appears to be) rather than the relative path
(which it goes to some lengths to make relative to work_dir
). I'm not sure what the larger intent is here, but the effect is that this doesn't work as expected.
It looks like this was done deliberately in 24e7491 by @luser. This suggests that path remapping should be done in absolute space - though the code is pretty inconsistent. If full_path
is None
, then I think the resulting path will be relative.
@@ -253,6 +253,7 @@ top_level_options!( | |||
// Include the debug_assertions flag into dependency tracking, since it | |||
// can influence whether overflow checks are done or not. | |||
debug_assertions: bool [TRACKED], | |||
debug_prefix_map: Option<(String, String)> [TRACKED], |
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 only allows a single remapping. It needs to allow an arbitrary number of remappings to be useful.
I haven't been following this too closely, but was a conclusion of how to implement this reached? (just triaging some old PRs) |
@alexcrichton No, not yet, mostly due to my being busy with other things and not properly following up over at #38322. I have an idea what it could look like, I just need to write it up and confirm that it is what people except. |
triage: we discussed at tools team meeting @michaelwoerister has not had a chance to look at this yet, but still intends to, hopefully next week |
☔ The latest upstream changes (presumably #41237) made this pull request unmergeable. Please resolve the merge conflicts. |
Friendly ping-- there's some merge conflicts. Also have you had a chance to look at this @michaelwoerister ? Just want to keep this on your radar! |
That PR was just an initial attempt, but I believe @michaelwoerister had some more fleshed-out ideas later. We continued the discussion in #38322 and I'm waiting on his reply. In the meantime I submitted some patches to GCC that includes a change to make the mapping algorithm a bit more predictable, as described in #38322#273499873. |
This is literally the next thing on my TODO list. Expect a PR from me later this week. |
I posted an updated description of the approach I envision here: #38322 (comment) |
@michaelwoerister so is this pr still needed or is it going to be replaced with a different PR? |
Fix #38322.