-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't canonicalize crate paths #139834
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
base: master
Are you sure you want to change the base?
Don't canonicalize crate paths #139834
Conversation
r? compiler |
Any test that can show us how the diagnostics get changed? |
I can add a run-make test. I'm finding it hard to do in a UI test. But before when running error[E0464]: multiple candidates for `rlib` dependency `resolver1` found
--> main.rs:1:1
|
1 | extern crate resolver1;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: candidate #1: \\?\F:\Temp\rust\crateresolver\libresolver1-1.rlib
= note: candidate #2: \\?\F:\Temp\rust\crateresolver\libresolver1-2.rlib
error: aborting due to 1 previous error After:
I think the latter is nicer. Another alternative would be to make paths absolute without resolving symlinks but I think it worth preserving relative paths if that's what the user gave us. If nothing else it's a bit more reproducible between machines. |
This PR modifies cc @jieyouxu |
cfb2ed1
to
2712731
Compare
Not too familiar with the specific part of the code base to review beyond that, I think.. r? compiler |
r? jieyouxu |
Note for myself: see if with this PR we can remove the extra normalization from Waffle's PR and not have tests explode (89b4eba) |
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.
Looks reasonable to me, r=me with the comments added.
@@ -432,7 +432,8 @@ impl<'a> CrateLocator<'a> { | |||
if seen_paths.contains(&path) { | |||
continue; | |||
}; | |||
seen_paths.insert(path.clone()); | |||
seen_paths.insert(path); | |||
let path = spf.path.to_path_buf(); |
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.
minor: Can you add comments here? I envision something like this:
{
// Use canonical path to check if we already processed it.
// Going through different symlinks does not change the result.
let path =
try_canonicalize(&spf.path).unwrap_or_else(|_| spf.path.to_path_buf());
if seen_paths.contains(&path) {
continue;
};
seen_paths.insert(path);
}
// Use the original path (potentially with unresolved symlinks),
// filesystem code should not care, but this is nicer for diagnostics.
let path = spf.path.to_path_buf();
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.
question: Does this also make the error not reproducible if case there are 2 symlinks? (i.e. you could go from either of them first, the second is ignored)
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's as deterministic as our Vec<SearchPath>
of library paths, so it should always pick the first library path passed in that resolves to the same directory. Changing the library order passed in would change the diagnostic. Though I don't think that's too different from other diagnostics that depend on the order of things passed in?
Aside: I am slightly uncertain if we need to use canonicalise at all. If two rlibs, for example, are byte-for-byte equal then we should treat them as not conflicting, whether that's due to being a symlink, hard link, copy or a deterministic rebuild. So skipping directories is just a potential performance optimisation. Though I don't know if it has that much impact in practice or if using same-file
(thus skipping potentially more expensive checks) would recover most performance loss, if any. I've not looked into it so didn't want to touch that here.
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.
Makes sense
@bors r=WaffleLapkin |
Don't canonicalize crate paths When printing paths in diagnostic we should favour printing the paths that were passed in rather than resolving all symlinks. This PR changes the form of the crate path but it should only really affect diagnostics as filesystem functions won't care which path is used. The uncanonicalized path was already used as a fallback for when canonicalization failed. This is a partial alternative to rust-lang#139823.
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#137454 (not lint break with label and unsafe block) - rust-lang#138934 (support config extensions) - rust-lang#139297 (Deduplicate & clean up Nix shell) - rust-lang#139834 (Don't canonicalize crate paths) - rust-lang#139868 (Move `pal::env` into `std::sys::env_consts`) - rust-lang#139978 (Add citool command for generating a test dashboard) - rust-lang#140000 (skip llvm-config in autodiff check builds, when its unavailable) - rust-lang#140007 (Disable has_thread_local on i686-win7-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
Don't canonicalize crate paths When printing paths in diagnostic we should favour printing the paths that were passed in rather than resolving all symlinks. This PR changes the form of the crate path but it should only really affect diagnostics as filesystem functions won't care which path is used. The uncanonicalized path was already used as a fallback for when canonicalization failed. This is a partial alternative to rust-lang#139823.
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#137454 (not lint break with label and unsafe block) - rust-lang#138934 (support config extensions) - rust-lang#139297 (Deduplicate & clean up Nix shell) - rust-lang#139834 (Don't canonicalize crate paths) - rust-lang#139978 (Add citool command for generating a test dashboard) - rust-lang#140000 (skip llvm-config in autodiff check builds, when its unavailable) - rust-lang#140007 (Disable has_thread_local on i686-win7-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#137454 (not lint break with label and unsafe block) - rust-lang#138934 (support config extensions) - rust-lang#139297 (Deduplicate & clean up Nix shell) - rust-lang#139834 (Don't canonicalize crate paths) - rust-lang#139978 (Add citool command for generating a test dashboard) - rust-lang#140000 (skip llvm-config in autodiff check builds, when its unavailable) - rust-lang#140007 (Disable has_thread_local on i686-win7-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#137454 (not lint break with label and unsafe block) - rust-lang#138934 (support config extensions) - rust-lang#139297 (Deduplicate & clean up Nix shell) - rust-lang#139834 (Don't canonicalize crate paths) - rust-lang#139978 (Add citool command for generating a test dashboard) - rust-lang#140000 (skip llvm-config in autodiff check builds, when its unavailable) - rust-lang#140007 (Disable has_thread_local on i686-win7-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
Don't canonicalize crate paths When printing paths in diagnostic we should favour printing the paths that were passed in rather than resolving all symlinks. This PR changes the form of the crate path but it should only really affect diagnostics as filesystem functions won't care which path is used. The uncanonicalized path was already used as a fallback for when canonicalization failed. This is a partial alternative to rust-lang#139823.
When printing paths in diagnostic we should favour printing the paths that were passed in rather than resolving all symlinks.
This PR changes the form of the crate path but it should only really affect diagnostics as filesystem functions won't care which path is used. The uncanonicalized path was already used as a fallback for when canonicalization failed.
This is a partial alternative to #139823.