Skip to content

Commit af787cc

Browse files
committed
Update to nightly-2025-07-28.
- `run_fat_lto`, `optimize_fat`, and `autodiff` were merged into `run_and_optimize_fat_lto`, and the parameters were changed. - `run_thin_lto` parameters were changed. - `codegen` parameters were changed. - `LtoModuleCodegen` was removed. The LTO changes occurred in rust-lang/rust PR 143388 and PR 144062.
1 parent f7c1ab1 commit af787cc

File tree

4 files changed

+21
-33
lines changed

4 files changed

+21
-33
lines changed

crates/rustc_codegen_spirv/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ use std::{env, fs, mem};
1818
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1919
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
2020
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
21-
channel = "nightly-2025-07-14"
21+
channel = "nightly-2025-07-28"
2222
components = ["rust-src", "rustc-dev", "llvm-tools"]
23-
# commit_hash = e9182f195b8505c87c4bd055b9f6e114ccda0981"#;
23+
# commit_hash = f8e355c230c6eb7b78ffce6a92fd81f78c890524"#;
2424

2525
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2626
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());

crates/rustc_codegen_spirv/src/lib.rs

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ mod target_feature;
141141

142142
use builder::Builder;
143143
use codegen_cx::CodegenCx;
144-
use maybe_pqp_cg_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
144+
use maybe_pqp_cg_ssa::back::lto::{SerializedModule, ThinModule};
145145
use maybe_pqp_cg_ssa::back::write::{
146146
CodegenContext, FatLtoInput, ModuleConfig, OngoingCodegen, TargetMachineFactoryConfig,
147147
};
@@ -170,7 +170,7 @@ use std::any::Any;
170170
use std::fs;
171171
use std::io::Cursor;
172172
use std::io::Write;
173-
use std::path::Path;
173+
use std::path::{Path, PathBuf};
174174
use std::sync::Arc;
175175
use tracing::{error, warn};
176176

@@ -333,7 +333,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
333333
type ThinBuffer = SpirvModuleBuffer;
334334

335335
// FIXME(eddyb) reuse the "merge" stage of `crate::linker` for this, or even
336-
// delegate to `run_fat_lto` (although `-Zcombine-cgu` is much more niche).
336+
// delegate to `run_and_optimize_fat_lto` (although `-Zcombine-cgu` is much more niche).
337337
fn run_link(
338338
cgcx: &CodegenContext<Self>,
339339
diag_handler: DiagCtxtHandle<'_>,
@@ -351,24 +351,29 @@ impl WriteBackendMethods for SpirvCodegenBackend {
351351
// consider setting `requires_lto = true` in the target specs and moving the
352352
// entirety of `crate::linker` into this stage (lacking diagnostics may be
353353
// an issue - it's surprising `CodegenBackend::link` has `Session` at all).
354-
fn run_fat_lto(
354+
fn run_and_optimize_fat_lto(
355355
cgcx: &CodegenContext<Self>,
356+
_exported_symbols_for_lto: &[String],
357+
_each_linked_rlib_for_lto: &[PathBuf],
356358
_modules: Vec<FatLtoInput<Self>>,
357-
_cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
358-
) -> Result<LtoModuleCodegen<Self>, FatalError> {
359+
_diff_fncs: Vec<AutoDiffItem>,
360+
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
359361
assert!(
360362
cgcx.lto == rustc_session::config::Lto::Fat,
361-
"`run_fat_lto` (for `WorkItemResult::NeedsFatLto`) should \
363+
"`run_and_optimize_fat_lto` (for `WorkItemResult::NeedsFatLto`) should \
362364
only be invoked due to `-Clto` (or equivalent)"
363365
);
364366
unreachable!("Rust-GPU does not support fat LTO")
365367
}
366368

367369
fn run_thin_lto(
368370
cgcx: &CodegenContext<Self>,
371+
// FIXME(bjorn3): Limit LTO exports to these symbols
372+
_exported_symbols_for_lto: &[String],
373+
_each_linked_rlib_for_lto: &[PathBuf], // njn: ?
369374
modules: Vec<(String, Self::ThinBuffer)>,
370375
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
371-
) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError> {
376+
) -> Result<(Vec<ThinModule<Self>>, Vec<WorkProduct>), FatalError> {
372377
link::run_thin(cgcx, modules, cached_modules)
373378
}
374379

@@ -409,16 +414,8 @@ impl WriteBackendMethods for SpirvCodegenBackend {
409414
Ok(module)
410415
}
411416

412-
fn optimize_fat(
413-
cgcx: &CodegenContext<Self>,
414-
module: &mut ModuleCodegen<Self::Module>,
415-
) -> Result<(), FatalError> {
416-
Self::optimize_common(cgcx, module)
417-
}
418-
419417
fn codegen(
420418
cgcx: &CodegenContext<Self>,
421-
_diag_handler: DiagCtxtHandle<'_>,
422419
module: ModuleCodegen<Self::Module>,
423420
_config: &ModuleConfig,
424421
) -> Result<CompiledModule, FatalError> {
@@ -457,15 +454,6 @@ impl WriteBackendMethods for SpirvCodegenBackend {
457454
SpirvModuleBuffer(module.module_llvm.assemble()),
458455
)
459456
}
460-
461-
fn autodiff(
462-
_cgcx: &CodegenContext<Self>,
463-
_module: &ModuleCodegen<Self::Module>,
464-
_diff_fncs: Vec<AutoDiffItem>,
465-
_config: &ModuleConfig,
466-
) -> Result<(), FatalError> {
467-
unreachable!("Rust-GPU does not support autodiff")
468-
}
469457
}
470458

471459
impl ExtraBackendMethods for SpirvCodegenBackend {

crates/rustc_codegen_spirv/src/link.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rspirv::binary::Assemble;
88
use rspirv::dr::Module;
99
use rustc_ast::CRATE_NODE_ID;
1010
use rustc_codegen_spirv_types::{CompileResult, ModuleResult};
11-
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
11+
use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared};
1212
use rustc_codegen_ssa::back::write::CodegenContext;
1313
use rustc_codegen_ssa::{CodegenResults, NativeLib};
1414
use rustc_data_structures::fx::FxHashSet;
@@ -634,7 +634,7 @@ pub(crate) fn run_thin(
634634
cgcx: &CodegenContext<SpirvCodegenBackend>,
635635
modules: Vec<(String, SpirvModuleBuffer)>,
636636
cached_modules: Vec<(SerializedModule<SpirvModuleBuffer>, WorkProduct)>,
637-
) -> Result<(Vec<LtoModuleCodegen<SpirvCodegenBackend>>, Vec<WorkProduct>), FatalError> {
637+
) -> Result<(Vec<ThinModule<SpirvCodegenBackend>>, Vec<WorkProduct>), FatalError> {
638638
if cgcx.opts.cg.linker_plugin_lto.enabled() {
639639
unreachable!("We should never reach this case if the LTO step is deferred to the linker");
640640
}
@@ -668,10 +668,10 @@ pub(crate) fn run_thin(
668668

669669
let mut opt_jobs = vec![];
670670
for (module_index, _) in shared.module_names.iter().enumerate() {
671-
opt_jobs.push(LtoModuleCodegen::Thin(ThinModule {
671+
opt_jobs.push(ThinModule {
672672
shared: shared.clone(),
673673
idx: module_index,
674-
}));
674+
});
675675
}
676676

677677
Ok((opt_jobs, vec![]))

rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[toolchain]
2-
channel = "nightly-2025-07-14"
2+
channel = "nightly-2025-07-28"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]
4-
# commit_hash = e9182f195b8505c87c4bd055b9f6e114ccda0981
4+
# commit_hash = f8e355c230c6eb7b78ffce6a92fd81f78c890524
55

66
# Whenever changing the nightly channel, update the commit hash above, and
77
# change `REQUIRED_RUST_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` too.

0 commit comments

Comments
 (0)