Exclude unnecessary info from CodegenResults
`foreign_module` and `wasm_import_module` are not needed for linking, and hence can be removed from CodegenResults.
This commit is contained in:
parent
969b42d8c0
commit
732afd41cf
@ -2,7 +2,7 @@ use rustc_data_structures::fx::FxHashSet;
|
|||||||
use rustc_data_structures::temp_dir::MaybeTempDir;
|
use rustc_data_structures::temp_dir::MaybeTempDir;
|
||||||
use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
||||||
use rustc_hir::def_id::CrateNum;
|
use rustc_hir::def_id::CrateNum;
|
||||||
use rustc_middle::middle::cstore::{EncodedMetadata, LibSource, NativeLib};
|
use rustc_middle::middle::cstore::{EncodedMetadata, LibSource};
|
||||||
use rustc_middle::middle::dependency_format::Linkage;
|
use rustc_middle::middle::dependency_format::Linkage;
|
||||||
use rustc_session::config::{self, CFGuard, CrateType, DebugInfo};
|
use rustc_session::config::{self, CFGuard, CrateType, DebugInfo};
|
||||||
use rustc_session::config::{OutputFilenames, OutputType, PrintRequest, SanitizerSet};
|
use rustc_session::config::{OutputFilenames, OutputType, PrintRequest, SanitizerSet};
|
||||||
@ -22,7 +22,8 @@ use super::command::Command;
|
|||||||
use super::linker::{self, Linker};
|
use super::linker::{self, Linker};
|
||||||
use super::rpath::{self, RPathConfig};
|
use super::rpath::{self, RPathConfig};
|
||||||
use crate::{
|
use crate::{
|
||||||
looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo, METADATA_FILENAME,
|
looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo, NativeLib,
|
||||||
|
METADATA_FILENAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cc::windows_registry;
|
use cc::windows_registry;
|
||||||
|
@ -766,7 +766,7 @@ impl CrateInfo {
|
|||||||
profiler_runtime: None,
|
profiler_runtime: None,
|
||||||
is_no_builtins: Default::default(),
|
is_no_builtins: Default::default(),
|
||||||
native_libraries: Default::default(),
|
native_libraries: Default::default(),
|
||||||
used_libraries: tcx.native_libraries(LOCAL_CRATE),
|
used_libraries: tcx.native_libraries(LOCAL_CRATE).iter().map(Into::into).collect(),
|
||||||
link_args: tcx.link_args(LOCAL_CRATE),
|
link_args: tcx.link_args(LOCAL_CRATE),
|
||||||
crate_name: Default::default(),
|
crate_name: Default::default(),
|
||||||
used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic),
|
used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic),
|
||||||
@ -787,7 +787,8 @@ impl CrateInfo {
|
|||||||
info.missing_lang_items.reserve(n_crates);
|
info.missing_lang_items.reserve(n_crates);
|
||||||
|
|
||||||
for &cnum in crates.iter() {
|
for &cnum in crates.iter() {
|
||||||
info.native_libraries.insert(cnum, tcx.native_libraries(cnum));
|
info.native_libraries
|
||||||
|
.insert(cnum, tcx.native_libraries(cnum).iter().map(Into::into).collect());
|
||||||
info.crate_name.insert(cnum, tcx.crate_name(cnum).to_string());
|
info.crate_name.insert(cnum, tcx.crate_name(cnum).to_string());
|
||||||
info.used_crate_source.insert(cnum, tcx.used_crate_source(cnum));
|
info.used_crate_source.insert(cnum, tcx.used_crate_source(cnum));
|
||||||
if tcx.is_panic_runtime(cnum) {
|
if tcx.is_panic_runtime(cnum) {
|
||||||
|
@ -21,15 +21,17 @@ extern crate tracing;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
|
|
||||||
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_hir::def_id::CrateNum;
|
use rustc_hir::def_id::CrateNum;
|
||||||
use rustc_hir::LangItem;
|
use rustc_hir::LangItem;
|
||||||
use rustc_middle::dep_graph::WorkProduct;
|
use rustc_middle::dep_graph::WorkProduct;
|
||||||
use rustc_middle::middle::cstore::{CrateSource, LibSource, NativeLib};
|
use rustc_middle::middle::cstore::{self, CrateSource, LibSource};
|
||||||
use rustc_middle::middle::dependency_format::Dependencies;
|
use rustc_middle::middle::dependency_format::Dependencies;
|
||||||
use rustc_middle::ty::query::Providers;
|
use rustc_middle::ty::query::Providers;
|
||||||
use rustc_session::config::{OutputFilenames, OutputType, RUST_CGU_EXT};
|
use rustc_session::config::{OutputFilenames, OutputType, RUST_CGU_EXT};
|
||||||
|
use rustc_session::utils::NativeLibKind;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
@ -105,6 +107,19 @@ bitflags::bitflags! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Encodable, Decodable, HashStable)]
|
||||||
|
pub struct NativeLib {
|
||||||
|
pub kind: NativeLibKind,
|
||||||
|
pub name: Option<Symbol>,
|
||||||
|
pub cfg: Option<ast::MetaItem>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&cstore::NativeLib> for NativeLib {
|
||||||
|
fn from(lib: &cstore::NativeLib) -> Self {
|
||||||
|
NativeLib { kind: lib.kind.clone(), name: lib.name.clone(), cfg: lib.cfg.clone() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Misc info we load from metadata to persist beyond the tcx.
|
/// Misc info we load from metadata to persist beyond the tcx.
|
||||||
///
|
///
|
||||||
/// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo`
|
/// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo`
|
||||||
@ -119,9 +134,9 @@ pub struct CrateInfo {
|
|||||||
pub compiler_builtins: Option<CrateNum>,
|
pub compiler_builtins: Option<CrateNum>,
|
||||||
pub profiler_runtime: Option<CrateNum>,
|
pub profiler_runtime: Option<CrateNum>,
|
||||||
pub is_no_builtins: FxHashSet<CrateNum>,
|
pub is_no_builtins: FxHashSet<CrateNum>,
|
||||||
pub native_libraries: FxHashMap<CrateNum, Lrc<Vec<NativeLib>>>,
|
pub native_libraries: FxHashMap<CrateNum, Vec<NativeLib>>,
|
||||||
pub crate_name: FxHashMap<CrateNum, String>,
|
pub crate_name: FxHashMap<CrateNum, String>,
|
||||||
pub used_libraries: Lrc<Vec<NativeLib>>,
|
pub used_libraries: Vec<NativeLib>,
|
||||||
pub link_args: Lrc<Vec<String>>,
|
pub link_args: Lrc<Vec<String>>,
|
||||||
pub used_crate_source: FxHashMap<CrateNum, Lrc<CrateSource>>,
|
pub used_crate_source: FxHashMap<CrateNum, Lrc<CrateSource>>,
|
||||||
pub used_crates_static: Vec<(CrateNum, LibSource)>,
|
pub used_crates_static: Vec<(CrateNum, LibSource)>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user