Skip to content

rustup: update to nightly-2025-06-23 (~1.89). #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use std::{env, fs, mem};
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2025-05-09"
channel = "nightly-2025-06-23"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = 50aa04180709189a03dde5fd1c05751b2625ed37"#;
# commit_hash = be19eda0dc4c22c5cf5f1b48fd163acf9bd4b0a6"#;

fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
Expand Down Expand Up @@ -209,6 +209,13 @@ pub(crate) fn create_object_file(_: &Session) -> Option<write::Object<'static>>
#[cfg(any())]
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {",
);
src = src.replace(
"
pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {",
"
#[cfg(any())]
pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {",
);
}

// HACK(eddyb) "typed alloca" patches.
Expand Down Expand Up @@ -255,17 +262,17 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
}
if line.starts_with('[') {
toml_directive = Some(line);
} else if toml_directive == Some("[dependencies]") {
if let Some((name, _)) = line.split_once(" = ") {
// HACK(eddyb) ignore a weird edge case.
if name == "thorin-dwp" {
continue;
}
let extern_crate = format!("extern crate {};", name.replace('-', "_"));
if !all_extern_crates.contains(&extern_crate) {
writeln(&mut all_extern_crates, "#[allow(unused_extern_crates)]");
writeln(&mut all_extern_crates, &extern_crate);
}
} else if toml_directive == Some("[dependencies]")
&& let Some((name, _)) = line.split_once(" = ")
{
// HACK(eddyb) ignore a weird edge case.
if name == "thorin-dwp" {
continue;
}
let extern_crate = format!("extern crate {};", name.replace('-', "_"));
if !all_extern_crates.contains(&extern_crate) {
writeln(&mut all_extern_crates, "#[allow(unused_extern_crates)]");
writeln(&mut all_extern_crates, &extern_crate);
}
}
}
Expand Down Expand Up @@ -320,9 +327,6 @@ mod maybe_pqp_cg_ssa;
// HACK(eddyb) `if cfg!(llvm_enzyme)` added upstream for autodiff support.
println!("cargo::rustc-check-cfg=cfg(llvm_enzyme)");

// HACK(eddyb) `cfg_attr(bootstrap, ...` used upstream temporarily.
println!("cargo::rustc-check-cfg=cfg(bootstrap)");

Ok(())
}

Expand Down
76 changes: 51 additions & 25 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ pub(crate) fn provide(providers: &mut Providers) {
let trivial_struct = match tcx.hir_node_by_def_id(def_id) {
rustc_hir::Node::Item(item) => match item.kind {
rustc_hir::ItemKind::Struct(
..,
_,
&rustc_hir::Generics {
params:
&[]
Expand All @@ -309,6 +309,7 @@ pub(crate) fn provide(providers: &mut Providers) {
where_clause_span: _,
span: _,
},
_,
) => Some(tcx.adt_def(def_id)),
_ => None,
},
Expand Down Expand Up @@ -541,12 +542,11 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {

let attrs = AggregatedSpirvAttributes::parse(cx, cx.tcx.get_attrs_unchecked(adt.did()));

if let Some(intrinsic_type_attr) = attrs.intrinsic_type.map(|attr| attr.value) {
if let Ok(spirv_type) =
if let Some(intrinsic_type_attr) = attrs.intrinsic_type.map(|attr| attr.value)
&& let Ok(spirv_type) =
trans_intrinsic_type(cx, span, *self, args, intrinsic_type_attr)
{
return spirv_type;
}
{
return spirv_type;
}
}

Expand Down Expand Up @@ -612,12 +612,12 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
};
// FIXME(eddyb) use `ArrayVec` here.
let mut field_names = Vec::new();
if let TyKind::Adt(adt, _) = self.ty.kind() {
if let Variants::Single { index } = self.variants {
for i in self.fields.index_by_increasing_offset() {
let field = &adt.variants()[index].fields[FieldIdx::new(i)];
field_names.push(field.name);
}
if let TyKind::Adt(adt, _) = self.ty.kind()
&& let Variants::Single { index } = self.variants
{
for i in self.fields.index_by_increasing_offset() {
let field = &adt.variants()[index].fields[FieldIdx::new(i)];
field_names.push(field.name);
}
}
SpirvType::Adt {
Expand Down Expand Up @@ -792,10 +792,11 @@ fn dig_scalar_pointee<'tcx>(
// the type is really more "Layout with Ty" (`.ty` field + `Deref`s to `Layout`).
fn trans_aggregate<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -> Word {
fn create_zst<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -> Word {
assert_eq!(ty.size, Size::ZERO);
SpirvType::Adt {
def_id: def_id_for_spirv_type_adt(ty),
size: Some(Size::ZERO),
align: Align::from_bytes(0).unwrap(),
align: ty.align.abi,
field_types: &[],
field_offsets: &[],
field_names: None,
Expand All @@ -817,14 +818,18 @@ fn trans_aggregate<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>
// NOTE(eddyb) even if long-term this may become a byte array, that
// only works for "data types" and not "opaque handles" (images etc.).
let largest_case = (0..ty.fields.count())
.map(|i| ty.field(cx, i))
.max_by_key(|case| case.size);
.map(|i| (FieldIdx::from_usize(i), ty.field(cx, i)))
.max_by_key(|(_, case)| case.size);

if let Some(case) = largest_case {
assert_eq!(ty.size, case.size);
case.spirv_type(span, cx)
if let Some((case_idx, case)) = largest_case {
if ty.align != case.align {
// HACK(eddyb) mismatched alignment requires a wrapper `struct`.
trans_struct_or_union(cx, span, ty, Some(case_idx))
} else {
assert_eq!(ty.size, case.size);
case.spirv_type(span, cx)
}
} else {
assert_eq!(ty.size, Size::ZERO);
create_zst(cx, span, ty)
}
}
Expand Down Expand Up @@ -859,10 +864,19 @@ fn trans_aggregate<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>
FieldsShape::Arbitrary {
offsets: _,
memory_index: _,
} => trans_struct(cx, span, ty),
} => trans_struct_or_union(cx, span, ty, None),
}
}

#[cfg_attr(
not(rustc_codegen_spirv_disable_pqp_cg_ssa),
expect(
unused,
reason = "actually used from \
`<rustc_codegen_ssa::traits::ConstCodegenMethods for CodegenCx<'_>>::const_struct`, \
but `rustc_codegen_ssa` being `pqp_cg_ssa` makes that trait unexported"
)
)]
// returns (field_offsets, size, align)
pub fn auto_struct_layout(
cx: &CodegenCx<'_>,
Expand Down Expand Up @@ -890,14 +904,25 @@ pub fn auto_struct_layout(
}

// see struct_llfields in librustc_codegen_llvm for implementation hints
fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -> Word {
fn trans_struct_or_union<'tcx>(
cx: &CodegenCx<'tcx>,
span: Span,
ty: TyAndLayout<'tcx>,
union_case: Option<FieldIdx>,
) -> Word {
let size = if ty.is_unsized() { None } else { Some(ty.size) };
let align = ty.align.abi;
// FIXME(eddyb) use `AccumulateVec`s just like `rustc` itself does.
let mut field_types = Vec::new();
let mut field_offsets = Vec::new();
let mut field_names = Vec::new();
for i in ty.fields.index_by_increasing_offset() {
if let Some(expected_field_idx) = union_case
&& i != expected_field_idx.as_usize()
{
continue;
}

let field_ty = ty.field(cx, i);
field_types.push(field_ty.spirv_type(span, cx));
let offset = ty.fields.offset(i);
Expand Down Expand Up @@ -969,10 +994,11 @@ impl<'tcx> From<TyAndLayout<'tcx>> for TyLayoutNameKey<'tcx> {
impl fmt::Display for TyLayoutNameKey<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.ty)?;
if let (TyKind::Adt(def, _), Some(index)) = (self.ty.kind(), self.variant) {
if def.is_enum() && !def.variants().is_empty() {
write!(f, "::{}", def.variants()[index].name)?;
}
if let (TyKind::Adt(def, _), Some(index)) = (self.ty.kind(), self.variant)
&& def.is_enum()
&& !def.variants().is_empty()
{
write!(f, "::{}", def.variants()[index].name)?;
}
if let (TyKind::Coroutine(_, _), Some(index)) = (self.ty.kind(), self.variant) {
write!(f, "::{}", CoroutineArgs::variant_name(index))?;
Expand Down
Loading