Skip to content
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

rustc: Ignore fs::canonicalize errors in metadata #74915

Merged
merged 1 commit into from
Jul 30, 2020

Conversation

alexcrichton
Copy link
Member

This commit updates the metadata location logic to ignore errors when
calling fs::canonicalize. Canonicalization was added historically so
multiple -L paths to the same directory don't print errors about
multiple candidates (since rustc can deduplicate same-named paths), but
canonicalization doesn't work on all filesystems. Cargo, for example,
always uses this sort of fallback where it will opportunitistically try
to canonicalize but fall back to using the input path if it otherwise
doesn't work.

If rustc is run on a filesystem that doesn't support canonicalization
then the effect of this change will be that -L paths which logically
point to the same directory will cause errors, but that's a rare enough
occurrence it shouldn't cause much issue in practice. Otherwise rustc
doesn't work at all today on those sorts of filesystem where
canonicalization isn't supported!

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 29, 2020
@Mark-Simulacrum
Copy link
Member

It looks like

let l = fs::canonicalize(l).ok();
and
Err(e) => panic!("failed to get realpath: {}", e),
might also need to be fixed for rustc itself to work well on canonicalize-unsupporting systems.

I didn't look at tools or bootstrap but those probably have more cases like this as well.

r=me if you don't want to fix those in this PR though!

This commit updates the metadata location logic to ignore errors when
calling `fs::canonicalize`. Canonicalization was added historically so
multiple `-L` paths to the same directory don't print errors about
multiple candidates (since rustc can deduplicate same-named paths), but
canonicalization doesn't work on all filesystems. Cargo, for example,
always uses this sort of fallback where it will opportunitistically try
to canonicalize but fall back to using the input path if it otherwise
doesn't work.

If rustc is run on a filesystem that doesn't support canonicalization
then the effect of this change will be that `-L` paths which logically
point to the same directory will cause errors, but that's a rare enough
occurrence it shouldn't cause much issue in practice. Otherwise rustc
doesn't work at all today on those sorts of filesystem where
canonicalization isn't supported!
@alexcrichton
Copy link
Member Author

Ah good catch! I've gone ahead and fixed those too.

@bors: r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Jul 30, 2020

📌 Commit cd8bdb5 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2020
@estebank
Copy link
Contributor

r? @Mark-Simulacrum

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 30, 2020
…arth

Rollup of 9 pull requests

Successful merges:

 - rust-lang#74751 (Clean up E0730 explanation)
 - rust-lang#74782 (Don't use "weak count" around Weak::from_raw_ptr)
 - rust-lang#74835 (Clean up E0734 explanation)
 - rust-lang#74871 (Enable docs on dist-x86_64-musl)
 - rust-lang#74905 (Avoid bool-like naming)
 - rust-lang#74907 (Clean up E0740 explanation)
 - rust-lang#74915 (rustc: Ignore fs::canonicalize errors in metadata)
 - rust-lang#74934 (Improve diagnostics when constant pattern is too generic)
 - rust-lang#74951 (Cherry-pick the release notes for 1.45.1)

Failed merges:

r? @ghost
@bors bors merged commit 0a45b13 into rust-lang:master Jul 30, 2020
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants