diff options
| author | jyn <github@jyn.dev> | 2023-05-08 04:12:38 -0500 |
|---|---|---|
| committer | jyn <github@jyn.dev> | 2023-05-17 23:54:21 -0500 |
| commit | d5f2b8e5c65b0406254b990296793f664c1926a0 (patch) | |
| tree | 7245f2f921a806ae8fc6dad29d543af26ab0f452 /compiler/rustc_codegen_ssa/src | |
| parent | 0dddad0dc5d614f799d7e04de4895e7a7418eccb (diff) | |
| download | rust-d5f2b8e5c65b0406254b990296793f664c1926a0.tar.gz rust-d5f2b8e5c65b0406254b990296793f664c1926a0.zip | |
Only depend on CFG_VERSION in rustc_interface
this avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/lib.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index c3cc17c255b..cdf50bdf1a4 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -36,6 +36,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT}; use rustc_session::cstore::{self, CrateSource}; use rustc_session::utils::NativeLibKind; +use rustc_session::Session; use rustc_span::symbol::Symbol; use rustc_span::DebuggerVisualizerFile; use std::collections::BTreeSet; @@ -175,11 +176,11 @@ pub struct CodegenResults { pub crate_info: CrateInfo, } -pub enum CodegenErrors<'a> { +pub enum CodegenErrors { WrongFileType, EmptyVersionNumber, EncodingVersionMismatch { version_array: String, rlink_version: u32 }, - RustcVersionMismatch { rustc_version: String, current_version: &'a str }, + RustcVersionMismatch { rustc_version: String }, } pub fn provide(providers: &mut Providers) { @@ -213,10 +214,9 @@ pub fn looks_like_rust_object_file(filename: &str) -> bool { const RLINK_VERSION: u32 = 1; const RLINK_MAGIC: &[u8] = b"rustlink"; -const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION"); - impl CodegenResults { pub fn serialize_rlink( + sess: &Session, rlink_file: &Path, codegen_results: &CodegenResults, ) -> Result<usize, io::Error> { @@ -225,12 +225,12 @@ impl CodegenResults { // `emit_raw_bytes` is used to make sure that the version representation does not depend on // Encoder's inner representation of `u32`. encoder.emit_raw_bytes(&RLINK_VERSION.to_be_bytes()); - encoder.emit_str(RUSTC_VERSION.unwrap()); + encoder.emit_str(sess.cfg_version); Encodable::encode(codegen_results, &mut encoder); encoder.finish() } - pub fn deserialize_rlink<'a>(data: Vec<u8>) -> Result<Self, CodegenErrors<'a>> { + pub fn deserialize_rlink(sess: &Session, data: Vec<u8>) -> Result<Self, CodegenErrors> { // The Decodable machinery is not used here because it panics if the input data is invalid // and because its internal representation may change. if !data.starts_with(RLINK_MAGIC) { @@ -252,11 +252,9 @@ impl CodegenResults { let mut decoder = MemDecoder::new(&data[4..], 0); let rustc_version = decoder.read_str(); - let current_version = RUSTC_VERSION.unwrap(); - if rustc_version != current_version { + if rustc_version != sess.cfg_version { return Err(CodegenErrors::RustcVersionMismatch { rustc_version: rustc_version.to_string(), - current_version, }); } |
