Skip to content

Commit 0580b41

Browse files
committed
rustup to nightly-2025-04-28
1 parent 1e4e468 commit 0580b41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+927
-633
lines changed

Cargo.lock

Lines changed: 345 additions & 250 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ members = [
3131
[workspace.package]
3232
version = "0.9.0"
3333
authors = ["rust-gpu developers", "Embark <opensource@embark-studios.com>"]
34-
edition = "2021"
34+
edition = "2024"
3535
license = "MIT OR Apache-2.0"
3636
repository = "https://github.com/rust-gpu/rust-gpu"
3737

crates/rustc_codegen_spirv/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ rustix = { version = "0.38.42", features = ["all-apis"] }
4141

4242
# HACK(eddyb) deps of `rustc_codegen_ssa`, for `pqp_cg_ssa` (see `build.rs`),
4343
# that cannot be handled with just `extern crate` pulling out of the sysroot.
44-
object = { version = "0.36.2", default-features = false, features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive", "write", "wasm"] }
45-
thorin-dwp = "0.8"
44+
object = { version = "0.36.2", default-features = false, features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive", "write", "wasm"] }
45+
thorin-dwp = "0.9"
4646

4747
# Normal dependencies.
4848
ar = "0.9.0"
@@ -64,6 +64,9 @@ tracing-tree = "0.3.0"
6464
[dev-dependencies]
6565
pretty_assertions = "1.0"
6666

67+
[lints.rust]
68+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)', 'cfg(llvm_enzyme)'] }
69+
6770
# HACK(eddyb) can't re-introduce deps of `rustc_codegen_ssa`, for `pqp_cg_ssa`
6871
# (see `build.rs`).
6972
# tempfile = "3.4"

crates/rustc_codegen_spirv/build.rs

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use std::{env, fs, mem};
1515
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1616
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
1717
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
18-
channel = "nightly-2024-11-22"
18+
channel = "nightly-2025-04-28"
1919
components = ["rust-src", "rustc-dev", "llvm-tools"]
20-
# commit_hash = b19329a37cedf2027517ae22c87cf201f93d776e"#;
20+
# commit_hash = cb31a009e3e735ab08613cec2d8a5a754e65596f"#;
2121

2222
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2323
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
@@ -199,31 +199,83 @@ mod win {",
199199
src = src.replace("if constant_ty.is_simd() {", "if false {");
200200
}
201201

202+
//src = src.replace(" object::", " thorin::object::"); src =
203+
//src.replace("(object::", "(thorin::object::");
204+
202205
fs::write(out_path, src)?;
203206
}
204207
}
205208

206209
// HACK(eddyb) very basic extraction of deps from original `Cargo.toml`.
207210
let mut all_extern_crates = cg_ssa_lib_rs_extern_crates;
208211
let cg_ssa_cargo_toml = fs::read_to_string(out_pqp_cg_ssa_dir.join("Cargo.toml"))?;
209-
let mut toml_directive = None;
212+
for line in cg_ssa_cargo_toml.lines() {
213+
println!("cargo::warning={line}");
214+
}
215+
216+
let mut current_section: Option<&str> = None;
217+
210218
for line in cg_ssa_cargo_toml.lines() {
211219
let line = line.trim();
212220
if line.starts_with('#') || line.is_empty() {
213221
continue;
214222
}
215-
if line.starts_with('[') {
216-
toml_directive = Some(line);
217-
} else if toml_directive == Some("[dependencies]") {
218-
if let Some((name, _)) = line.split_once(" = ") {
223+
224+
if line.starts_with('[') && line.ends_with(']') {
225+
if line == "[dependencies]" {
226+
current_section = Some("[dependencies]");
227+
} else if line.starts_with("[dependencies.") {
228+
// This is a [dependencies.foo] section header.
229+
// Extract 'foo' from '[dependencies.foo]'
230+
if let Some(name_in_header) = line
231+
.strip_prefix("[dependencies.")
232+
.and_then(|s| s.strip_suffix(']'))
233+
{
234+
let name = name_in_header.trim().trim_matches('"');
235+
236+
// HACK(eddyb) ignore a weird edge case.
237+
if name == "thorin-dwp" {
238+
continue;
239+
}
240+
if !name.is_empty() {
241+
let crate_identifier = name.replace('-', "_");
242+
let extern_crate = format!("extern crate {};", crate_identifier);
243+
244+
if !all_extern_crates.contains(&extern_crate) {
245+
writeln(&mut all_extern_crates, "#[allow(unused_extern_crates)]");
246+
writeln(&mut all_extern_crates, &extern_crate);
247+
}
248+
}
249+
250+
// Set section to None so we don't process lines *within* this table
251+
// (like version="...") as dependency names.
252+
current_section = None;
253+
} else {
254+
// Malformed line like "[dependencies.foo", treat as unknown section
255+
current_section = Some(line);
256+
}
257+
} else {
258+
// It's some other section ([build-dependencies], [workspace], etc.)
259+
current_section = Some(line);
260+
}
261+
} else if current_section == Some("[dependencies]") {
262+
// Look for lines like `name = ...`
263+
if let Some((name_in_line, _)) = line.split_once('=') {
264+
let name = name_in_line.trim().trim_matches('"');
265+
219266
// HACK(eddyb) ignore a weird edge case.
220267
if name == "thorin-dwp" {
221268
continue;
222269
}
223-
let extern_crate = format!("extern crate {};", name.replace('-', "_"));
224-
if !all_extern_crates.contains(&extern_crate) {
225-
writeln(&mut all_extern_crates, "#[allow(unused_extern_crates)]");
226-
writeln(&mut all_extern_crates, &extern_crate);
270+
271+
if !name.is_empty() {
272+
let crate_identifier = name.replace('-', "_");
273+
let extern_crate = format!("extern crate {};", crate_identifier);
274+
275+
if !all_extern_crates.contains(&extern_crate) {
276+
writeln(&mut all_extern_crates, "#[allow(unused_extern_crates)]");
277+
writeln(&mut all_extern_crates, &extern_crate);
278+
}
227279
}
228280
}
229281
}

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ use crate::codegen_cx::CodegenCx;
66
use crate::spirv_type::SpirvType;
77
use itertools::Itertools;
88
use rspirv::spirv::{Dim, ImageFormat, StorageClass, Word};
9+
use rustc_abi::ExternAbi;
10+
use rustc_abi::{
11+
Align, BackendRepr, FieldsShape, LayoutData, Primitive, ReprFlags, ReprOptions, Scalar, Size,
12+
TagEncoding, VariantIdx, Variants,
13+
};
914
use rustc_data_structures::fx::FxHashMap;
1015
use rustc_errors::ErrorGuaranteed;
1116
use rustc_index::Idx;
@@ -20,12 +25,7 @@ use rustc_middle::{bug, span_bug};
2025
use rustc_span::DUMMY_SP;
2126
use rustc_span::def_id::DefId;
2227
use rustc_span::{Span, Symbol};
23-
use rustc_target::abi::call::{ArgAbi, ArgAttributes, FnAbi, PassMode};
24-
use rustc_target::abi::{
25-
Align, BackendRepr, FieldsShape, LayoutData, Primitive, ReprFlags, ReprOptions, Scalar, Size,
26-
TagEncoding, VariantIdx, Variants,
27-
};
28-
use rustc_target::spec::abi::Abi;
28+
use rustc_target::callconv::{ArgAbi, ArgAttributes, FnAbi, PassMode};
2929
use std::cell::RefCell;
3030
use std::collections::hash_map::Entry;
3131
use std::fmt;
@@ -46,8 +46,8 @@ pub(crate) fn provide(providers: &mut Providers) {
4646
let result = (rustc_interface::DEFAULT_QUERY_PROVIDERS.fn_sig)(tcx, def_id);
4747
result.map_bound(|outer| {
4848
outer.map_bound(|mut inner| {
49-
if let Abi::C { .. } = inner.abi {
50-
inner.abi = Abi::Unadjusted;
49+
if let ExternAbi::C { .. } = inner.abi {
50+
inner.abi = ExternAbi::Unadjusted;
5151
}
5252
inner
5353
})
@@ -110,6 +110,8 @@ pub(crate) fn provide(providers: &mut Providers) {
110110
size,
111111
max_repr_align,
112112
unadjusted_abi_align,
113+
uninhabited,
114+
randomization_seed,
113115
} = *layout;
114116
LayoutData {
115117
fields: match *fields {
@@ -125,6 +127,7 @@ pub(crate) fn provide(providers: &mut Providers) {
125127
},
126128
},
127129
variants: match *variants {
130+
Variants::Empty => Variants::Empty,
128131
Variants::Single { index } => Variants::Single { index },
129132
Variants::Multiple {
130133
tag,
@@ -155,6 +158,8 @@ pub(crate) fn provide(providers: &mut Providers) {
155158
size,
156159
max_repr_align,
157160
unadjusted_abi_align,
161+
uninhabited,
162+
randomization_seed,
158163
}
159164
}
160165

@@ -198,6 +203,7 @@ pub(crate) fn provide(providers: &mut Providers) {
198203
let trivial_struct = match tcx.hir_node_by_def_id(def_id) {
199204
rustc_hir::Node::Item(item) => match item.kind {
200205
rustc_hir::ItemKind::Struct(
206+
_,
201207
_,
202208
&rustc_hir::Generics {
203209
params:
@@ -462,7 +468,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
462468
// `ScalarPair`.
463469
// There's a few layers that we go through here. First we inspect layout.backend_repr, then if relevant, layout.fields, etc.
464470
match self.backend_repr {
465-
BackendRepr::Uninhabited => SpirvType::Adt {
471+
x @ _ if x.is_unsized() => SpirvType::Adt {
466472
def_id: def_id_for_spirv_type_adt(*self),
467473
size: Some(Size::ZERO),
468474
align: Align::from_bytes(0).unwrap(),
@@ -523,7 +529,9 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
523529
if let TyKind::Adt(adt, _) = self.ty.kind() {
524530
if let Variants::Single { index } = self.variants {
525531
for i in self.fields.index_by_increasing_offset() {
526-
let field = &adt.variants()[index].fields[i.into()];
532+
let field_index = rustc_abi::FieldIdx::from_usize(i);
533+
let field: &rustc_middle::ty::FieldDef =
534+
&adt.variants()[index].fields[field_index];
527535
field_names.push(field.name);
528536
}
529537
}
@@ -542,7 +550,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
542550
}
543551
.def_with_name(cx, span, TyLayoutNameKey::from(*self))
544552
}
545-
BackendRepr::Vector { element, count } => {
553+
BackendRepr::SimdVector { element, count } => {
546554
let elem_spirv = trans_scalar(cx, span, *self, element, Size::ZERO);
547555
SpirvType::Vector {
548556
element: elem_spirv,
@@ -653,6 +661,7 @@ fn dig_scalar_pointee<'tcx>(
653661

654662
let all_fields = (match &layout.variants {
655663
Variants::Multiple { variants, .. } => 0..variants.len(),
664+
Variants::Empty => 0..0,
656665
Variants::Single { index } => {
657666
let i = index.as_usize();
658667
i..i + 1
@@ -811,7 +820,8 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
811820
field_offsets.push(offset);
812821
if let Variants::Single { index } = ty.variants {
813822
if let TyKind::Adt(adt, _) = ty.ty.kind() {
814-
let field = &adt.variants()[index].fields[i.into()];
823+
let field_index = rustc_abi::FieldIdx::from_usize(i);
824+
let field: &rustc_middle::ty::FieldDef = &adt.variants()[index].fields[field_index];
815825
field_names.push(field.name);
816826
} else {
817827
// FIXME(eddyb) this looks like something that should exist in rustc.
@@ -868,6 +878,7 @@ impl<'tcx> From<TyAndLayout<'tcx>> for TyLayoutNameKey<'tcx> {
868878
variant: match layout.variants {
869879
Variants::Single { index } => Some(index),
870880
Variants::Multiple { .. } => None,
881+
Variants::Empty => None,
871882
},
872883
}
873884
}
@@ -984,11 +995,11 @@ fn trans_intrinsic_type<'tcx>(
984995
cx: &CodegenCx<'tcx>,
985996
const_: Const<'tcx>,
986997
) -> Result<P, ErrorGuaranteed> {
987-
let (const_val, const_ty) = const_
988-
.try_to_valtree()
989-
.expect("expected monomorphic const in codegen");
998+
let const_val = const_.to_value();
999+
let const_ty = const_val.ty;
9901000
assert!(const_ty.is_integral());
9911001
const_val
1002+
.valtree
9921003
.try_to_scalar_int()
9931004
.and_then(P::from_scalar_int)
9941005
.ok_or_else(|| {

crates/rustc_codegen_spirv/src/attr.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::codegen_cx::CodegenCx;
66
use crate::symbols::Symbols;
77
use rspirv::spirv::{BuiltIn, ExecutionMode, ExecutionModel, StorageClass};
8-
use rustc_ast::Attribute;
8+
99
use rustc_hir as hir;
1010
use rustc_hir::def_id::LocalModDefId;
1111
use rustc_hir::intravisit::{self, Visitor};
@@ -148,7 +148,7 @@ impl AggregatedSpirvAttributes {
148148
///
149149
/// Any errors for malformed/duplicate attributes will have been reported
150150
/// prior to codegen, by the `attr` check pass.
151-
pub fn parse<'tcx>(cx: &CodegenCx<'tcx>, attrs: &'tcx [Attribute]) -> Self {
151+
pub fn parse<'tcx>(cx: &CodegenCx<'tcx>, attrs: &'tcx [rustc_hir::Attribute]) -> Self {
152152
let mut aggregated_attrs = Self::default();
153153

154154
// NOTE(eddyb) `span_delayed_bug` ensures that if attribute checking fails
@@ -254,8 +254,8 @@ fn target_from_impl_item(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>) -> Targ
254254
match impl_item.kind {
255255
hir::ImplItemKind::Const(..) => Target::AssocConst,
256256
hir::ImplItemKind::Fn(..) => {
257-
let parent_owner_id = tcx.hir().get_parent_item(impl_item.hir_id());
258-
let containing_item = tcx.hir().expect_item(parent_owner_id.def_id);
257+
let parent_owner_id = tcx.hir_get_parent_item(impl_item.hir_id());
258+
let containing_item = tcx.hir_expect_item(parent_owner_id.def_id);
259259
let containing_impl_is_for_trait = match &containing_item.kind {
260260
hir::ItemKind::Impl(hir::Impl { of_trait, .. }) => of_trait.is_some(),
261261
_ => unreachable!("parent of an ImplItem must be an Impl"),
@@ -281,7 +281,7 @@ impl CheckSpirvAttrVisitor<'_> {
281281

282282
let parse_attrs = |attrs| crate::symbols::parse_attrs_for_checking(&self.sym, attrs);
283283

284-
let attrs = self.tcx.hir().attrs(hir_id);
284+
let attrs = self.tcx.hir_attrs(hir_id);
285285
for parse_attr_result in parse_attrs(attrs) {
286286
let (span, parsed_attr) = match parse_attr_result {
287287
Ok(span_and_parsed_attr) => span_and_parsed_attr,
@@ -327,10 +327,9 @@ impl CheckSpirvAttrVisitor<'_> {
327327
| SpirvAttribute::SpecConstant(_) => match target {
328328
Target::Param => {
329329
let parent_hir_id = self.tcx.parent_hir_id(hir_id);
330-
let parent_is_entry_point =
331-
parse_attrs(self.tcx.hir().attrs(parent_hir_id))
332-
.filter_map(|r| r.ok())
333-
.any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_)));
330+
let parent_is_entry_point = parse_attrs(self.tcx.hir_attrs(parent_hir_id))
331+
.filter_map(|r| r.ok())
332+
.any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_)));
334333
if !parent_is_entry_point {
335334
self.tcx.dcx().span_err(
336335
span,
@@ -418,8 +417,8 @@ impl CheckSpirvAttrVisitor<'_> {
418417
impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
419418
type NestedFilter = nested_filter::OnlyBodies;
420419

421-
fn nested_visit_map(&mut self) -> Self::Map {
422-
self.tcx.hir()
420+
fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
421+
self.tcx
423422
}
424423

425424
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
@@ -498,8 +497,8 @@ fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
498497
tcx,
499498
sym: Symbols::get(),
500499
};
501-
tcx.hir()
502-
.visit_item_likes_in_module(module_def_id, check_spirv_attr_visitor);
500+
tcx.hir_visit_item_likes_in_module(module_def_id, check_spirv_attr_visitor);
501+
503502
if module_def_id.is_top_level_module() {
504503
check_spirv_attr_visitor.check_spirv_attributes(CRATE_HIR_ID, Target::Mod);
505504
}

0 commit comments

Comments
 (0)