1
Fork 0

Auto merge of #111345 - jyn514:cfg-release-caching, r=cjgillot,est31

Only depend on CFG_VERSION in rustc_interface

This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.

cc https://github.com/rust-lang/rust/issues/76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
This commit is contained in:
bors 2023-05-18 21:45:02 +00:00
commit c9dc55d05c
24 changed files with 97 additions and 71 deletions

View file

@ -245,6 +245,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,
@ -322,6 +323,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
@ -654,7 +656,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);
@ -1096,7 +1098,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();

View file

@ -2276,7 +2276,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.

View file

@ -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.