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::{Encoding, Format, LineEncoding, RunTimeEndian};
|
use gimli::{Encoding, Format, LineEncoding, RunTimeEndian};
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
|
use rustc_session::Session;
|
||||||
|
|
||||||
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
|
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
|
||||||
pub(crate) use self::unwind::UnwindContext;
|
pub(crate) use self::unwind::UnwindContext;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub(crate) fn producer() -> String {
|
pub(crate) fn producer(sess: &Session) -> String {
|
||||||
format!(
|
format!("rustc version {} with cranelift {}", sess.cfg_version, cranelift_codegen::VERSION)
|
||||||
"rustc version {} with cranelift {}",
|
|
||||||
rustc_interface::util::rustc_version_str().unwrap_or("unknown version"),
|
|
||||||
cranelift_codegen::VERSION,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct DebugContext {
|
pub(crate) struct DebugContext {
|
||||||
@ -67,7 +64,7 @@ pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa) -> Self {
|
|||||||
|
|
||||||
let should_remap_filepaths = tcx.sess.should_prefer_remapped_for_codegen();
|
let should_remap_filepaths = tcx.sess.should_prefer_remapped_for_codegen();
|
||||||
|
|
||||||
let producer = producer();
|
let producer = producer(tcx.sess);
|
||||||
let comp_dir = tcx
|
let comp_dir = tcx
|
||||||
.sess
|
.sess
|
||||||
.opts
|
.opts
|
||||||
|
@ -143,6 +143,7 @@ fn emit_cgu(
|
|||||||
debug: Option<DebugContext>,
|
debug: Option<DebugContext>,
|
||||||
unwind_context: UnwindContext,
|
unwind_context: UnwindContext,
|
||||||
global_asm_object_file: Option<PathBuf>,
|
global_asm_object_file: Option<PathBuf>,
|
||||||
|
producer: &str,
|
||||||
) -> Result<ModuleCodegenResult, String> {
|
) -> Result<ModuleCodegenResult, String> {
|
||||||
let mut product = module.finish();
|
let mut product = module.finish();
|
||||||
|
|
||||||
@ -152,8 +153,14 @@ fn emit_cgu(
|
|||||||
|
|
||||||
unwind_context.emit(&mut product);
|
unwind_context.emit(&mut product);
|
||||||
|
|
||||||
let module_regular =
|
let module_regular = emit_module(
|
||||||
emit_module(output_filenames, prof, product.object, ModuleKind::Regular, name.clone())?;
|
output_filenames,
|
||||||
|
prof,
|
||||||
|
product.object,
|
||||||
|
ModuleKind::Regular,
|
||||||
|
name.clone(),
|
||||||
|
producer,
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(ModuleCodegenResult {
|
Ok(ModuleCodegenResult {
|
||||||
module_regular,
|
module_regular,
|
||||||
@ -174,6 +181,7 @@ fn emit_module(
|
|||||||
mut object: cranelift_object::object::write::Object<'_>,
|
mut object: cranelift_object::object::write::Object<'_>,
|
||||||
kind: ModuleKind,
|
kind: ModuleKind,
|
||||||
name: String,
|
name: String,
|
||||||
|
producer_str: &str,
|
||||||
) -> Result<CompiledModule, String> {
|
) -> Result<CompiledModule, String> {
|
||||||
if object.format() == cranelift_object::object::BinaryFormat::Elf {
|
if object.format() == cranelift_object::object::BinaryFormat::Elf {
|
||||||
let comment_section = object.add_section(
|
let comment_section = object.add_section(
|
||||||
@ -182,7 +190,7 @@ fn emit_module(
|
|||||||
cranelift_object::object::SectionKind::OtherString,
|
cranelift_object::object::SectionKind::OtherString,
|
||||||
);
|
);
|
||||||
let mut producer = vec![0];
|
let mut producer = vec![0];
|
||||||
producer.extend(crate::debuginfo::producer().as_bytes());
|
producer.extend(producer_str.as_bytes());
|
||||||
producer.push(0);
|
producer.push(0);
|
||||||
object.set_section_data(comment_section, producer, 1);
|
object.set_section_data(comment_section, producer, 1);
|
||||||
}
|
}
|
||||||
@ -321,6 +329,8 @@ fn module_codegen(
|
|||||||
(cgu_name, cx, module, codegened_functions)
|
(cgu_name, cx, module, codegened_functions)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let producer = crate::debuginfo::producer(tcx.sess);
|
||||||
|
|
||||||
OngoingModuleCodegen::Async(std::thread::spawn(move || {
|
OngoingModuleCodegen::Async(std::thread::spawn(move || {
|
||||||
cx.profiler.clone().generic_activity_with_arg("compile functions", &*cgu_name).run(|| {
|
cx.profiler.clone().generic_activity_with_arg("compile functions", &*cgu_name).run(|| {
|
||||||
cranelift_codegen::timing::set_thread_profiler(Box::new(super::MeasuremeProfiler(
|
cranelift_codegen::timing::set_thread_profiler(Box::new(super::MeasuremeProfiler(
|
||||||
@ -348,6 +358,7 @@ fn module_codegen(
|
|||||||
cx.debug_context,
|
cx.debug_context,
|
||||||
cx.unwind_context,
|
cx.unwind_context,
|
||||||
global_asm_object_file,
|
global_asm_object_file,
|
||||||
|
&producer,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
std::mem::drop(token);
|
std::mem::drop(token);
|
||||||
@ -453,6 +464,7 @@ pub(crate) fn run_aot(
|
|||||||
product.object,
|
product.object,
|
||||||
ModuleKind::Allocator,
|
ModuleKind::Allocator,
|
||||||
"allocator_shim".to_owned(),
|
"allocator_shim".to_owned(),
|
||||||
|
&crate::debuginfo::producer(tcx.sess),
|
||||||
) {
|
) {
|
||||||
Ok(allocator_module) => Some(allocator_module),
|
Ok(allocator_module) => Some(allocator_module),
|
||||||
Err(err) => tcx.dcx().fatal(err),
|
Err(err) => tcx.dcx().fatal(err),
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
extern crate rustc_hir;
|
extern crate rustc_hir;
|
||||||
extern crate rustc_incremental;
|
extern crate rustc_incremental;
|
||||||
extern crate rustc_index;
|
extern crate rustc_index;
|
||||||
extern crate rustc_interface;
|
|
||||||
extern crate rustc_metadata;
|
extern crate rustc_metadata;
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
extern crate rustc_span;
|
extern crate rustc_span;
|
||||||
|
Loading…
Reference in New Issue
Block a user