mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
Use sess.cfg_version instead of rustc_version_str()
This makes it easier to patch cg_clif to be statically linked as part of rustc.
This commit is contained in:
parent
24361a1b99
commit
7d3b29399d
@ -13,17 +13,14 @@ use gimli::write::{
|
||||
};
|
||||
use gimli::{Encoding, Format, LineEncoding, RunTimeEndian};
|
||||
use indexmap::IndexSet;
|
||||
use rustc_session::Session;
|
||||
|
||||
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
|
||||
pub(crate) use self::unwind::UnwindContext;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub(crate) fn producer() -> String {
|
||||
format!(
|
||||
"rustc version {} with cranelift {}",
|
||||
rustc_interface::util::rustc_version_str().unwrap_or("unknown version"),
|
||||
cranelift_codegen::VERSION,
|
||||
)
|
||||
pub(crate) fn producer(sess: &Session) -> String {
|
||||
format!("rustc version {} with cranelift {}", sess.cfg_version, cranelift_codegen::VERSION)
|
||||
}
|
||||
|
||||
pub(crate) struct DebugContext {
|
||||
@ -67,7 +64,7 @@ impl DebugContext {
|
||||
|
||||
let should_remap_filepaths = tcx.sess.should_prefer_remapped_for_codegen();
|
||||
|
||||
let producer = producer();
|
||||
let producer = producer(tcx.sess);
|
||||
let comp_dir = tcx
|
||||
.sess
|
||||
.opts
|
||||
|
@ -143,6 +143,7 @@ fn emit_cgu(
|
||||
debug: Option<DebugContext>,
|
||||
unwind_context: UnwindContext,
|
||||
global_asm_object_file: Option<PathBuf>,
|
||||
producer: &str,
|
||||
) -> Result<ModuleCodegenResult, String> {
|
||||
let mut product = module.finish();
|
||||
|
||||
@ -152,8 +153,14 @@ fn emit_cgu(
|
||||
|
||||
unwind_context.emit(&mut product);
|
||||
|
||||
let module_regular =
|
||||
emit_module(output_filenames, prof, product.object, ModuleKind::Regular, name.clone())?;
|
||||
let module_regular = emit_module(
|
||||
output_filenames,
|
||||
prof,
|
||||
product.object,
|
||||
ModuleKind::Regular,
|
||||
name.clone(),
|
||||
producer,
|
||||
)?;
|
||||
|
||||
Ok(ModuleCodegenResult {
|
||||
module_regular,
|
||||
@ -174,6 +181,7 @@ fn emit_module(
|
||||
mut object: cranelift_object::object::write::Object<'_>,
|
||||
kind: ModuleKind,
|
||||
name: String,
|
||||
producer_str: &str,
|
||||
) -> Result<CompiledModule, String> {
|
||||
if object.format() == cranelift_object::object::BinaryFormat::Elf {
|
||||
let comment_section = object.add_section(
|
||||
@ -182,7 +190,7 @@ fn emit_module(
|
||||
cranelift_object::object::SectionKind::OtherString,
|
||||
);
|
||||
let mut producer = vec![0];
|
||||
producer.extend(crate::debuginfo::producer().as_bytes());
|
||||
producer.extend(producer_str.as_bytes());
|
||||
producer.push(0);
|
||||
object.set_section_data(comment_section, producer, 1);
|
||||
}
|
||||
@ -321,6 +329,8 @@ fn module_codegen(
|
||||
(cgu_name, cx, module, codegened_functions)
|
||||
});
|
||||
|
||||
let producer = crate::debuginfo::producer(tcx.sess);
|
||||
|
||||
OngoingModuleCodegen::Async(std::thread::spawn(move || {
|
||||
cx.profiler.clone().generic_activity_with_arg("compile functions", &*cgu_name).run(|| {
|
||||
cranelift_codegen::timing::set_thread_profiler(Box::new(super::MeasuremeProfiler(
|
||||
@ -348,6 +358,7 @@ fn module_codegen(
|
||||
cx.debug_context,
|
||||
cx.unwind_context,
|
||||
global_asm_object_file,
|
||||
&producer,
|
||||
)
|
||||
});
|
||||
std::mem::drop(token);
|
||||
@ -453,6 +464,7 @@ pub(crate) fn run_aot(
|
||||
product.object,
|
||||
ModuleKind::Allocator,
|
||||
"allocator_shim".to_owned(),
|
||||
&crate::debuginfo::producer(tcx.sess),
|
||||
) {
|
||||
Ok(allocator_module) => Some(allocator_module),
|
||||
Err(err) => tcx.dcx().fatal(err),
|
||||
|
@ -18,7 +18,6 @@ extern crate rustc_fs_util;
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_incremental;
|
||||
extern crate rustc_index;
|
||||
extern crate rustc_interface;
|
||||
extern crate rustc_metadata;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
|
Loading…
Reference in New Issue
Block a user