-
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
Open
ChrisDenton
wants to merge
2
commits into
rust-lang:master
Choose a base branch
from
ChrisDenton:spf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−6
Open
Don't canonicalize crate paths #139834
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
tests/run-make/crate-loading-multiple-candidates/crateresolve1-1.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#![crate_name = "crateresolve1"] | ||
#![crate_type = "lib"] | ||
|
||
pub fn f() -> isize { | ||
10 | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/run-make/crate-loading-multiple-candidates/crateresolve1-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#![crate_name = "crateresolve1"] | ||
#![crate_type = "lib"] | ||
|
||
pub fn f() -> isize { | ||
20 | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/run-make/crate-loading-multiple-candidates/multiple-candidates.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern crate crateresolve1; | ||
|
||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
tests/run-make/crate-loading-multiple-candidates/multiple-candidates.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found | ||
--> multiple-candidates.rs:1:1 | ||
| | ||
LL | extern crate crateresolve1; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: candidate #1: ./mylibs/libcrateresolve1-1.rlib | ||
= note: candidate #2: ./mylibs/libcrateresolve1-2.rlib | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0464`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//@ needs-symlink | ||
//@ ignore-cross-compile | ||
|
||
// Tests that the multiple candidate dependencies diagnostic prints relative | ||
// paths if a relative library path was passed in. | ||
|
||
use run_make_support::{bare_rustc, diff, rfs, rustc}; | ||
|
||
fn main() { | ||
// Check that relative paths are preserved in the diagnostic | ||
rfs::create_dir("mylibs"); | ||
rustc().input("crateresolve1-1.rs").out_dir("mylibs").extra_filename("-1").run(); | ||
rustc().input("crateresolve1-2.rs").out_dir("mylibs").extra_filename("-2").run(); | ||
check("./mylibs"); | ||
|
||
// Check that symlinks aren't followed when printing the diagnostic | ||
rfs::rename("mylibs", "original"); | ||
rfs::symlink_dir("original", "mylibs"); | ||
check("./mylibs"); | ||
} | ||
|
||
fn check(library_path: &str) { | ||
let out = rustc() | ||
.input("multiple-candidates.rs") | ||
.library_search_path(library_path) | ||
.ui_testing() | ||
.run_fail() | ||
.stderr_utf8(); | ||
diff() | ||
.expected_file("multiple-candidates.stderr") | ||
.normalize(r"\\", "/") | ||
.actual_text("(rustc)", &out) | ||
.run(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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