Remove support for -Zcombine-cgu
Nobody seems to actually use this, while still adding some extra complexity to the already rather complex codegen coordinator code. It is also not supported by any backend other than the LLVM backend.
This commit is contained in:
parent
fe2eeabe27
commit
948f7798d7
7 changed files with 6 additions and 91 deletions
|
|
@ -4,7 +4,6 @@ use gccjit::{Context, OutputKind};
|
|||
use rustc_codegen_ssa::back::link::ensure_removed;
|
||||
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
|
||||
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
||||
use rustc_errors::DiagCtxtHandle;
|
||||
use rustc_fs_util::link_or_copy;
|
||||
use rustc_session::config::OutputType;
|
||||
use rustc_span::fatal_error::FatalError;
|
||||
|
|
@ -258,14 +257,6 @@ pub(crate) fn codegen(
|
|||
))
|
||||
}
|
||||
|
||||
pub(crate) fn link(
|
||||
_cgcx: &CodegenContext<GccCodegenBackend>,
|
||||
_dcx: DiagCtxtHandle<'_>,
|
||||
mut _modules: Vec<ModuleCodegen<GccContext>>,
|
||||
) -> Result<ModuleCodegen<GccContext>, FatalError> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub(crate) fn save_temp_bitcode(
|
||||
cgcx: &CodegenContext<GccCodegenBackend>,
|
||||
_module: &ModuleCodegen<GccContext>,
|
||||
|
|
|
|||
|
|
@ -426,14 +426,6 @@ impl WriteBackendMethods for GccCodegenBackend {
|
|||
fn serialize_module(_module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn run_link(
|
||||
cgcx: &CodegenContext<Self>,
|
||||
dcx: DiagCtxtHandle<'_>,
|
||||
modules: Vec<ModuleCodegen<Self::Module>>,
|
||||
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
||||
back::write::link(cgcx, dcx, modules)
|
||||
}
|
||||
}
|
||||
|
||||
/// This is the entrypoint for a hot plugged rustc_codegen_gccjit
|
||||
|
|
|
|||
|
|
@ -796,29 +796,6 @@ pub(crate) fn optimize(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn link(
|
||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
dcx: DiagCtxtHandle<'_>,
|
||||
mut modules: Vec<ModuleCodegen<ModuleLlvm>>,
|
||||
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
|
||||
use super::lto::{Linker, ModuleBuffer};
|
||||
// Sort the modules by name to ensure deterministic behavior.
|
||||
modules.sort_by(|a, b| a.name.cmp(&b.name));
|
||||
let (first, elements) =
|
||||
modules.split_first().expect("Bug! modules must contain at least one module.");
|
||||
|
||||
let mut linker = Linker::new(first.module_llvm.llmod());
|
||||
for module in elements {
|
||||
let _timer = cgcx.prof.generic_activity_with_arg("LLVM_link_module", &*module.name);
|
||||
let buffer = ModuleBuffer::new(module.module_llvm.llmod());
|
||||
linker
|
||||
.add(buffer.data())
|
||||
.map_err(|()| llvm_err(dcx, LlvmError::SerializeModule { name: &module.name }))?;
|
||||
}
|
||||
drop(linker);
|
||||
Ok(modules.remove(0))
|
||||
}
|
||||
|
||||
pub(crate) fn codegen(
|
||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
module: ModuleCodegen<ModuleLlvm>,
|
||||
|
|
|
|||
|
|
@ -168,13 +168,6 @@ impl WriteBackendMethods for LlvmCodegenBackend {
|
|||
let stats = llvm::build_string(|s| unsafe { llvm::LLVMRustPrintStatistics(s) }).unwrap();
|
||||
print!("{stats}");
|
||||
}
|
||||
fn run_link(
|
||||
cgcx: &CodegenContext<Self>,
|
||||
dcx: DiagCtxtHandle<'_>,
|
||||
modules: Vec<ModuleCodegen<Self::Module>>,
|
||||
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
||||
back::write::link(cgcx, dcx, modules)
|
||||
}
|
||||
fn run_and_optimize_fat_lto(
|
||||
cgcx: &CodegenContext<Self>,
|
||||
exported_symbols_for_lto: &[String],
|
||||
|
|
|
|||
|
|
@ -797,10 +797,6 @@ pub(crate) enum WorkItemResult<B: WriteBackendMethods> {
|
|||
/// The backend has finished compiling a CGU, nothing more required.
|
||||
Finished(CompiledModule),
|
||||
|
||||
/// The backend has finished compiling a CGU, which now needs linking
|
||||
/// because `-Zcombine-cgu` was specified.
|
||||
NeedsLink(ModuleCodegen<B::Module>),
|
||||
|
||||
/// The backend has finished compiling a CGU, which now needs to go through
|
||||
/// fat LTO.
|
||||
NeedsFatLto(FatLtoInput<B>),
|
||||
|
|
@ -884,7 +880,10 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
|
|||
};
|
||||
|
||||
match lto_type {
|
||||
ComputedLtoType::No => finish_intra_module_work(cgcx, module, module_config),
|
||||
ComputedLtoType::No => {
|
||||
let module = B::codegen(cgcx, module, module_config)?;
|
||||
Ok(WorkItemResult::Finished(module))
|
||||
}
|
||||
ComputedLtoType::Thin => {
|
||||
let (name, thin_buffer) = B::prepare_thin(module, false);
|
||||
if let Some(path) = bitcode {
|
||||
|
|
@ -1024,20 +1023,8 @@ fn execute_thin_lto_work_item<B: ExtraBackendMethods>(
|
|||
module_config: &ModuleConfig,
|
||||
) -> Result<WorkItemResult<B>, FatalError> {
|
||||
let module = B::optimize_thin(cgcx, module)?;
|
||||
finish_intra_module_work(cgcx, module, module_config)
|
||||
}
|
||||
|
||||
fn finish_intra_module_work<B: ExtraBackendMethods>(
|
||||
cgcx: &CodegenContext<B>,
|
||||
module: ModuleCodegen<B::Module>,
|
||||
module_config: &ModuleConfig,
|
||||
) -> Result<WorkItemResult<B>, FatalError> {
|
||||
if !cgcx.opts.unstable_opts.combine_cgu || module.kind == ModuleKind::Allocator {
|
||||
let module = B::codegen(cgcx, module, module_config)?;
|
||||
Ok(WorkItemResult::Finished(module))
|
||||
} else {
|
||||
Ok(WorkItemResult::NeedsLink(module))
|
||||
}
|
||||
let module = B::codegen(cgcx, module, module_config)?;
|
||||
Ok(WorkItemResult::Finished(module))
|
||||
}
|
||||
|
||||
/// Messages sent to the coordinator.
|
||||
|
|
@ -1343,7 +1330,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
// through codegen and LLVM.
|
||||
let mut compiled_modules = vec![];
|
||||
let mut compiled_allocator_module = None;
|
||||
let mut needs_link = Vec::new();
|
||||
let mut needs_fat_lto = Vec::new();
|
||||
let mut needs_thin_lto = Vec::new();
|
||||
let mut lto_import_only_modules = Vec::new();
|
||||
|
|
@ -1625,7 +1611,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
Ok(WorkItemResult::Finished(compiled_module)) => {
|
||||
match compiled_module.kind {
|
||||
ModuleKind::Regular => {
|
||||
assert!(needs_link.is_empty());
|
||||
compiled_modules.push(compiled_module);
|
||||
}
|
||||
ModuleKind::Allocator => {
|
||||
|
|
@ -1634,10 +1619,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
}
|
||||
}
|
||||
}
|
||||
Ok(WorkItemResult::NeedsLink(module)) => {
|
||||
assert!(compiled_modules.is_empty());
|
||||
needs_link.push(module);
|
||||
}
|
||||
Ok(WorkItemResult::NeedsFatLto(fat_lto_input)) => {
|
||||
assert!(!started_lto);
|
||||
assert!(needs_thin_lto.is_empty());
|
||||
|
|
@ -1674,17 +1655,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
return Err(());
|
||||
}
|
||||
|
||||
let needs_link = mem::take(&mut needs_link);
|
||||
if !needs_link.is_empty() {
|
||||
assert!(compiled_modules.is_empty());
|
||||
let dcx = cgcx.create_dcx();
|
||||
let dcx = dcx.handle();
|
||||
let module = B::run_link(&cgcx, dcx, needs_link).map_err(|_| ())?;
|
||||
let module =
|
||||
B::codegen(&cgcx, module, cgcx.config(ModuleKind::Regular)).map_err(|_| ())?;
|
||||
compiled_modules.push(module);
|
||||
}
|
||||
|
||||
// Drop to print timings
|
||||
drop(llvm_start_time);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,6 @@ pub trait WriteBackendMethods: Clone + 'static {
|
|||
type ThinData: Send + Sync;
|
||||
type ThinBuffer: ThinBufferMethods;
|
||||
|
||||
/// Merge all modules into main_module and returning it
|
||||
fn run_link(
|
||||
cgcx: &CodegenContext<Self>,
|
||||
dcx: DiagCtxtHandle<'_>,
|
||||
modules: Vec<ModuleCodegen<Self::Module>>,
|
||||
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
|
||||
/// Performs fat LTO by merging all modules into a single one, running autodiff
|
||||
/// if necessary and running any further optimizations
|
||||
fn run_and_optimize_fat_lto(
|
||||
|
|
|
|||
|
|
@ -2168,8 +2168,6 @@ options! {
|
|||
"hash algorithm of source files used to check freshness in cargo (`blake3` or `sha256`)"),
|
||||
codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||
"the backend to use"),
|
||||
combine_cgu: bool = (false, parse_bool, [TRACKED],
|
||||
"combine CGUs into a single one"),
|
||||
contract_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"emit runtime checks for contract pre- and post-conditions (default: no)"),
|
||||
coverage_options: CoverageOptions = (CoverageOptions::default(), parse_coverage_options, [TRACKED],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue