Skip to content

rustup: update to nightly-2023-04-15. #1067

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 2 commits into from
Jun 2, 2023
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(using ranges instead of just the starting position, and tracking inlined calls)

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

### Removed 🔥
Expand Down Expand Up @@ -66,7 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(see also [the `--no-early-report-zombies` codegen args docs](docs/src/codegen-args.md#--no-early-report-zombies))
- [PR#1035](https://github.com/EmbarkStudios/rust-gpu/pull/1035) reduced the number of CGUs ("codegen units") used by `spirv-builder` to just `1`
- [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)
- [PR#1029](https://github.com/EmbarkStudios/rust-gpu/pull/1029) fixed SampledImage::sample() fns being unnecessarily marked as unsafe
- [PR#1029](https://github.com/EmbarkStudios/rust-gpu/pull/1029) fixed `SampledImage::sample` `fn`s being unnecessarily marked as `unsafe`
- [PR#1005](https://github.com/EmbarkStudios/rust-gpu/pull/1005) updated toolchain to `nightly-2023-03-04`

### Fixed 🩹
- [PR#1041](https://github.com/EmbarkStudios/rust-gpu/pull/1041) fixed `Image::gather()` not always returning a `Vec4`.
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode};
/// `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");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2023-03-04"
channel = "nightly-2023-04-15"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 44cfafe2fafe816395d3acc434663a45d5178c41"#;
# commit_hash = 84dd17b56a931a631a23dfd5ef2018fd3ef49108"#;

fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
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[i];
let field = &adt.variants()[index].fields[i.into()];
field_names.push(field.name);
}
}
Expand Down Expand Up @@ -711,7 +711,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
field_offsets.push(offset);
if let Variants::Single { index } = ty.variants {
if let TyKind::Adt(adt, _) = ty.ty.kind() {
let field = &adt.variants()[index].fields[i];
let field = &adt.variants()[index].fields[i.into()];
field_names.push(field.name);
} else {
// FIXME(eddyb) this looks like something that should exist in rustc.
Expand Down
259 changes: 204 additions & 55 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions crates/rustc_codegen_spirv/src/builder_spirv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@ impl<'tcx> BuilderSpirv<'tcx> {
&self,
span: Span,
) -> (DebugFileSpirv<'tcx>, Range<(u32, u32)>) {
// HACK(eddyb) this is similar to what `#[track_caller]` does, and it
// allows us to point to the use site of a macro, instead of inside the
// macro (but ideally we would record the entire macro backtrace).
let span = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);

let (lo, hi) = (span.lo(), span.hi());

let lo_loc = self.source_map.lookup_char_pos(lo);
Expand Down
4 changes: 4 additions & 0 deletions crates/rustc_codegen_spirv/src/codegen_cx/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
fn const_undef(&self, ty: Self::Type) -> Self::Value {
self.undef(ty)
}
fn const_poison(&self, ty: Self::Type) -> Self::Value {
// No distinction between undef and poison.
self.const_undef(ty)
}
fn const_int(&self, t: Self::Type, i: i64) -> Self::Value {
self.constant_int(t, i as u64)
}
Expand Down
20 changes: 17 additions & 3 deletions crates/rustc_codegen_spirv/src/codegen_cx/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::spirv_type::SpirvType;
use rspirv::spirv::{FunctionControl, LinkageType, StorageClass, Word};
use rustc_attr::InlineAttr;
use rustc_codegen_ssa::traits::{BaseTypeMethods, PreDefineMethods, StaticMethods};
use rustc_hir::def::DefKind;
use rustc_middle::bug;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
Expand Down Expand Up @@ -124,8 +125,16 @@ impl<'tcx> CodegenCx<'tcx> {

let declared = fn_id.with_type(function_type);

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

// HACK(eddyb) there is no good way to identify this definition
// (e.g. no `#[lang = "..."]` attribute), but this works well enough.
if demangled_symbol_name == "<core::fmt::Arguments>::new_v1" {
if [
"<core::fmt::Arguments>::new_v1",
"<core::fmt::Arguments>::new_const",
]
.contains(&&demangled_symbol_name[..])
{
self.fmt_args_new_fn_ids.borrow_mut().insert(fn_id);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct CodegenCx<'tcx> {
// it mandatory even for `panic!("...")` (that were previously separate).
pub panic_entry_point_ids: RefCell<FxHashSet<Word>>,

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

/// Intrinsic for loading a <T> from a &[u32]. The PassMode is the mode of the <T>.
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![feature(assert_matches)]
#![feature(result_flattening)]
#![feature(lint_reasons)]
#![feature(once_cell)]
#![feature(lazy_cell)]
// crate-specific exceptions:
#![allow(
unsafe_code, // rustc_codegen_ssa requires unsafe functions in traits to be impl'd
Expand Down Expand Up @@ -104,7 +104,7 @@ use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
use rustc_middle::mir::pretty::write_mir_pretty;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, query, DefIdTree, Instance, InstanceDef, TyCtxt};
use rustc_middle::ty::{self, query, Instance, InstanceDef, TyCtxt};
use rustc_session::config::{self, OutputFilenames, OutputType};
use rustc_session::Session;
use rustc_span::symbol::{sym, Symbol};
Expand Down
52 changes: 13 additions & 39 deletions crates/rustc_codegen_spirv/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,14 @@ fn link_rlib(sess: &Session, codegen_results: &CodegenResults, out_filename: &Pa
file_list.push(obj);
}
for lib in codegen_results.crate_info.used_libraries.iter() {
match lib.kind {
NativeLibKind::Static {
bundle: None | Some(true),
..
} => {}
NativeLibKind::Static {
bundle: Some(false),
..
}
| NativeLibKind::Dylib { .. }
| NativeLibKind::Framework { .. }
| NativeLibKind::RawDylib
| NativeLibKind::LinkArg
| NativeLibKind::Unspecified => continue,
}
if let Some(name) = lib.name {
if let NativeLibKind::Static {
bundle: None | Some(true),
..
} = lib.kind
{
sess.err(format!(
"Adding native library to rlib not supported yet: {name}"
"adding native library to rlib not supported yet: {}",
lib.name
));
}
}
Expand Down Expand Up @@ -441,39 +431,23 @@ fn add_upstream_native_libraries(

for &cnum in &codegen_results.crate_info.used_crates {
for lib in codegen_results.crate_info.native_libraries[&cnum].iter() {
let name = match lib.name {
Some(l) => l,
None => continue,
};
if !relevant_lib(sess, lib) {
continue;
}
match lib.kind {
NativeLibKind::Dylib { .. } | NativeLibKind::Unspecified => sess.fatal(format!(
"TODO: dylib nativelibkind not supported yet: {name}"
)),
NativeLibKind::Framework { .. } => sess.fatal(format!(
"TODO: framework nativelibkind not supported yet: {name}"
)),
NativeLibKind::Static {
bundle: Some(false),
..
} => {
if data[cnum.as_usize() - 1] == Linkage::Static {
sess.fatal(format!(
"TODO: staticnobundle nativelibkind not supported yet: {name}"
))
}
}
} if data[cnum.as_usize() - 1] != Linkage::Static => {}

NativeLibKind::Static {
bundle: None | Some(true),
..
} => {}
NativeLibKind::RawDylib => {
sess.fatal(format!("raw_dylib feature not yet implemented: {name}"))
}
NativeLibKind::LinkArg => sess.fatal(format!(
"TODO: linkarg nativelibkind not supported yet: {name}"

_ => sess.fatal(format!(
"`NativeLibKind::{:?}` (name={:?}) not supported yet",
lib.kind, lib.name
)),
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/spirv-std/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ pub fn gpu_only(_attr: TokenStream, item: TokenStream) -> TokenStream {
block,
} = syn::parse_macro_input!(item as syn::ItemFn);

// FIXME(eddyb) this looks like a clippy false positive (`sig` is used below).
#[allow(clippy::redundant_clone)]
let fn_name = sig.ident.clone();

let sig_cpu = syn::Signature {
Expand Down
6 changes: 3 additions & 3 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[toolchain]
channel = "nightly-2023-03-04"
channel = "nightly-2023-04-15"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 44cfafe2fafe816395d3acc434663a45d5178c41
# commit_hash = 84dd17b56a931a631a23dfd5ef2018fd3ef49108

# Whenever changing the nightly channel, update the commit hash above, and make
# sure to change REQUIRED_TOOLCHAIN in crates/rustc_codegen_spirv/src/build.rs also.
# sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also.
8 changes: 4 additions & 4 deletions tests/ui/dis/ptr_copy.normal.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: cannot memcpy dynamically sized data
--> $CORE_SRC/intrinsics.rs:2460:9
--> $CORE_SRC/intrinsics.rs:2724:9
|
2460 | copy(src, dst, count)
2724 | copy(src, dst, count)
| ^^^^^^^^^^^^^^^^^^^^^
|
note: used from within `core::intrinsics::copy::<f32>`
--> $CORE_SRC/intrinsics.rs:2447:21
--> $CORE_SRC/intrinsics.rs:2710:21
|
2447 | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
2710 | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
| ^^^^
note: called by `ptr_copy::copy_via_raw_ptr`
--> $DIR/ptr_copy.rs:28:18
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/dis/ptr_read.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%4 = OpFunctionParameter %5
%6 = OpFunctionParameter %5
%7 = OpLabel
OpLine %8 1157 8
OpLine %8 1188 12
%9 = OpLoad %10 %4
OpLine %11 7 13
OpStore %6 %9
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/dis/ptr_read_method.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%4 = OpFunctionParameter %5
%6 = OpFunctionParameter %5
%7 = OpLabel
OpLine %8 1157 8
OpLine %8 1188 12
%9 = OpLoad %10 %4
OpLine %11 7 13
OpStore %6 %9
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/dis/ptr_write.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%7 = OpLabel
OpLine %8 7 35
%9 = OpLoad %10 %4
OpLine %11 1354 8
OpLine %11 1386 8
OpStore %6 %9
OpNoLine
OpReturn
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/dis/ptr_write_method.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%7 = OpLabel
OpLine %8 7 37
%9 = OpLoad %10 %4
OpLine %11 1354 8
OpLine %11 1386 8
OpStore %6 %9
OpNoLine
OpReturn
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/lang/core/unwrap_or.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
OpLine %5 13 11
%6 = OpCompositeInsert %7 %8 %9 0
%10 = OpCompositeExtract %11 %6 1
OpLine %12 967 14
OpLine %12 975 14
%13 = OpBitcast %14 %8
OpLine %12 967 8
OpLine %12 975 8
%15 = OpIEqual %16 %13 %17
OpNoLine
OpSelectionMerge %18 None
Expand Down
6 changes: 2 additions & 4 deletions tests/ui/spirv-attr/invalid-matrix-type-empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
use spirv_std::spirv;

#[spirv(matrix)]
pub struct _EmptyStruct {}
pub struct EmptyStruct {}

#[spirv(fragment)]
pub fn _entry() {
let _empty_struct = _EmptyStruct {};
}
pub fn entry(#[spirv(push_constant)] matrix: &EmptyStruct) {}
4 changes: 2 additions & 2 deletions tests/ui/spirv-attr/invalid-matrix-type-empty.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: #[spirv(matrix)] type must have at least two fields
--> $DIR/invalid-matrix-type-empty.rs:7:1
|
7 | pub struct _EmptyStruct {}
| ^^^^^^^^^^^^^^^^^^^^^^^
7 | pub struct EmptyStruct {}
| ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error