Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Commit e9cdb96

Browse files
committed
rustup: update to nightly-2023-04-15.
1 parent 87b7d13 commit e9cdb96

File tree

20 files changed

+93
-85
lines changed

20 files changed

+93
-85
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
(using ranges instead of just the starting position, and tracking inlined calls)
3737

3838
### Changed 🛠
39+
- [PR#1067](https://github.com/EmbarkStudios/rust-gpu/pull/1067) updated toolchain to `nightly-2023-04-15`
3940
- [PR#1038](https://github.com/EmbarkStudios/rust-gpu/pull/1038) relaxed `glam` version requirements (from only `0.22`, to `>=0.22, <=0.24`)
4041

4142
### Removed 🔥
@@ -66,7 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6667
(see also [the `--no-early-report-zombies` codegen args docs](docs/src/codegen-args.md#--no-early-report-zombies))
6768
- [PR#1035](https://github.com/EmbarkStudios/rust-gpu/pull/1035) reduced the number of CGUs ("codegen units") used by `spirv-builder` to just `1`
6869
- [PR#1011](https://github.com/EmbarkStudios/rust-gpu/pull/1011) made `NonWritable` all read-only storage buffers (i.e. those typed `&T`, where `T` doesn't have interior mutability)
69-
- [PR#1029](https://github.com/EmbarkStudios/rust-gpu/pull/1029) fixed SampledImage::sample() fns being unnecessarily marked as unsafe
70+
- [PR#1029](https://github.com/EmbarkStudios/rust-gpu/pull/1029) fixed `SampledImage::sample` `fn`s being unnecessarily marked as `unsafe`
71+
- [PR#1005](https://github.com/EmbarkStudios/rust-gpu/pull/1005) updated toolchain to `nightly-2023-03-04`
7072

7173
### Fixed 🩹
7274
- [PR#1041](https://github.com/EmbarkStudios/rust-gpu/pull/1041) fixed `Image::gather()` not always returning a `Vec4`.

crates/rustc_codegen_spirv/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use std::process::{Command, ExitCode};
1010
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1111
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain");
1212
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
13-
channel = "nightly-2023-03-04"
13+
channel = "nightly-2023-04-15"
1414
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
15-
# commit_hash = 44cfafe2fafe816395d3acc434663a45d5178c41"#;
15+
# commit_hash = 84dd17b56a931a631a23dfd5ef2018fd3ef49108"#;
1616

1717
fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
1818
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
424424
if let TyKind::Adt(adt, _) = self.ty.kind() {
425425
if let Variants::Single { index } = self.variants {
426426
for i in self.fields.index_by_increasing_offset() {
427-
let field = &adt.variants()[index].fields[i];
427+
let field = &adt.variants()[index].fields[i.into()];
428428
field_names.push(field.name);
429429
}
430430
}
@@ -711,7 +711,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
711711
field_offsets.push(offset);
712712
if let Variants::Single { index } = ty.variants {
713713
if let TyKind::Adt(adt, _) = ty.ty.kind() {
714-
let field = &adt.variants()[index].fields[i];
714+
let field = &adt.variants()[index].fields[i.into()];
715715
field_names.push(field.name);
716716
} else {
717717
// FIXME(eddyb) this looks like something that should exist in rustc.

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
657657
}
658658

659659
fn set_span(&mut self, span: Span) {
660+
// HACK(eddyb) this is what `#[track_caller]` does, and we need it to be
661+
// able to point at e.g. a use of `panic!`, instead of its implementation,
662+
// but it should be more fine-grained and/or include macro backtraces in
663+
// debuginfo (so the decision to use them can be deferred).
664+
let span = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
665+
660666
let old_span = self.current_span.replace(span);
661667

662668
// FIXME(eddyb) enable this once cross-block interactions are figured out
@@ -2392,10 +2398,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
23922398
&[SpirvValue {
23932399
kind: SpirvValueKind::Def(format_args_id),
23942400
..
2395-
}, SpirvValue {
2396-
kind: SpirvValueKind::IllegalConst(_panic_location_id),
2397-
..
2398-
}] => format_args_id,
2401+
}, _] => format_args_id,
23992402

24002403
_ => return None,
24012404
};
@@ -2445,21 +2448,27 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
24452448
(operands.next().unwrap(), operands.next().unwrap())
24462449
})
24472450
.filter(|&(store_dst_id, _)| store_dst_id == load_src_id)?;
2448-
let (call_fmt_args_new_idx, _) = relevant_insts_next_back(Op::FunctionCall)
2451+
let call_fmt_args_new_idx = relevant_insts_next_back(Op::FunctionCall)
24492452
.filter(|&(_, result_id, _)| result_id == Some(store_val_id))
24502453
.map(|(i, _, mut operands)| (i, operands.next().unwrap(), operands))
24512454
.filter(|&(_, callee, _)| self.fmt_args_new_fn_ids.borrow().contains(&callee))
2452-
.map(|(i, _, mut call_args)| {
2453-
assert_eq!(call_args.len(), 4);
2454-
let mut arg = || call_args.next().unwrap();
2455-
(i, [arg(), arg(), arg(), arg()])
2456-
})
2457-
.filter(|&(_, [_, _, _, fmt_args_len_id])| {
2458-
// Only ever remove `fmt::Arguments` with no runtime values.
2459-
matches!(
2460-
self.builder.lookup_const_by_id(fmt_args_len_id),
2461-
Some(SpirvConst::U32(0))
2462-
)
2455+
.and_then(|(i, _, mut call_args)| {
2456+
if call_args.len() == 4 {
2457+
// `<core::fmt::Arguments>::new_v1`
2458+
let mut arg = || call_args.next().unwrap();
2459+
let [_, _, _, fmt_args_len_id] = [arg(), arg(), arg(), arg()];
2460+
// Only ever remove `fmt::Arguments` with no runtime values.
2461+
Some(i).filter(|_| {
2462+
matches!(
2463+
self.builder.lookup_const_by_id(fmt_args_len_id),
2464+
Some(SpirvConst::U32(0))
2465+
)
2466+
})
2467+
} else {
2468+
// `<core::fmt::Arguments>::new_const`
2469+
assert_eq!(call_args.len(), 2);
2470+
Some(i)
2471+
}
24632472
})?;
24642473

24652474
// Lastly, ensure that the `Op{Store,Load}` pair operates on

crates/rustc_codegen_spirv/src/builder_spirv.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@ impl<'tcx> BuilderSpirv<'tcx> {
683683
&self,
684684
span: Span,
685685
) -> (DebugFileSpirv<'tcx>, Range<(u32, u32)>) {
686+
// HACK(eddyb) this is similar to what `#[track_caller]` does, and it
687+
// allows us to point to the use site of a macro, instead of inside the
688+
// macro (but ideally we would record the entire macro backtrace).
689+
let span = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
690+
686691
let (lo, hi) = (span.lo(), span.hi());
687692

688693
let lo_loc = self.source_map.lookup_char_pos(lo);

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
127127
fn const_undef(&self, ty: Self::Type) -> Self::Value {
128128
self.undef(ty)
129129
}
130+
fn const_poison(&self, ty: Self::Type) -> Self::Value {
131+
// No distinction between undef and poison.
132+
self.const_undef(ty)
133+
}
130134
fn const_int(&self, t: Self::Type, i: i64) -> Self::Value {
131135
self.constant_int(t, i as u64)
132136
}

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::spirv_type::SpirvType;
77
use rspirv::spirv::{FunctionControl, LinkageType, StorageClass, Word};
88
use rustc_attr::InlineAttr;
99
use rustc_codegen_ssa::traits::{BaseTypeMethods, PreDefineMethods, StaticMethods};
10+
use rustc_hir::def::DefKind;
1011
use rustc_middle::bug;
1112
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
1213
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
@@ -124,8 +125,16 @@ impl<'tcx> CodegenCx<'tcx> {
124125

125126
let declared = fn_id.with_type(function_type);
126127

127-
let attrs =
128-
AggregatedSpirvAttributes::parse(self, self.tcx.get_attrs_unchecked(instance.def_id()));
128+
let attrs = AggregatedSpirvAttributes::parse(
129+
self,
130+
match self.tcx.def_kind(instance.def_id()) {
131+
// This was made to ICE cross-crate at some point, but then got
132+
// reverted in https://github.com/rust-lang/rust/pull/111381.
133+
// FIXME(eddyb) remove this workaround once we rustup past that.
134+
DefKind::Closure => &[],
135+
_ => self.tcx.get_attrs_unchecked(instance.def_id()),
136+
},
137+
);
129138
if let Some(entry) = attrs.entry.map(|attr| attr.value) {
130139
let entry_name = entry
131140
.name
@@ -178,7 +187,12 @@ impl<'tcx> CodegenCx<'tcx> {
178187

179188
// HACK(eddyb) there is no good way to identify this definition
180189
// (e.g. no `#[lang = "..."]` attribute), but this works well enough.
181-
if demangled_symbol_name == "<core::fmt::Arguments>::new_v1" {
190+
if [
191+
"<core::fmt::Arguments>::new_v1",
192+
"<core::fmt::Arguments>::new_const",
193+
]
194+
.contains(&&demangled_symbol_name[..])
195+
{
182196
self.fmt_args_new_fn_ids.borrow_mut().insert(fn_id);
183197
}
184198

crates/rustc_codegen_spirv/src/codegen_cx/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct CodegenCx<'tcx> {
6969
// it mandatory even for `panic!("...")` (that were previously separate).
7070
pub panic_entry_point_ids: RefCell<FxHashSet<Word>>,
7171

72-
/// `core::fmt::Arguments::new_v1` instances (for Rust 2021 panics).
72+
/// `core::fmt::Arguments::new_{v1,const}` instances (for Rust 2021 panics).
7373
pub fmt_args_new_fn_ids: RefCell<FxHashSet<Word>>,
7474

7575
/// Intrinsic for loading a <T> from a &[u32]. The PassMode is the mode of the <T>.

crates/rustc_codegen_spirv/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#![feature(assert_matches)]
2020
#![feature(result_flattening)]
2121
#![feature(lint_reasons)]
22-
#![feature(once_cell)]
22+
#![feature(lazy_cell)]
2323
// crate-specific exceptions:
2424
#![allow(
2525
unsafe_code, // rustc_codegen_ssa requires unsafe functions in traits to be impl'd
@@ -104,7 +104,7 @@ use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
104104
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
105105
use rustc_middle::mir::pretty::write_mir_pretty;
106106
use rustc_middle::ty::print::with_no_trimmed_paths;
107-
use rustc_middle::ty::{self, query, DefIdTree, Instance, InstanceDef, TyCtxt};
107+
use rustc_middle::ty::{self, query, Instance, InstanceDef, TyCtxt};
108108
use rustc_session::config::{self, OutputFilenames, OutputType};
109109
use rustc_session::Session;
110110
use rustc_span::symbol::{sym, Symbol};

crates/rustc_codegen_spirv/src/link.rs

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,14 @@ fn link_rlib(sess: &Session, codegen_results: &CodegenResults, out_filename: &Pa
9999
file_list.push(obj);
100100
}
101101
for lib in codegen_results.crate_info.used_libraries.iter() {
102-
match lib.kind {
103-
NativeLibKind::Static {
104-
bundle: None | Some(true),
105-
..
106-
} => {}
107-
NativeLibKind::Static {
108-
bundle: Some(false),
109-
..
110-
}
111-
| NativeLibKind::Dylib { .. }
112-
| NativeLibKind::Framework { .. }
113-
| NativeLibKind::RawDylib
114-
| NativeLibKind::LinkArg
115-
| NativeLibKind::Unspecified => continue,
116-
}
117-
if let Some(name) = lib.name {
102+
if let NativeLibKind::Static {
103+
bundle: None | Some(true),
104+
..
105+
} = lib.kind
106+
{
118107
sess.err(format!(
119-
"Adding native library to rlib not supported yet: {name}"
108+
"adding native library to rlib not supported yet: {}",
109+
lib.name
120110
));
121111
}
122112
}
@@ -441,39 +431,23 @@ fn add_upstream_native_libraries(
441431

442432
for &cnum in &codegen_results.crate_info.used_crates {
443433
for lib in codegen_results.crate_info.native_libraries[&cnum].iter() {
444-
let name = match lib.name {
445-
Some(l) => l,
446-
None => continue,
447-
};
448434
if !relevant_lib(sess, lib) {
449435
continue;
450436
}
451437
match lib.kind {
452-
NativeLibKind::Dylib { .. } | NativeLibKind::Unspecified => sess.fatal(format!(
453-
"TODO: dylib nativelibkind not supported yet: {name}"
454-
)),
455-
NativeLibKind::Framework { .. } => sess.fatal(format!(
456-
"TODO: framework nativelibkind not supported yet: {name}"
457-
)),
458438
NativeLibKind::Static {
459439
bundle: Some(false),
460440
..
461-
} => {
462-
if data[cnum.as_usize() - 1] == Linkage::Static {
463-
sess.fatal(format!(
464-
"TODO: staticnobundle nativelibkind not supported yet: {name}"
465-
))
466-
}
467-
}
441+
} if data[cnum.as_usize() - 1] != Linkage::Static => {}
442+
468443
NativeLibKind::Static {
469444
bundle: None | Some(true),
470445
..
471446
} => {}
472-
NativeLibKind::RawDylib => {
473-
sess.fatal(format!("raw_dylib feature not yet implemented: {name}"))
474-
}
475-
NativeLibKind::LinkArg => sess.fatal(format!(
476-
"TODO: linkarg nativelibkind not supported yet: {name}"
447+
448+
_ => sess.fatal(format!(
449+
"`NativeLibKind::{:?}` (name={:?}) not supported yet",
450+
lib.kind, lib.name
477451
)),
478452
}
479453
}

0 commit comments

Comments
 (0)