Rollup merge of #134251 - bjorn3:various_cleanups2, r=oli-obk
A bunch of cleanups (part 2) Just like https://github.com/rust-lang/rust/pull/133567 these were all found while looking at the respective code, but are not blocking any other changes I want to make in the short term.
This commit is contained in:
commit
87bbbcd1bb
18 changed files with 43 additions and 71 deletions
|
@ -11,7 +11,6 @@ bitflags = "2.4.1"
|
|||
cc = "1.1.23"
|
||||
either = "1.5.0"
|
||||
itertools = "0.12"
|
||||
jobserver = "0.1.28"
|
||||
pathdiff = "0.2.0"
|
||||
regex = "1.4"
|
||||
rustc_abi = { path = "../rustc_abi" }
|
||||
|
|
|
@ -236,7 +236,13 @@ pub fn each_linked_rlib(
|
|||
) -> Result<(), errors::LinkRlibError> {
|
||||
let crates = info.used_crates.iter();
|
||||
|
||||
let fmts = if crate_type.is_none() {
|
||||
let fmts = if let Some(crate_type) = crate_type {
|
||||
let Some(fmts) = info.dependency_formats.get(&crate_type) else {
|
||||
return Err(errors::LinkRlibError::MissingFormat);
|
||||
};
|
||||
|
||||
fmts
|
||||
} else {
|
||||
for combination in info.dependency_formats.iter().combinations(2) {
|
||||
let (ty1, list1) = &combination[0];
|
||||
let (ty2, list2) = &combination[1];
|
||||
|
@ -252,18 +258,7 @@ pub fn each_linked_rlib(
|
|||
if info.dependency_formats.is_empty() {
|
||||
return Err(errors::LinkRlibError::MissingFormat);
|
||||
}
|
||||
&info.dependency_formats[0].1
|
||||
} else {
|
||||
let fmts = info
|
||||
.dependency_formats
|
||||
.iter()
|
||||
.find_map(|&(ty, ref list)| if Some(ty) == crate_type { Some(list) } else { None });
|
||||
|
||||
let Some(fmts) = fmts else {
|
||||
return Err(errors::LinkRlibError::MissingFormat);
|
||||
};
|
||||
|
||||
fmts
|
||||
info.dependency_formats.first().unwrap().1
|
||||
};
|
||||
|
||||
for &cnum in crates {
|
||||
|
@ -624,8 +619,7 @@ fn link_staticlib(
|
|||
let fmts = codegen_results
|
||||
.crate_info
|
||||
.dependency_formats
|
||||
.iter()
|
||||
.find_map(|&(ty, ref list)| if ty == CrateType::Staticlib { Some(list) } else { None })
|
||||
.get(&CrateType::Staticlib)
|
||||
.expect("no dependency formats for staticlib");
|
||||
|
||||
let mut all_rust_dylibs = vec![];
|
||||
|
@ -2355,11 +2349,10 @@ fn linker_with_args(
|
|||
// they are used within inlined functions or instantiated generic functions. We do this *after*
|
||||
// handling the raw-dylib symbols in the current crate to make sure that those are chosen first
|
||||
// by the linker.
|
||||
let (_, dependency_linkage) = codegen_results
|
||||
let dependency_linkage = codegen_results
|
||||
.crate_info
|
||||
.dependency_formats
|
||||
.iter()
|
||||
.find(|(ty, _)| *ty == crate_type)
|
||||
.get(&crate_type)
|
||||
.expect("failed to find crate type in dependency format list");
|
||||
|
||||
// We sort the libraries below
|
||||
|
@ -2738,11 +2731,10 @@ fn add_upstream_rust_crates(
|
|||
// Linking to a rlib involves just passing it to the linker (the linker
|
||||
// will slurp up the object files inside), and linking to a dynamic library
|
||||
// involves just passing the right -l flag.
|
||||
let (_, data) = codegen_results
|
||||
let data = codegen_results
|
||||
.crate_info
|
||||
.dependency_formats
|
||||
.iter()
|
||||
.find(|(ty, _)| *ty == crate_type)
|
||||
.get(&crate_type)
|
||||
.expect("failed to find crate type in dependency format list");
|
||||
|
||||
if sess.target.is_like_aix {
|
||||
|
|
|
@ -1749,7 +1749,7 @@ fn for_each_exported_symbols_include_dep<'tcx>(
|
|||
}
|
||||
|
||||
let formats = tcx.dependency_formats(());
|
||||
let deps = formats.iter().find_map(|(t, list)| (*t == crate_type).then_some(list)).unwrap();
|
||||
let deps = &formats[&crate_type];
|
||||
|
||||
for (index, dep_format) in deps.iter().enumerate() {
|
||||
let cnum = CrateNum::new(index + 1);
|
||||
|
|
|
@ -6,9 +6,9 @@ use std::sync::Arc;
|
|||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::{fs, io, mem, str, thread};
|
||||
|
||||
use jobserver::{Acquired, Client};
|
||||
use rustc_ast::attr;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||
use rustc_data_structures::jobserver::{self, Acquired};
|
||||
use rustc_data_structures::memmap::Mmap;
|
||||
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
|
||||
use rustc_errors::emitter::Emitter;
|
||||
|
@ -456,7 +456,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
|
|||
metadata_module: Option<CompiledModule>,
|
||||
) -> OngoingCodegen<B> {
|
||||
let (coordinator_send, coordinator_receive) = channel();
|
||||
let sess = tcx.sess;
|
||||
|
||||
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
|
||||
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
|
||||
|
@ -477,7 +476,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
|
|||
shared_emitter,
|
||||
codegen_worker_send,
|
||||
coordinator_receive,
|
||||
sess.jobserver.clone(),
|
||||
Arc::new(regular_config),
|
||||
Arc::new(metadata_config),
|
||||
Arc::new(allocator_config),
|
||||
|
@ -1093,7 +1091,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
shared_emitter: SharedEmitter,
|
||||
codegen_worker_send: Sender<CguMessage>,
|
||||
coordinator_receive: Receiver<Box<dyn Any + Send>>,
|
||||
jobserver: Client,
|
||||
regular_config: Arc<ModuleConfig>,
|
||||
metadata_config: Arc<ModuleConfig>,
|
||||
allocator_config: Arc<ModuleConfig>,
|
||||
|
@ -1145,7 +1142,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
// get tokens on `coordinator_receive` which will
|
||||
// get managed in the main loop below.
|
||||
let coordinator_send2 = coordinator_send.clone();
|
||||
let helper = jobserver
|
||||
let helper = jobserver::client()
|
||||
.into_helper_thread(move |token| {
|
||||
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue