Merge pull request #852 from rust-lang/sync_from_rust_2026_02_13
Sync from rust 2026/02/13
This commit is contained in:
commit
70ae207ff5
5 changed files with 31 additions and 22 deletions
|
|
@ -1,3 +1,3 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2026-02-13"
|
channel = "nightly-2026-02-14"
|
||||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, SharedEmitter}
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
|
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
|
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||||
use rustc_errors::{DiagCtxt, DiagCtxtHandle};
|
use rustc_errors::{DiagCtxt, DiagCtxtHandle};
|
||||||
use rustc_log::tracing::info;
|
use rustc_log::tracing::info;
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
|
|
@ -112,6 +113,7 @@ fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> {
|
||||||
/// for further optimization.
|
/// for further optimization.
|
||||||
pub(crate) fn run_fat(
|
pub(crate) fn run_fat(
|
||||||
cgcx: &CodegenContext,
|
cgcx: &CodegenContext,
|
||||||
|
prof: &SelfProfilerRef,
|
||||||
shared_emitter: &SharedEmitter,
|
shared_emitter: &SharedEmitter,
|
||||||
each_linked_rlib_for_lto: &[PathBuf],
|
each_linked_rlib_for_lto: &[PathBuf],
|
||||||
modules: Vec<FatLtoInput<GccCodegenBackend>>,
|
modules: Vec<FatLtoInput<GccCodegenBackend>>,
|
||||||
|
|
@ -123,6 +125,7 @@ pub(crate) fn run_fat(
|
||||||
lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
|
lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
|
||||||
fat_lto(
|
fat_lto(
|
||||||
cgcx,
|
cgcx,
|
||||||
|
prof,
|
||||||
dcx,
|
dcx,
|
||||||
modules,
|
modules,
|
||||||
lto_data.upstream_modules,
|
lto_data.upstream_modules,
|
||||||
|
|
@ -133,13 +136,14 @@ pub(crate) fn run_fat(
|
||||||
|
|
||||||
fn fat_lto(
|
fn fat_lto(
|
||||||
cgcx: &CodegenContext,
|
cgcx: &CodegenContext,
|
||||||
|
prof: &SelfProfilerRef,
|
||||||
_dcx: DiagCtxtHandle<'_>,
|
_dcx: DiagCtxtHandle<'_>,
|
||||||
modules: Vec<FatLtoInput<GccCodegenBackend>>,
|
modules: Vec<FatLtoInput<GccCodegenBackend>>,
|
||||||
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
|
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
|
||||||
tmp_path: TempDir,
|
tmp_path: TempDir,
|
||||||
//symbols_below_threshold: &[String],
|
//symbols_below_threshold: &[String],
|
||||||
) -> ModuleCodegen<GccContext> {
|
) -> ModuleCodegen<GccContext> {
|
||||||
let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module");
|
let _timer = prof.generic_activity("GCC_fat_lto_build_monolithic_module");
|
||||||
info!("going for a fat lto");
|
info!("going for a fat lto");
|
||||||
|
|
||||||
// Sort out all our lists of incoming modules into two lists.
|
// Sort out all our lists of incoming modules into two lists.
|
||||||
|
|
@ -223,8 +227,7 @@ fn fat_lto(
|
||||||
// We add the object files and save in should_combine_object_files that we should combine
|
// We add the object files and save in should_combine_object_files that we should combine
|
||||||
// them into a single object file when compiling later.
|
// them into a single object file when compiling later.
|
||||||
for (bc_decoded, name) in serialized_modules {
|
for (bc_decoded, name) in serialized_modules {
|
||||||
let _timer = cgcx
|
let _timer = prof
|
||||||
.prof
|
|
||||||
.generic_activity_with_arg_recorder("GCC_fat_lto_link_module", |recorder| {
|
.generic_activity_with_arg_recorder("GCC_fat_lto_link_module", |recorder| {
|
||||||
recorder.record_arg(format!("{:?}", name))
|
recorder.record_arg(format!("{:?}", name))
|
||||||
});
|
});
|
||||||
|
|
@ -284,6 +287,7 @@ impl ModuleBufferMethods for ModuleBuffer {
|
||||||
/// can simply be copied over from the incr. comp. cache.
|
/// can simply be copied over from the incr. comp. cache.
|
||||||
pub(crate) fn run_thin(
|
pub(crate) fn run_thin(
|
||||||
cgcx: &CodegenContext,
|
cgcx: &CodegenContext,
|
||||||
|
prof: &SelfProfilerRef,
|
||||||
dcx: DiagCtxtHandle<'_>,
|
dcx: DiagCtxtHandle<'_>,
|
||||||
each_linked_rlib_for_lto: &[PathBuf],
|
each_linked_rlib_for_lto: &[PathBuf],
|
||||||
modules: Vec<(String, ThinBuffer)>,
|
modules: Vec<(String, ThinBuffer)>,
|
||||||
|
|
@ -298,6 +302,7 @@ pub(crate) fn run_thin(
|
||||||
}
|
}
|
||||||
thin_lto(
|
thin_lto(
|
||||||
cgcx,
|
cgcx,
|
||||||
|
prof,
|
||||||
dcx,
|
dcx,
|
||||||
modules,
|
modules,
|
||||||
lto_data.upstream_modules,
|
lto_data.upstream_modules,
|
||||||
|
|
@ -345,7 +350,8 @@ pub(crate) fn prepare_thin(module: ModuleCodegen<GccContext>) -> (String, ThinBu
|
||||||
/// all of the `LtoModuleCodegen` units returned below and destroyed once
|
/// all of the `LtoModuleCodegen` units returned below and destroyed once
|
||||||
/// they all go out of scope.
|
/// they all go out of scope.
|
||||||
fn thin_lto(
|
fn thin_lto(
|
||||||
cgcx: &CodegenContext,
|
_cgcx: &CodegenContext,
|
||||||
|
prof: &SelfProfilerRef,
|
||||||
_dcx: DiagCtxtHandle<'_>,
|
_dcx: DiagCtxtHandle<'_>,
|
||||||
modules: Vec<(String, ThinBuffer)>,
|
modules: Vec<(String, ThinBuffer)>,
|
||||||
serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
|
serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
|
||||||
|
|
@ -353,7 +359,7 @@ fn thin_lto(
|
||||||
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
|
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
|
||||||
//_symbols_below_threshold: &[String],
|
//_symbols_below_threshold: &[String],
|
||||||
) -> (Vec<ThinModule<GccCodegenBackend>>, Vec<WorkProduct>) {
|
) -> (Vec<ThinModule<GccCodegenBackend>>, Vec<WorkProduct>) {
|
||||||
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_global_analysis");
|
let _timer = prof.generic_activity("LLVM_thin_lto_global_analysis");
|
||||||
info!("going for that thin, thin LTO");
|
info!("going for that thin, thin LTO");
|
||||||
|
|
||||||
/*let green_modules: FxHashMap<_, _> =
|
/*let green_modules: FxHashMap<_, _> =
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use rustc_codegen_ssa::back::write::{
|
||||||
BitcodeSection, CodegenContext, EmitObj, ModuleConfig, SharedEmitter,
|
BitcodeSection, CodegenContext, EmitObj, ModuleConfig, SharedEmitter,
|
||||||
};
|
};
|
||||||
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
||||||
|
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||||
use rustc_errors::DiagCtxt;
|
use rustc_errors::DiagCtxt;
|
||||||
use rustc_fs_util::link_or_copy;
|
use rustc_fs_util::link_or_copy;
|
||||||
use rustc_log::tracing::debug;
|
use rustc_log::tracing::debug;
|
||||||
|
|
@ -18,6 +19,7 @@ use crate::{GccContext, LtoMode};
|
||||||
|
|
||||||
pub(crate) fn codegen(
|
pub(crate) fn codegen(
|
||||||
cgcx: &CodegenContext,
|
cgcx: &CodegenContext,
|
||||||
|
prof: &SelfProfilerRef,
|
||||||
shared_emitter: &SharedEmitter,
|
shared_emitter: &SharedEmitter,
|
||||||
module: ModuleCodegen<GccContext>,
|
module: ModuleCodegen<GccContext>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
|
|
@ -25,7 +27,7 @@ pub(crate) fn codegen(
|
||||||
let dcx = DiagCtxt::new(Box::new(shared_emitter.clone()));
|
let dcx = DiagCtxt::new(Box::new(shared_emitter.clone()));
|
||||||
let dcx = dcx.handle();
|
let dcx = dcx.handle();
|
||||||
|
|
||||||
let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
|
let _timer = prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
|
||||||
{
|
{
|
||||||
let context = &module.module_llvm.context;
|
let context = &module.module_llvm.context;
|
||||||
|
|
||||||
|
|
@ -44,9 +46,8 @@ pub(crate) fn codegen(
|
||||||
);
|
);
|
||||||
|
|
||||||
if config.bitcode_needed() {
|
if config.bitcode_needed() {
|
||||||
let _timer = cgcx
|
let _timer =
|
||||||
.prof
|
prof.generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name);
|
||||||
.generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name);
|
|
||||||
|
|
||||||
// TODO(antoyo)
|
// TODO(antoyo)
|
||||||
/*if let Some(bitcode_filename) = bc_out.file_name() {
|
/*if let Some(bitcode_filename) = bc_out.file_name() {
|
||||||
|
|
@ -58,8 +59,7 @@ pub(crate) fn codegen(
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
|
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
|
||||||
let _timer = cgcx
|
let _timer = prof
|
||||||
.prof
|
|
||||||
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
|
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
|
||||||
if lto_supported {
|
if lto_supported {
|
||||||
context.add_command_line_option("-flto=auto");
|
context.add_command_line_option("-flto=auto");
|
||||||
|
|
@ -70,8 +70,7 @@ pub(crate) fn codegen(
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
|
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
|
||||||
let _timer = cgcx
|
let _timer = prof
|
||||||
.prof
|
|
||||||
.generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name);
|
.generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name);
|
||||||
if lto_supported {
|
if lto_supported {
|
||||||
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
|
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
|
||||||
|
|
@ -98,7 +97,7 @@ pub(crate) fn codegen(
|
||||||
|
|
||||||
if config.emit_asm {
|
if config.emit_asm {
|
||||||
let _timer =
|
let _timer =
|
||||||
cgcx.prof.generic_activity_with_arg("GCC_module_codegen_emit_asm", &*module.name);
|
prof.generic_activity_with_arg("GCC_module_codegen_emit_asm", &*module.name);
|
||||||
let path = cgcx.output_filenames.temp_path_for_cgu(
|
let path = cgcx.output_filenames.temp_path_for_cgu(
|
||||||
OutputType::Assembly,
|
OutputType::Assembly,
|
||||||
&module.name,
|
&module.name,
|
||||||
|
|
@ -109,9 +108,8 @@ pub(crate) fn codegen(
|
||||||
|
|
||||||
match config.emit_obj {
|
match config.emit_obj {
|
||||||
EmitObj::ObjectCode(_) => {
|
EmitObj::ObjectCode(_) => {
|
||||||
let _timer = cgcx
|
let _timer =
|
||||||
.prof
|
prof.generic_activity_with_arg("GCC_module_codegen_emit_obj", &*module.name);
|
||||||
.generic_activity_with_arg("GCC_module_codegen_emit_obj", &*module.name);
|
|
||||||
if env::var("CG_GCCJIT_DUMP_MODULE_NAMES").as_deref() == Ok("1") {
|
if env::var("CG_GCCJIT_DUMP_MODULE_NAMES").as_deref() == Ok("1") {
|
||||||
println!("Module {}", module.name);
|
println!("Module {}", module.name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
||||||
///
|
///
|
||||||
/// If there’s a value with the same name already declared, the function will
|
/// If there’s a value with the same name already declared, the function will
|
||||||
/// update the declaration and return existing Value instead.
|
/// update the declaration and return existing Value instead.
|
||||||
#[expect(clippy::let_and_return)]
|
|
||||||
fn declare_raw_fn<'gcc>(
|
fn declare_raw_fn<'gcc>(
|
||||||
cx: &CodegenCx<'gcc, '_>,
|
cx: &CodegenCx<'gcc, '_>,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
|
|
||||||
12
src/lib.rs
12
src/lib.rs
|
|
@ -90,6 +90,7 @@ use rustc_codegen_ssa::target_features::cfg_target_feature;
|
||||||
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, WriteBackendMethods};
|
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, WriteBackendMethods};
|
||||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig};
|
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig};
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
|
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||||
use rustc_data_structures::sync::IntoDynSyncSend;
|
use rustc_data_structures::sync::IntoDynSyncSend;
|
||||||
use rustc_errors::DiagCtxtHandle;
|
use rustc_errors::DiagCtxtHandle;
|
||||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||||
|
|
@ -429,6 +430,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
|
|
||||||
fn run_and_optimize_fat_lto(
|
fn run_and_optimize_fat_lto(
|
||||||
cgcx: &CodegenContext,
|
cgcx: &CodegenContext,
|
||||||
|
prof: &SelfProfilerRef,
|
||||||
shared_emitter: &SharedEmitter,
|
shared_emitter: &SharedEmitter,
|
||||||
_tm_factory: TargetMachineFactoryFn<Self>,
|
_tm_factory: TargetMachineFactoryFn<Self>,
|
||||||
// FIXME(bjorn3): Limit LTO exports to these symbols
|
// FIXME(bjorn3): Limit LTO exports to these symbols
|
||||||
|
|
@ -436,11 +438,12 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
each_linked_rlib_for_lto: &[PathBuf],
|
each_linked_rlib_for_lto: &[PathBuf],
|
||||||
modules: Vec<FatLtoInput<Self>>,
|
modules: Vec<FatLtoInput<Self>>,
|
||||||
) -> ModuleCodegen<Self::Module> {
|
) -> ModuleCodegen<Self::Module> {
|
||||||
back::lto::run_fat(cgcx, shared_emitter, each_linked_rlib_for_lto, modules)
|
back::lto::run_fat(cgcx, prof, shared_emitter, each_linked_rlib_for_lto, modules)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_thin_lto(
|
fn run_thin_lto(
|
||||||
cgcx: &CodegenContext,
|
cgcx: &CodegenContext,
|
||||||
|
prof: &SelfProfilerRef,
|
||||||
dcx: DiagCtxtHandle<'_>,
|
dcx: DiagCtxtHandle<'_>,
|
||||||
// FIXME(bjorn3): Limit LTO exports to these symbols
|
// FIXME(bjorn3): Limit LTO exports to these symbols
|
||||||
_exported_symbols_for_lto: &[String],
|
_exported_symbols_for_lto: &[String],
|
||||||
|
|
@ -448,7 +451,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
modules: Vec<(String, Self::ThinBuffer)>,
|
modules: Vec<(String, Self::ThinBuffer)>,
|
||||||
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
|
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
|
||||||
) -> (Vec<ThinModule<Self>>, Vec<WorkProduct>) {
|
) -> (Vec<ThinModule<Self>>, Vec<WorkProduct>) {
|
||||||
back::lto::run_thin(cgcx, dcx, each_linked_rlib_for_lto, modules, cached_modules)
|
back::lto::run_thin(cgcx, prof, dcx, each_linked_rlib_for_lto, modules, cached_modules)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_pass_timings(&self) {
|
fn print_pass_timings(&self) {
|
||||||
|
|
@ -461,6 +464,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
|
|
||||||
fn optimize(
|
fn optimize(
|
||||||
_cgcx: &CodegenContext,
|
_cgcx: &CodegenContext,
|
||||||
|
_prof: &SelfProfilerRef,
|
||||||
_shared_emitter: &SharedEmitter,
|
_shared_emitter: &SharedEmitter,
|
||||||
module: &mut ModuleCodegen<Self::Module>,
|
module: &mut ModuleCodegen<Self::Module>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
|
|
@ -470,6 +474,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
|
|
||||||
fn optimize_thin(
|
fn optimize_thin(
|
||||||
cgcx: &CodegenContext,
|
cgcx: &CodegenContext,
|
||||||
|
_prof: &SelfProfilerRef,
|
||||||
_shared_emitter: &SharedEmitter,
|
_shared_emitter: &SharedEmitter,
|
||||||
_tm_factory: TargetMachineFactoryFn<Self>,
|
_tm_factory: TargetMachineFactoryFn<Self>,
|
||||||
thin: ThinModule<Self>,
|
thin: ThinModule<Self>,
|
||||||
|
|
@ -479,11 +484,12 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
|
|
||||||
fn codegen(
|
fn codegen(
|
||||||
cgcx: &CodegenContext,
|
cgcx: &CodegenContext,
|
||||||
|
prof: &SelfProfilerRef,
|
||||||
shared_emitter: &SharedEmitter,
|
shared_emitter: &SharedEmitter,
|
||||||
module: ModuleCodegen<Self::Module>,
|
module: ModuleCodegen<Self::Module>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
) -> CompiledModule {
|
) -> CompiledModule {
|
||||||
back::write::codegen(cgcx, shared_emitter, module, config)
|
back::write::codegen(cgcx, prof, shared_emitter, module, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
|
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue