-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Crate loader cleanups #126099
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
Merged
Merged
Crate loader cleanups #126099
Changes from all commits
Commits
Show all changes
3 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 hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -222,7 +222,6 @@ use rustc_data_structures::owned_slice::slice_owned; | |
use rustc_data_structures::svh::Svh; | ||
use rustc_errors::{DiagArgValue, IntoDiagArg}; | ||
use rustc_fs_util::try_canonicalize; | ||
use rustc_session::config; | ||
use rustc_session::cstore::CrateSource; | ||
use rustc_session::filesearch::FileSearch; | ||
use rustc_session::search_paths::PathKind; | ||
|
@@ -309,7 +308,6 @@ impl<'a> CrateLocator<'a> { | |
is_rlib: bool, | ||
hash: Option<Svh>, | ||
extra_filename: Option<&'a str>, | ||
is_host: bool, | ||
path_kind: PathKind, | ||
) -> CrateLocator<'a> { | ||
let needs_object_code = sess.opts.output_types.should_codegen(); | ||
|
@@ -340,17 +338,9 @@ impl<'a> CrateLocator<'a> { | |
}, | ||
hash, | ||
extra_filename, | ||
target: if is_host { &sess.host } else { &sess.target }, | ||
triple: if is_host { | ||
TargetTriple::from_triple(config::host_triple()) | ||
} else { | ||
sess.opts.target_triple.clone() | ||
}, | ||
filesearch: if is_host { | ||
sess.host_filesearch(path_kind) | ||
} else { | ||
sess.target_filesearch(path_kind) | ||
}, | ||
target: &sess.target, | ||
triple: sess.opts.target_triple.clone(), | ||
filesearch: sess.target_filesearch(path_kind), | ||
is_proc_macro: false, | ||
crate_rejections: CrateRejections::default(), | ||
} | ||
|
@@ -424,12 +414,18 @@ impl<'a> CrateLocator<'a> { | |
debug!("testing {}", spf.path.display()); | ||
|
||
let f = &spf.file_name_str; | ||
let (hash, kind) = if f.starts_with(rlib_prefix) && f.ends_with(rlib_suffix) { | ||
(&f[rlib_prefix.len()..(f.len() - rlib_suffix.len())], CrateFlavor::Rlib) | ||
} else if f.starts_with(rmeta_prefix) && f.ends_with(rmeta_suffix) { | ||
(&f[rmeta_prefix.len()..(f.len() - rmeta_suffix.len())], CrateFlavor::Rmeta) | ||
} else if f.starts_with(dylib_prefix) && f.ends_with(dylib_suffix.as_ref()) { | ||
(&f[dylib_prefix.len()..(f.len() - dylib_suffix.len())], CrateFlavor::Dylib) | ||
let (hash, kind) = if let Some(f) = f.strip_prefix(rlib_prefix) | ||
&& let Some(f) = f.strip_suffix(rlib_suffix) | ||
{ | ||
Comment on lines
+417
to
+419
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is much easier to understand 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i really love rusts string manipulation methods |
||
(f, CrateFlavor::Rlib) | ||
} else if let Some(f) = f.strip_prefix(rmeta_prefix) | ||
&& let Some(f) = f.strip_suffix(rmeta_suffix) | ||
{ | ||
(f, CrateFlavor::Rmeta) | ||
} else if let Some(f) = f.strip_prefix(dylib_prefix) | ||
&& let Some(f) = f.strip_suffix(dylib_suffix.as_ref()) | ||
{ | ||
(f, CrateFlavor::Dylib) | ||
} else { | ||
if f.starts_with(staticlib_prefix) && f.ends_with(staticlib_suffix.as_ref()) { | ||
self.crate_rejections.via_kind.push(CrateMismatch { | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
I'm so confused. The callsite is always
false
and there was a casualis_host
branch here? Archaeology didn't reveal much for why this came to be, oh well.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.
But apparently this seems to work since 5 years ago when
is_host
was introduced, then I guess it must've worked because nobody complained about it 🤷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.
Only
true
usage in https://github.com/rust-lang/rust/pull/66496/filesso I think this is correct since we ripped out compiler plugin support some time ago.