Skip to content
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

Rust update to 1.78.0 #1138

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
File renamed without changes.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [PR#1127](https://github.com/EmbarkStudios/rust-gpu/pull/1127) updated `spirv-tools` to `0.10.0`, which follows `vulkan-sdk-1.3.275`
- [PR#1101](https://github.com/EmbarkStudios/rust-gpu/pull/1101) added `ignore` and `no_run` to documentation to make `cargo test` pass
- [PR#1112](https://github.com/EmbarkStudios/rust-gpu/pull/1112) updated wgpu and winit in example runners
- [PR#1134](https://github.com/EmbarkStudios/rust-gpu/pull/1134) updated toolchain to `nightly-2023-12-21`
- [PR#1100](https://github.com/EmbarkStudios/rust-gpu/pull/1100) updated toolchain to `nightly-2023-09-30`
- [PR#1091](https://github.com/EmbarkStudios/rust-gpu/pull/1091) updated toolchain to `nightly-2023-08-29`
- [PR#1085](https://github.com/EmbarkStudios/rust-gpu/pull/1085) updated toolchain to `nightly-2023-07-08`
Expand Down
26 changes: 3 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ syn = { version = "1", features = ["extra-traits", "full"] }
[dependencies]
# HACK(eddyb) these only exist to unify features across dependency trees,
# in order to avoid multiple separate instances of `rustc_codegen_spirv`.
hashbrown = "0.11"
libc = { version = "0.2", features = ["align", "extra_traits"] }
num-traits = { version = "0.2", features = ["libm"] }
once_cell = "1"
regex = { version = "1", features = ["perf"] }

# Normal dependencies.
termcolor = "1.2"
ar = "0.9.0"
either = "1.8.0"
indexmap = "1.6.0"
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.toml");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2023-09-30"
channel = "nightly-2024-03-14"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = 8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72"#;
# commit_hash = 3cbb93223f33024db464a4df27a13c7cce870173"#;

fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));
Expand Down
46 changes: 26 additions & 20 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_middle::query::Providers;
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
use rustc_middle::ty::GenericArgsRef;
use rustc_middle::ty::{
self, Const, FloatTy, GeneratorArgs, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind,
self, Const, CoroutineArgs, FloatTy, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind,
TypeAndMut, UintTy,
};
use rustc_middle::{bug, span_bug};
Expand Down Expand Up @@ -64,6 +64,9 @@ pub(crate) fn provide(providers: &mut Providers) {
) -> &'tcx FnAbi<'tcx, Ty<'tcx>> {
let readjust_arg_abi = |arg: &ArgAbi<'tcx, Ty<'tcx>>| {
let mut arg = ArgAbi::new(&tcx, arg.layout, |_, _, _| ArgAttributes::new());
// FIXME: this is bad! https://github.com/rust-lang/rust/issues/115666
// <https://github.com/rust-lang/rust/commit/eaaa03faf77b157907894a4207d8378ecaec7b45>
arg.make_direct_deprecated();

// Avoid pointlessly passing ZSTs, just like the official Rust ABI.
if arg.layout.is_zst() {
Expand Down Expand Up @@ -96,7 +99,9 @@ pub(crate) fn provide(providers: &mut Providers) {

// FIXME(eddyb) remove this by deriving `Clone` for `LayoutS` upstream.
// FIXME(eddyb) the `S` suffix is a naming antipattern, rename upstream.
fn clone_layout(layout: &LayoutS) -> LayoutS {
fn clone_layout<FieldIdx: Idx, VariantIdx: Idx>(
layout: &LayoutS<FieldIdx, VariantIdx>,
) -> LayoutS<FieldIdx, VariantIdx> {
let LayoutS {
ref fields,
ref variants,
Expand Down Expand Up @@ -500,8 +505,10 @@ fn trans_scalar<'tcx>(
Primitive::Int(width, signedness) => {
SpirvType::Integer(width.size().bits() as u32, signedness).def(span, cx)
}
Primitive::F16 => SpirvType::Float(16).def(span, cx),
Primitive::F32 => SpirvType::Float(32).def(span, cx),
Primitive::F64 => SpirvType::Float(64).def(span, cx),
Primitive::F128 => SpirvType::Float(128).def(span, cx),
Primitive::Pointer(_) => {
let pointee_ty = dig_scalar_pointee(cx, ty, offset);
// Pointers can be recursive. So, record what we're currently translating, and if we're already translating
Expand Down Expand Up @@ -575,7 +582,7 @@ fn dig_scalar_pointee<'tcx>(
let new_pointee = dig_scalar_pointee(cx, field, offset - field_offset);
match pointee {
Some(old_pointee) if old_pointee != new_pointee => {
cx.tcx.sess.fatal(format!(
cx.tcx.sess.psess.dcx.fatal(format!(
"dig_scalar_pointee: unsupported Pointer with different \
pointee types ({old_pointee:?} vs {new_pointee:?}) at offset {offset:?} in {layout:#?}"
));
Expand Down Expand Up @@ -723,7 +730,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
if i == 0 {
field_names.push(cx.sym.discriminant);
} else {
cx.tcx.sess.fatal("Variants::Multiple has multiple fields")
cx.tcx.sess.psess.dcx.fatal("Variants::Multiple has multiple fields")
}
};
}
Expand All @@ -744,7 +751,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
fn def_id_for_spirv_type_adt(layout: TyAndLayout<'_>) -> Option<DefId> {
match *layout.ty.kind() {
TyKind::Adt(def, _) => Some(def.did()),
TyKind::Foreign(def_id) | TyKind::Closure(def_id, _) | TyKind::Generator(def_id, ..) => {
TyKind::Foreign(def_id) | TyKind::Closure(def_id, _) | TyKind::Coroutine(def_id, ..) => {
Some(def_id)
}
_ => None,
Expand Down Expand Up @@ -779,8 +786,8 @@ impl fmt::Display for TyLayoutNameKey<'_> {
write!(f, "::{}", def.variants()[index].name)?;
}
}
if let (TyKind::Generator(_, _, _), Some(index)) = (self.ty.kind(), self.variant) {
write!(f, "::{}", GeneratorArgs::variant_name(index))?;
if let (TyKind::Coroutine(_, _,), Some(index)) = (self.ty.kind(), self.variant) {
write!(f, "::{}", CoroutineArgs::variant_name(index))?;
}
Ok(())
}
Expand All @@ -800,6 +807,7 @@ fn trans_intrinsic_type<'tcx>(
return Err(cx
.tcx
.sess
.psess.dcx
.err("#[spirv(generic_image)] type must have size 4"));
}

Expand Down Expand Up @@ -843,7 +851,7 @@ fn trans_intrinsic_type<'tcx>(
_ => {
return Err(cx
.tcx
.sess
.sess.psess.dcx
.span_err(span, "Invalid sampled type to `Image`."));
}
};
Expand All @@ -866,7 +874,7 @@ fn trans_intrinsic_type<'tcx>(
Some(v) => Ok(v),
None => Err(cx
.tcx
.sess
.sess.psess.dcx
.err(format!("Invalid value for Image const generic: {value}"))),
}
}
Expand All @@ -892,7 +900,7 @@ fn trans_intrinsic_type<'tcx>(
IntrinsicType::Sampler => {
// see SpirvType::sizeof
if ty.size != Size::from_bytes(4) {
return Err(cx.tcx.sess.err("#[spirv(sampler)] type must have size 4"));
return Err(cx.tcx.sess.psess.dcx.err("#[spirv(sampler)] type must have size 4"));
}
Ok(SpirvType::Sampler.def(span, cx))
}
Expand All @@ -905,7 +913,7 @@ fn trans_intrinsic_type<'tcx>(
if ty.size != Size::from_bytes(4) {
return Err(cx
.tcx
.sess
.sess.psess.dcx
.err("#[spirv(sampled_image)] type must have size 4"));
}

Expand All @@ -918,15 +926,15 @@ fn trans_intrinsic_type<'tcx>(
} else {
Err(cx
.tcx
.sess
.sess.psess.dcx
.err("#[spirv(sampled_image)] type must have a generic image type"))
}
}
IntrinsicType::RuntimeArray => {
if ty.size != Size::from_bytes(4) {
return Err(cx
.tcx
.sess
.sess.psess.dcx
.err("#[spirv(runtime_array)] type must have size 4"));
}

Expand All @@ -938,7 +946,7 @@ fn trans_intrinsic_type<'tcx>(
} else {
Err(cx
.tcx
.sess
.sess.psess.dcx
.err("#[spirv(runtime_array)] type must have a generic element type"))
}
}
Expand All @@ -953,12 +961,12 @@ fn trans_intrinsic_type<'tcx>(
if field_types.len() < 2 {
return Err(cx
.tcx
.sess
.sess.psess.dcx
.span_err(span, "#[spirv(matrix)] type must have at least two fields"));
}
let elem_type = field_types[0];
if !field_types.iter().all(|&ty| ty == elem_type) {
return Err(cx.tcx.sess.span_err(
return Err(cx.tcx.sess.psess.dcx.span_err(
span,
"#[spirv(matrix)] type fields must all be the same type",
));
Expand All @@ -968,10 +976,8 @@ fn trans_intrinsic_type<'tcx>(
ty => {
return Err(cx
.tcx
.sess
.struct_span_err(span, "#[spirv(matrix)] type fields must all be vectors")
.note(format!("field type is {}", ty.debug(elem_type, cx)))
.emit());
.sess.psess.dcx
.span_err(span, format!("#[spirv(matrix)] type fields must all be vectors, found {}", ty.debug(elem_type, cx))));
}
}

Expand Down
26 changes: 13 additions & 13 deletions crates/rustc_codegen_spirv/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ impl AggregatedSpirvAttributes {
pub fn parse<'tcx>(cx: &CodegenCx<'tcx>, attrs: &'tcx [Attribute]) -> Self {
let mut aggregated_attrs = Self::default();

// NOTE(eddyb) `delay_span_bug` ensures that if attribute checking fails
// NOTE(eddyb) `span_delayed_bug` ensures that if attribute checking fails
// to see an attribute error, it will cause an ICE instead.
for parse_attr_result in crate::symbols::parse_attrs_for_checking(&cx.sym, attrs) {
let (span, parsed_attr) = match parse_attr_result {
Ok(span_and_parsed_attr) => span_and_parsed_attr,
Err((span, msg)) => {
cx.tcx.sess.delay_span_bug(span, msg);
cx.tcx.sess.psess.dcx.span_delayed_bug(span, msg);
continue;
}
};
Expand All @@ -165,8 +165,8 @@ impl AggregatedSpirvAttributes {
category,
}) => {
cx.tcx
.sess
.delay_span_bug(span, format!("multiple {category} attributes"));
.sess.psess.dcx
.span_delayed_bug(span, format!("multiple {category} attributes"));
}
}
}
Expand Down Expand Up @@ -278,7 +278,7 @@ impl CheckSpirvAttrVisitor<'_> {
let (span, parsed_attr) = match parse_attr_result {
Ok(span_and_parsed_attr) => span_and_parsed_attr,
Err((span, msg)) => {
self.tcx.sess.span_err(span, msg);
self.tcx.sess.psess.dcx.span_err(span, msg);
continue;
}
};
Expand Down Expand Up @@ -317,13 +317,13 @@ impl CheckSpirvAttrVisitor<'_> {
| SpirvAttribute::InputAttachmentIndex(_)
| SpirvAttribute::SpecConstant(_) => match target {
Target::Param => {
let parent_hir_id = self.tcx.hir().parent_id(hir_id);
let mut parent_hir_id = self.tcx.hir().parent_id_iter(hir_id);
let parent_is_entry_point =
parse_attrs(self.tcx.hir().attrs(parent_hir_id))
parse_attrs(self.tcx.hir().attrs(parent_hir_id.next().unwrap()))
.filter_map(|r| r.ok())
.any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_)));
if !parent_is_entry_point {
self.tcx.sess.span_err(
self.tcx.sess.psess.dcx.span_err(
span,
"attribute is only valid on a parameter of an entry-point function",
);
Expand All @@ -346,7 +346,7 @@ impl CheckSpirvAttrVisitor<'_> {
};

if let Err(msg) = valid {
self.tcx.sess.span_err(
self.tcx.sess.psess.dcx.span_err(
span,
format!("`{storage_class:?}` storage class {msg}"),
);
Expand All @@ -367,7 +367,7 @@ impl CheckSpirvAttrVisitor<'_> {
};
match valid_target {
Err(Expected(expected_target)) => {
self.tcx.sess.span_err(
self.tcx.sess.psess.dcx.span_err(
span,
format!(
"attribute is only valid on a {expected_target}, not on a {target}"
Expand All @@ -381,13 +381,13 @@ impl CheckSpirvAttrVisitor<'_> {
category,
}) => {
self.tcx
.sess
.sess.psess.dcx
.struct_span_err(
span,
format!("only one {category} attribute is allowed on a {target}"),
)
.span_note(prev_span, format!("previous {category} attribute"))
.emit();
;
}
},
}
Expand All @@ -397,7 +397,7 @@ impl CheckSpirvAttrVisitor<'_> {
// so we can perform further checks, emit warnings, etc.

if let Some(block_attr) = aggregated_attrs.block {
self.tcx.sess.span_warn(
self.tcx.sess.psess.dcx.span_warn(
block_attr.span,
"#[spirv(block)] is no longer needed and should be removed",
);
Expand Down
Loading