Skip to content

Commit 9331e20

Browse files
committed
rustup: update to nightly-2025-06-23 (~1.89).
1 parent 658e55b commit 9331e20

22 files changed

+480
-407
lines changed

crates/rustc_codegen_spirv/build.rs

Lines changed: 9 additions & 5 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-05-09"
21+
channel = "nightly-2025-06-23"
2222
components = ["rust-src", "rustc-dev", "llvm-tools"]
23-
# commit_hash = 50aa04180709189a03dde5fd1c05751b2625ed37"#;
23+
# commit_hash = be19eda0dc4c22c5cf5f1b48fd163acf9bd4b0a6"#;
2424

2525
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2626
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
@@ -209,6 +209,13 @@ pub(crate) fn create_object_file(_: &Session) -> Option<write::Object<'static>>
209209
#[cfg(any())]
210210
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {",
211211
);
212+
src = src.replace(
213+
"
214+
pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {",
215+
"
216+
#[cfg(any())]
217+
pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {",
218+
);
212219
}
213220

214221
// HACK(eddyb) "typed alloca" patches.
@@ -320,9 +327,6 @@ mod maybe_pqp_cg_ssa;
320327
// HACK(eddyb) `if cfg!(llvm_enzyme)` added upstream for autodiff support.
321328
println!("cargo::rustc-check-cfg=cfg(llvm_enzyme)");
322329

323-
// HACK(eddyb) `cfg_attr(bootstrap, ...` used upstream temporarily.
324-
println!("cargo::rustc-check-cfg=cfg(bootstrap)");
325-
326330
Ok(())
327331
}
328332

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub(crate) fn provide(providers: &mut Providers) {
290290
let trivial_struct = match tcx.hir_node_by_def_id(def_id) {
291291
rustc_hir::Node::Item(item) => match item.kind {
292292
rustc_hir::ItemKind::Struct(
293-
..,
293+
_,
294294
&rustc_hir::Generics {
295295
params:
296296
&[]
@@ -309,6 +309,7 @@ pub(crate) fn provide(providers: &mut Providers) {
309309
where_clause_span: _,
310310
span: _,
311311
},
312+
_,
312313
) => Some(tcx.adt_def(def_id)),
313314
_ => None,
314315
},
@@ -792,10 +793,11 @@ fn dig_scalar_pointee<'tcx>(
792793
// the type is really more "Layout with Ty" (`.ty` field + `Deref`s to `Layout`).
793794
fn trans_aggregate<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -> Word {
794795
fn create_zst<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -> Word {
796+
assert_eq!(ty.size, Size::ZERO);
795797
SpirvType::Adt {
796798
def_id: def_id_for_spirv_type_adt(ty),
797799
size: Some(Size::ZERO),
798-
align: Align::from_bytes(0).unwrap(),
800+
align: ty.align.abi,
799801
field_types: &[],
800802
field_offsets: &[],
801803
field_names: None,
@@ -817,14 +819,18 @@ fn trans_aggregate<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>
817819
// NOTE(eddyb) even if long-term this may become a byte array, that
818820
// only works for "data types" and not "opaque handles" (images etc.).
819821
let largest_case = (0..ty.fields.count())
820-
.map(|i| ty.field(cx, i))
821-
.max_by_key(|case| case.size);
822+
.map(|i| (FieldIdx::from_usize(i), ty.field(cx, i)))
823+
.max_by_key(|(_, case)| case.size);
822824

823-
if let Some(case) = largest_case {
824-
assert_eq!(ty.size, case.size);
825-
case.spirv_type(span, cx)
825+
if let Some((case_idx, case)) = largest_case {
826+
if ty.align != case.align {
827+
// HACK(eddyb) mismatched alignment requires a wrapper `struct`.
828+
trans_struct_or_union(cx, span, ty, Some(case_idx))
829+
} else {
830+
assert_eq!(ty.size, case.size);
831+
case.spirv_type(span, cx)
832+
}
826833
} else {
827-
assert_eq!(ty.size, Size::ZERO);
828834
create_zst(cx, span, ty)
829835
}
830836
}
@@ -859,7 +865,7 @@ fn trans_aggregate<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>
859865
FieldsShape::Arbitrary {
860866
offsets: _,
861867
memory_index: _,
862-
} => trans_struct(cx, span, ty),
868+
} => trans_struct_or_union(cx, span, ty, None),
863869
}
864870
}
865871

@@ -890,14 +896,25 @@ pub fn auto_struct_layout(
890896
}
891897

892898
// see struct_llfields in librustc_codegen_llvm for implementation hints
893-
fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -> Word {
899+
fn trans_struct_or_union<'tcx>(
900+
cx: &CodegenCx<'tcx>,
901+
span: Span,
902+
ty: TyAndLayout<'tcx>,
903+
union_case: Option<FieldIdx>,
904+
) -> Word {
894905
let size = if ty.is_unsized() { None } else { Some(ty.size) };
895906
let align = ty.align.abi;
896907
// FIXME(eddyb) use `AccumulateVec`s just like `rustc` itself does.
897908
let mut field_types = Vec::new();
898909
let mut field_offsets = Vec::new();
899910
let mut field_names = Vec::new();
900911
for i in ty.fields.index_by_increasing_offset() {
912+
if let Some(expected_field_idx) = union_case {
913+
if i != expected_field_idx.as_usize() {
914+
continue;
915+
}
916+
}
917+
901918
let field_ty = ty.field(cx, i);
902919
field_types.push(field_ty.spirv_type(span, cx));
903920
let offset = ty.fields.offset(i);

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_abi::{Align, BackendRepr, Scalar, Size, WrappingRange};
1414
use rustc_apfloat::{Float, Round, Status, ieee};
1515
use rustc_codegen_ssa::MemFlags;
1616
use rustc_codegen_ssa::common::{
17-
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
17+
AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
1818
};
1919
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
2020
use rustc_codegen_ssa::mir::place::PlaceRef;
@@ -26,7 +26,7 @@ use rustc_data_structures::fx::FxHashSet;
2626
use rustc_middle::bug;
2727
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2828
use rustc_middle::ty::layout::LayoutOf;
29-
use rustc_middle::ty::{self, Ty};
29+
use rustc_middle::ty::{self, AtomicOrdering, Ty};
3030
use rustc_span::Span;
3131
use rustc_target::callconv::FnAbi;
3232
use smallvec::SmallVec;
@@ -157,17 +157,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
157157
fn ordering_to_semantics_def(&self, ordering: AtomicOrdering) -> SpirvValue {
158158
let mut invalid_seq_cst = false;
159159
let semantics = match ordering {
160-
AtomicOrdering::Unordered | AtomicOrdering::Relaxed => MemorySemantics::NONE,
161-
// Note: rustc currently has AtomicOrdering::Consume commented out, if it ever becomes
162-
// uncommented, it should be MakeVisible | Acquire.
160+
AtomicOrdering::Relaxed => MemorySemantics::NONE,
163161
AtomicOrdering::Acquire => MemorySemantics::MAKE_VISIBLE | MemorySemantics::ACQUIRE,
164162
AtomicOrdering::Release => MemorySemantics::MAKE_AVAILABLE | MemorySemantics::RELEASE,
165-
AtomicOrdering::AcquireRelease => {
163+
AtomicOrdering::AcqRel => {
166164
MemorySemantics::MAKE_AVAILABLE
167165
| MemorySemantics::MAKE_VISIBLE
168166
| MemorySemantics::ACQUIRE_RELEASE
169167
}
170-
AtomicOrdering::SequentiallyConsistent => {
168+
AtomicOrdering::SeqCst => {
171169
let emit = self.emit();
172170
let memory_model = emit.module_ref().memory_model.as_ref().unwrap();
173171
if memory_model.operands[1].unwrap_memory_model() == MemoryModel::Vulkan {
@@ -182,8 +180,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
182180
if invalid_seq_cst {
183181
self.zombie(
184182
semantics.def(self),
185-
"cannot use AtomicOrdering=SequentiallyConsistent on Vulkan memory model \
186-
(check if AcquireRelease fits your needs)",
183+
"cannot use `AtomicOrdering::SeqCst` on Vulkan memory model \
184+
(check if `AcqRel` fits your needs)",
187185
);
188186
}
189187
semantics
@@ -3165,6 +3163,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
31653163
String::from_utf8(piece_str_bytes).ok()
31663164
};
31673165

3166+
// HACK(eddyb) `panic_explicit` doesn't take any regular arguments,
3167+
// only an (implicit) `&'static panic::Location<'static>`.
3168+
if args.len() == 1 {
3169+
decoded_format_args.const_pieces =
3170+
Some(["explicit panic".into()].into_iter().collect());
3171+
return Ok(decoded_format_args);
3172+
}
3173+
31683174
// HACK(eddyb) some entry-points only take a `&str`, not `fmt::Arguments`.
31693175
if let [
31703176
SpirvValue {
@@ -3397,17 +3403,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
33973403
}
33983404
};
33993405

3400-
let prepare_args_insts = try_rev_take(3).ok_or_else(|| {
3406+
let prepare_args_insts = try_rev_take(2).ok_or_else(|| {
34013407
FormatArgsNotRecognized(
34023408
"fmt::Arguments::new_v1_formatted call: ran out of instructions".into(),
34033409
)
34043410
})?;
34053411
let (rt_args_slice_ptr_id, _fmt_placeholders_slice_ptr_id) =
34063412
match prepare_args_insts[..] {
34073413
[
3408-
// HACK(eddyb) `rt::UnsafeArg::new()` call
3409-
// (`unsafe` ZST "constructor").
3410-
Inst::Call(_, _, ref rt_unsafe_arg_call_args),
34113414
Inst::Bitcast(
34123415
rt_args_cast_out_id,
34133416
rt_args_cast_in_id,
@@ -3416,8 +3419,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
34163419
placeholders_cast_out_id,
34173420
placeholders_cast_in_id,
34183421
),
3419-
] if rt_unsafe_arg_call_args.is_empty()
3420-
&& rt_args_cast_out_id == rt_args_slice_ptr_id
3422+
] if rt_args_cast_out_id == rt_args_slice_ptr_id
34213423
&& placeholders_cast_out_id
34223424
== fmt_placeholders_slice_ptr_id =>
34233425
{

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ use rustc_middle::ty::{FnDef, Instance, Ty, TyKind, TypingEnv};
1717
use rustc_middle::{bug, ty};
1818
use rustc_span::Span;
1919
use rustc_span::sym;
20-
use rustc_target::callconv::{FnAbi, PassMode};
21-
use std::assert_matches::assert_matches;
2220

2321
fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_>) -> Option<(u64, bool)> {
2422
match ty.kind() {
@@ -64,9 +62,8 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
6462
fn codegen_intrinsic_call(
6563
&mut self,
6664
instance: Instance<'tcx>,
67-
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
6865
args: &[OperandRef<'tcx, Self::Value>],
69-
llresult: Self::Value,
66+
result: PlaceRef<'tcx, Self::Value>,
7067
_span: Span,
7168
) -> Result<(), ty::Instance<'tcx>> {
7269
let callee_ty = instance.ty(self.tcx, TypingEnv::fully_monomorphized());
@@ -84,7 +81,6 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
8481
let name = self.tcx.item_name(def_id);
8582

8683
let ret_ty = self.layout_of(sig.output()).spirv_type(self.span(), self);
87-
let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout);
8884

8985
let value = match name {
9086
sym::likely | sym::unlikely => {
@@ -94,7 +90,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
9490

9591
sym::breakpoint => {
9692
self.abort();
97-
assert!(fn_abi.ret.is_ignore());
93+
assert!(result.layout.ty.is_unit());
9894
return Ok(());
9995
}
10096

@@ -113,7 +109,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
113109
| sym::prefetch_read_instruction
114110
| sym::prefetch_write_instruction => {
115111
// ignore
116-
assert!(fn_abi.ret.is_ignore());
112+
assert!(result.layout.ty.is_unit());
117113
return Ok(());
118114
}
119115

@@ -338,8 +334,14 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
338334
}
339335
};
340336

341-
if !fn_abi.ret.is_ignore() {
342-
assert_matches!(fn_abi.ret.mode, PassMode::Direct(_) | PassMode::Pair(..));
337+
if result.layout.ty.is_bool() {
338+
let val = self.from_immediate(value);
339+
self.store_to_place(val, result.val);
340+
} else if !result.layout.ty.is_unit() {
341+
// FIXME(eddyb) upstream uses `self.store_to_place(value, result.val);`,
342+
// which AFAICT does not handle packed pairs explicitly, meaning it
343+
// can/will store e.g. LLVM `{A, B}` values, which is legal (in LLVM),
344+
// but seems suboptimal (or even risky with e.g. layout randomization).
343345
OperandRef::from_immediate_or_packed_pair(self, value, result.layout)
344346
.val
345347
.store(self, result);
@@ -360,10 +362,6 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
360362
cond
361363
}
362364

363-
fn type_test(&mut self, _pointer: Self::Value, _typeid: Self::Metadata) -> Self::Value {
364-
todo!()
365-
}
366-
367365
fn type_checked_load(
368366
&mut self,
369367
_llvtable: Self::Value,

crates/rustc_codegen_spirv/src/builder/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub use spirv_asm::InstructionTable;
1212
// HACK(eddyb) avoids rewriting all of the imports (see `lib.rs` and `build.rs`).
1313
use crate::maybe_pqp_cg_ssa as rustc_codegen_ssa;
1414

15-
use crate::abi::ConvSpirvType;
1615
use crate::builder_spirv::{BuilderCursor, SpirvValue, SpirvValueExt};
1716
use crate::codegen_cx::CodegenCx;
1817
use crate::spirv_type::SpirvType;
@@ -193,10 +192,6 @@ impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> {
193192
todo!()
194193
}
195194

196-
fn get_dbg_loc(&self) -> Option<Self::DILocation> {
197-
None
198-
}
199-
200195
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
201196
todo!()
202197
}
@@ -254,10 +249,6 @@ impl<'a, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'a, 'tcx> {
254249
),
255250
}
256251
}
257-
258-
fn arg_memory_ty(&self, arg_abi: &ArgAbi<'tcx, Ty<'tcx>>) -> Self::Type {
259-
arg_abi.layout.spirv_type(self.span(), self)
260-
}
261252
}
262253

263254
impl AbiBuilderMethods for Builder<'_, '_> {

0 commit comments

Comments
 (0)