Move LinkerInfo into CrateInfo
This commit is contained in:
parent
9a27044f42
commit
323a74779f
7 changed files with 12 additions and 16 deletions
|
@ -4,7 +4,6 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
|
||||
use rustc_codegen_ssa::back::linker::LinkerInfo;
|
||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
|
@ -296,8 +295,7 @@ pub(crate) fn run_aot(
|
|||
allocator_module,
|
||||
metadata_module,
|
||||
metadata,
|
||||
linker_info: LinkerInfo::new(tcx, crate::target_triple(tcx.sess).to_string()),
|
||||
crate_info: CrateInfo::new(tcx),
|
||||
crate_info: CrateInfo::new(tcx, crate::target_triple(tcx.sess).to_string()),
|
||||
},
|
||||
work_products,
|
||||
))
|
||||
|
|
|
@ -178,7 +178,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
|
|||
|
||||
let mut dylib_paths = Vec::new();
|
||||
|
||||
let crate_info = CrateInfo::new(tcx);
|
||||
let crate_info = CrateInfo::new(tcx, "dummy_target_cpu".to_string());
|
||||
let formats = tcx.dependency_formats(());
|
||||
let data = &formats
|
||||
.iter()
|
||||
|
|
|
@ -1804,7 +1804,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
|
||||
// to the linker args construction.
|
||||
assert!(base_cmd.get_args().is_empty() || sess.target.vendor == "uwp");
|
||||
let cmd = &mut *codegen_results.linker_info.to_linker(base_cmd, &sess, flavor);
|
||||
let cmd = &mut *codegen_results.crate_info.linker_info.to_linker(base_cmd, &sess, flavor);
|
||||
let link_output_kind = link_output_kind(sess, crate_type);
|
||||
|
||||
// ------------ Early order-dependent options ------------
|
||||
|
@ -1986,10 +1986,10 @@ fn add_order_independent_options(
|
|||
if flavor == LinkerFlavor::PtxLinker {
|
||||
// Provide the linker with fallback to internal `target-cpu`.
|
||||
cmd.arg("--fallback-arch");
|
||||
cmd.arg(&codegen_results.linker_info.target_cpu);
|
||||
cmd.arg(&codegen_results.crate_info.linker_info.target_cpu);
|
||||
} else if flavor == LinkerFlavor::BpfLinker {
|
||||
cmd.arg("--cpu");
|
||||
cmd.arg(&codegen_results.linker_info.target_cpu);
|
||||
cmd.arg(&codegen_results.crate_info.linker_info.target_cpu);
|
||||
cmd.arg("--cpu-features");
|
||||
cmd.arg(match &sess.opts.cg.target_feature {
|
||||
feat if !feat.is_empty() => feat,
|
||||
|
|
|
@ -35,7 +35,7 @@ pub fn disable_localization(linker: &mut Command) {
|
|||
|
||||
/// For all the linkers we support, and information they might
|
||||
/// need out of the shared crate context before we get rid of it.
|
||||
#[derive(Encodable, Decodable)]
|
||||
#[derive(Debug, Encodable, Decodable)]
|
||||
pub struct LinkerInfo {
|
||||
pub(super) target_cpu: String,
|
||||
exports: FxHashMap<CrateType, Vec<String>>,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use super::link::{self, ensure_removed};
|
||||
use super::linker::LinkerInfo;
|
||||
use super::lto::{self, SerializedModule};
|
||||
use super::symbol_export::symbol_name_for_instance_in_crate;
|
||||
|
||||
|
@ -430,8 +429,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
|
|||
let no_builtins = tcx.sess.contains_name(crate_attrs, sym::no_builtins);
|
||||
let is_compiler_builtins = tcx.sess.contains_name(crate_attrs, sym::compiler_builtins);
|
||||
|
||||
let linker_info = LinkerInfo::new(tcx, target_cpu);
|
||||
let crate_info = CrateInfo::new(tcx);
|
||||
let crate_info = CrateInfo::new(tcx, target_cpu);
|
||||
|
||||
let regular_config =
|
||||
ModuleConfig::new(ModuleKind::Regular, sess, no_builtins, is_compiler_builtins);
|
||||
|
@ -461,7 +459,6 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
|
|||
OngoingCodegen {
|
||||
backend,
|
||||
metadata,
|
||||
linker_info,
|
||||
crate_info,
|
||||
|
||||
coordinator_send,
|
||||
|
@ -1799,7 +1796,6 @@ impl SharedEmitterMain {
|
|||
pub struct OngoingCodegen<B: ExtraBackendMethods> {
|
||||
pub backend: B,
|
||||
pub metadata: EncodedMetadata,
|
||||
pub linker_info: LinkerInfo,
|
||||
pub crate_info: CrateInfo,
|
||||
pub coordinator_send: Sender<Box<dyn Any + Send>>,
|
||||
pub codegen_worker_receive: Receiver<Message<B>>,
|
||||
|
@ -1842,7 +1838,6 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
|||
(
|
||||
CodegenResults {
|
||||
metadata: self.metadata,
|
||||
linker_info: self.linker_info,
|
||||
crate_info: self.crate_info,
|
||||
|
||||
modules: compiled_modules.modules,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::back::linker::LinkerInfo;
|
||||
use crate::back::write::{
|
||||
compute_per_cgu_lto_type, start_async_codegen, submit_codegened_module_to_llvm,
|
||||
submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm, ComputedLtoType, OngoingCodegen,
|
||||
|
@ -754,7 +755,8 @@ impl<B: ExtraBackendMethods> Drop for AbortCodegenOnDrop<B> {
|
|||
}
|
||||
|
||||
impl CrateInfo {
|
||||
pub fn new(tcx: TyCtxt<'_>) -> CrateInfo {
|
||||
pub fn new(tcx: TyCtxt<'_>, target_cpu: String) -> CrateInfo {
|
||||
let linker_info = LinkerInfo::new(tcx, target_cpu);
|
||||
let local_crate_name = tcx.crate_name(LOCAL_CRATE);
|
||||
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
|
||||
let subsystem = tcx.sess.first_attr_value_str_by_name(crate_attrs, sym::windows_subsystem);
|
||||
|
@ -770,6 +772,7 @@ impl CrateInfo {
|
|||
});
|
||||
|
||||
let mut info = CrateInfo {
|
||||
linker_info,
|
||||
local_crate_name,
|
||||
panic_runtime: None,
|
||||
compiler_builtins: None,
|
||||
|
|
|
@ -135,6 +135,7 @@ impl From<&cstore::NativeLib> for NativeLib {
|
|||
/// and the corresponding properties without referencing information outside of a `CrateInfo`.
|
||||
#[derive(Debug, Encodable, Decodable)]
|
||||
pub struct CrateInfo {
|
||||
pub linker_info: back::linker::LinkerInfo,
|
||||
pub local_crate_name: Symbol,
|
||||
pub panic_runtime: Option<CrateNum>,
|
||||
pub compiler_builtins: Option<CrateNum>,
|
||||
|
@ -157,7 +158,6 @@ pub struct CodegenResults {
|
|||
pub allocator_module: Option<CompiledModule>,
|
||||
pub metadata_module: Option<CompiledModule>,
|
||||
pub metadata: rustc_middle::middle::cstore::EncodedMetadata,
|
||||
pub linker_info: back::linker::LinkerInfo,
|
||||
pub crate_info: CrateInfo,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue