Only depend on CFG_VERSION in rustc_interface
this avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
This commit is contained in:
parent
0dddad0dc5
commit
d5f2b8e5c6
24 changed files with 97 additions and 71 deletions
|
@ -246,6 +246,7 @@ pub(crate) struct CrateLocator<'a> {
|
|||
only_needs_metadata: bool,
|
||||
sysroot: &'a Path,
|
||||
metadata_loader: &'a dyn MetadataLoader,
|
||||
cfg_version: &'static str,
|
||||
|
||||
// Immutable per-search configuration.
|
||||
crate_name: Symbol,
|
||||
|
@ -323,6 +324,7 @@ impl<'a> CrateLocator<'a> {
|
|||
only_needs_metadata,
|
||||
sysroot: &sess.sysroot,
|
||||
metadata_loader,
|
||||
cfg_version: sess.cfg_version,
|
||||
crate_name,
|
||||
exact_paths: if hash.is_none() {
|
||||
sess.opts
|
||||
|
@ -655,7 +657,7 @@ impl<'a> CrateLocator<'a> {
|
|||
}
|
||||
|
||||
fn crate_matches(&mut self, metadata: &MetadataBlob, libpath: &Path) -> Option<Svh> {
|
||||
let rustc_version = rustc_version();
|
||||
let rustc_version = rustc_version(self.cfg_version);
|
||||
let found_version = metadata.get_rustc_version();
|
||||
if found_version != rustc_version {
|
||||
info!("Rejecting via version: expected {} got {}", rustc_version, found_version);
|
||||
|
@ -1097,7 +1099,7 @@ impl CrateError {
|
|||
crate_name,
|
||||
add_info,
|
||||
found_crates,
|
||||
rustc_version: rustc_version(),
|
||||
rustc_version: rustc_version(sess.cfg_version),
|
||||
});
|
||||
} else if !locator.crate_rejections.via_invalid.is_empty() {
|
||||
let mut crate_rejections = Vec::new();
|
||||
|
|
|
@ -2267,7 +2267,7 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) {
|
|||
};
|
||||
|
||||
// Encode the rustc version string in a predictable location.
|
||||
rustc_version().encode(&mut ecx);
|
||||
rustc_version(tcx.sess.cfg_version).encode(&mut ecx);
|
||||
|
||||
// Encode all the entries and extra information in the crate,
|
||||
// culminating in the `CrateRoot` which points to all of it.
|
||||
|
|
|
@ -48,8 +48,8 @@ mod def_path_hash_map;
|
|||
mod encoder;
|
||||
mod table;
|
||||
|
||||
pub(crate) fn rustc_version() -> String {
|
||||
format!("rustc {}", option_env!("CFG_VERSION").unwrap_or("unknown version"))
|
||||
pub(crate) fn rustc_version(cfg_version: &'static str) -> String {
|
||||
format!("rustc {}", cfg_version)
|
||||
}
|
||||
|
||||
/// Metadata encoding version.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue