rustup: update to nightly-2023-05-27.

This commit is contained in:
Eduard-Mihai Burtescu 2023-06-06 01:08:13 +03:00 committed by Eduard-Mihai Burtescu
parent 188aba26fc
commit dbada91cb7
39 changed files with 195 additions and 135 deletions

View File

@ -29,6 +29,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed 🛠
- [PR#1071](https://github.com/EmbarkStudios/rust-gpu/pull/1071) updated toolchain to `nightly-2023-05-27`
## [0.8.0] ## [0.8.0]
### Added ⭐ ### Added ⭐

View File

@ -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 :/ /// `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 = include_str!("../../rust-toolchain");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2023-04-15" channel = "nightly-2023-05-27"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"] components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 84dd17b56a931a631a23dfd5ef2018fd3ef49108"#; # commit_hash = 1a5f8bce74ee432f7cc3aa131bc3d6920e06de10"#;
fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> { fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));

View File

@ -7,9 +7,9 @@ use crate::spirv_type::SpirvType;
use rspirv::spirv::{StorageClass, Word}; use rspirv::spirv::{StorageClass, Word};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_index::vec::Idx; use rustc_index::Idx;
use rustc_middle::query::{ExternProviders, Providers};
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
use rustc_middle::ty::query::{ExternProviders, Providers};
use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::subst::SubstsRef;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, Const, FloatTy, GeneratorSubsts, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, self, Const, FloatTy, GeneratorSubsts, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind,
@ -972,7 +972,7 @@ fn trans_intrinsic_type<'tcx>(
.tcx .tcx
.sess .sess
.struct_span_err(span, "#[spirv(matrix)] type fields must all be vectors") .struct_span_err(span, "#[spirv(matrix)] type fields must all be vectors")
.note(&format!("field type is {}", ty.debug(elem_type, cx))) .note(format!("field type is {}", ty.debug(elem_type, cx)))
.emit()); .emit());
} }
} }

View File

@ -11,7 +11,7 @@ use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{HirId, MethodKind, Target, CRATE_HIR_ID}; use rustc_hir::{HirId, MethodKind, Target, CRATE_HIR_ID};
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::ty::query::Providers; use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use std::rc::Rc; use std::rc::Rc;
@ -369,9 +369,9 @@ impl CheckSpirvAttrVisitor<'_> {
.sess .sess
.struct_span_err( .struct_span_err(
span, span,
&format!("only one {category} attribute is allowed on a {target}"), format!("only one {category} attribute is allowed on a {target}"),
) )
.span_note(prev_span, &format!("previous {category} attribute")) .span_note(prev_span, format!("previous {category} attribute"))
.emit(); .emit();
} }
}, },

View File

@ -18,6 +18,7 @@ use rustc_codegen_ssa::traits::{
use rustc_codegen_ssa::MemFlags; use rustc_codegen_ssa::MemFlags;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_span::Span; use rustc_span::Span;
use rustc_target::abi::call::FnAbi; use rustc_target::abi::call::FnAbi;
@ -760,9 +761,19 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
then_llbb: Self::BasicBlock, then_llbb: Self::BasicBlock,
else_llbb: Self::BasicBlock, else_llbb: Self::BasicBlock,
) { ) {
self.emit() let cond = cond.def(self);
.branch_conditional(cond.def(self), then_llbb, else_llbb, empty())
.unwrap(); // HACK(eddyb) constant-fold branches early on, as the `core` library is
// starting to get a lot of `if cfg!(debug_assertions)` added to it.
match self.builder.lookup_const_by_id(cond) {
Some(SpirvConst::Bool(true)) => self.br(then_llbb),
Some(SpirvConst::Bool(false)) => self.br(else_llbb),
_ => {
self.emit()
.branch_conditional(cond, then_llbb, else_llbb, empty())
.unwrap();
}
}
} }
fn switch( fn switch(
@ -840,6 +851,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
fn invoke( fn invoke(
&mut self, &mut self,
llty: Self::Type, llty: Self::Type,
fn_attrs: Option<&CodegenFnAttrs>,
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
llfn: Self::Value, llfn: Self::Value,
args: &[Self::Value], args: &[Self::Value],
@ -848,7 +860,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
funclet: Option<&Self::Funclet>, funclet: Option<&Self::Funclet>,
) -> Self::Value { ) -> Self::Value {
// Exceptions don't exist, jump directly to then block // Exceptions don't exist, jump directly to then block
let result = self.call(llty, fn_abi, llfn, args, funclet); let result = self.call(llty, fn_attrs, fn_abi, llfn, args, funclet);
self.emit().branch(then).unwrap(); self.emit().branch(then).unwrap();
result result
} }
@ -2095,6 +2107,10 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
todo!() todo!()
} }
fn filter_landing_pad(&mut self, _pers_fn: Self::Value) -> (Self::Value, Self::Value) {
todo!()
}
fn resume(&mut self, _exn0: Self::Value, _exn1: Self::Value) { fn resume(&mut self, _exn0: Self::Value, _exn1: Self::Value) {
todo!() todo!()
} }
@ -2309,6 +2325,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
fn call( fn call(
&mut self, &mut self,
callee_ty: Self::Type, callee_ty: Self::Type,
_fn_attrs: Option<&CodegenFnAttrs>,
_fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, _fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
callee: Self::Value, callee: Self::Value,
args: &[Self::Value], args: &[Self::Value],

View File

@ -15,7 +15,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.debug_type(original_type) self.debug_type(original_type)
)); ));
if original_type != invalid_type { if original_type != invalid_type {
err.note(&format!( err.note(format!(
"due to containing type {}", "due to containing type {}",
self.debug_type(invalid_type) self.debug_type(invalid_type)
)); ));
@ -210,7 +210,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.debug_type(original_type) self.debug_type(original_type)
)); ));
if original_type != value.ty { if original_type != value.ty {
err.note(&format!("due to containing type {}", value.ty)); err.note(format!("due to containing type {}", value.ty));
} }
Err(err.emit()) Err(err.emit())
} }

View File

@ -438,16 +438,4 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for Builder<'_, 'tcx> {
} }
} }
impl<'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'tcx> { impl<'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'tcx> {}
fn set_type_metadata(&self, _function: Self::Function, _typeid: String) {
// ignore
}
fn typeid_metadata(&self, _typeid: String) -> Self::Value {
todo!()
}
fn set_kcfi_type_metadata(&self, _function: Self::Function, _typeid: u32) {
// ignore
}
}

View File

@ -306,10 +306,10 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
let storage_class = inst.operands[0].unwrap_storage_class(); let storage_class = inst.operands[0].unwrap_storage_class();
if storage_class != StorageClass::Generic { if storage_class != StorageClass::Generic {
self.struct_err("TypePointer in asm! requires `Generic` storage class") self.struct_err("TypePointer in asm! requires `Generic` storage class")
.note(&format!( .note(format!(
"`{storage_class:?}` storage class was specified" "`{storage_class:?}` storage class was specified"
)) ))
.help(&format!( .help(format!(
"the storage class will be inferred automatically (e.g. to `{storage_class:?}`)" "the storage class will be inferred automatically (e.g. to `{storage_class:?}`)"
)) ))
.emit(); .emit();

View File

@ -152,7 +152,7 @@ impl SpirvValue {
cx.tcx cx.tcx
.sess .sess
.struct_span_err(span, "Can't use type as a value") .struct_span_err(span, "Can't use type as a value")
.note(&format!("Type: *{}", cx.debug_type(id))) .note(format!("Type: *{}", cx.debug_type(id)))
.emit(); .emit();
id id

View File

@ -36,7 +36,7 @@ fn attrs_to_spirv(attrs: &CodegenFnAttrs) -> FunctionControl {
impl<'tcx> CodegenCx<'tcx> { impl<'tcx> CodegenCx<'tcx> {
/// Returns a function if it already exists, or declares a header if it doesn't. /// Returns a function if it already exists, or declares a header if it doesn't.
pub fn get_fn_ext(&self, instance: Instance<'tcx>) -> SpirvValue { pub fn get_fn_ext(&self, instance: Instance<'tcx>) -> SpirvValue {
assert!(!instance.substs.needs_infer()); assert!(!instance.substs.has_infer());
assert!(!instance.substs.has_escaping_bound_vars()); assert!(!instance.substs.has_escaping_bound_vars());
if let Some(&func) = self.instances.borrow().get(&instance) { if let Some(&func) = self.instances.borrow().get(&instance) {

View File

@ -191,6 +191,7 @@ impl<'tcx> CodegenCx<'tcx> {
bx.set_span(span); bx.set_span(span);
bx.call( bx.call(
entry_func.ty, entry_func.ty,
None,
Some(entry_fn_abi), Some(entry_fn_abi),
entry_func, entry_func,
&call_args, &call_args,
@ -317,7 +318,7 @@ impl<'tcx> CodegenCx<'tcx> {
) )
.span_help( .span_help(
storage_class_attr.span, storage_class_attr.span,
&format!( format!(
"remove storage class attribute to use `{deduced:?}` as storage class" "remove storage class attribute to use `{deduced:?}` as storage class"
), ),
) )

View File

@ -103,8 +103,9 @@ use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility}; use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
use rustc_middle::mir::pretty::write_mir_pretty; use rustc_middle::mir::pretty::write_mir_pretty;
use rustc_middle::query;
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, query, Instance, InstanceDef, TyCtxt}; use rustc_middle::ty::{self, Instance, InstanceDef, TyCtxt};
use rustc_session::config::{self, OutputFilenames, OutputType}; use rustc_session::config::{self, OutputFilenames, OutputType};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
@ -137,7 +138,7 @@ fn is_blocklisted_fn<'tcx>(
instance: Instance<'tcx>, instance: Instance<'tcx>,
) -> bool { ) -> bool {
// TODO: These sometimes have a constant value of an enum variant with a hole // TODO: These sometimes have a constant value of an enum variant with a hole
if let InstanceDef::Item(def) = instance.def { if let InstanceDef::Item(def_id) = instance.def {
if let Some(debug_trait_def_id) = tcx.get_diagnostic_item(sym::Debug) { if let Some(debug_trait_def_id) = tcx.get_diagnostic_item(sym::Debug) {
// Helper for detecting `<_ as core::fmt::Debug>::fmt` (in impls). // Helper for detecting `<_ as core::fmt::Debug>::fmt` (in impls).
let is_debug_fmt_method = |def_id| match tcx.opt_associated_item(def_id) { let is_debug_fmt_method = |def_id| match tcx.opt_associated_item(def_id) {
@ -153,12 +154,12 @@ fn is_blocklisted_fn<'tcx>(
_ => false, _ => false,
}; };
if is_debug_fmt_method(def.did) { if is_debug_fmt_method(def_id) {
return true; return true;
} }
if tcx.opt_item_ident(def.did).map(|i| i.name) == Some(sym.fmt_decimal) { if tcx.opt_item_ident(def_id).map(|i| i.name) == Some(sym.fmt_decimal) {
if let Some(parent_def_id) = tcx.opt_parent(def.did) { if let Some(parent_def_id) = tcx.opt_parent(def_id) {
if is_debug_fmt_method(parent_def_id) { if is_debug_fmt_method(parent_def_id) {
return true; return true;
} }
@ -491,47 +492,17 @@ impl Drop for DumpModuleOnPanic<'_, '_, '_> {
/// This is the entrypoint for a hot plugged `rustc_codegen_spirv` /// This is the entrypoint for a hot plugged `rustc_codegen_spirv`
#[no_mangle] #[no_mangle]
pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> { pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
// Override rustc's panic hook with our own to override the ICE error // Tweak rustc's default ICE panic hook, to direct people to `rust-gpu`.
// message, and direct people to `rust-gpu`. rustc_driver::install_ice_hook(
let _rustc_hook = std::panic::take_hook(); "https://github.com/EmbarkStudios/rust-gpu/issues/new",
let default_hook = std::panic::take_hook(); |handler| {
{ handler.note_without_error(concat!(
// NOTE(eddyb) the reason we can get access to the default panic hook, "`rust-gpu` version `",
// is that `std::panic::take_hook` has this phrase in its documentation: env!("CARGO_PKG_VERSION"),
// "`"
// > If no custom hook is registered, the default hook will be returned. ));
// },
// But just in case (races with other threads?), we can do it a few more );
// times, and require that we get the same "boxed" ZST every time.
let more_hooks = [
std::panic::take_hook(),
std::panic::take_hook(),
std::panic::take_hook(),
std::panic::take_hook(),
];
assert_eq!(
std::mem::size_of_val(&*default_hook),
0,
"failed to acquire default panic hook using `std::panic::take_hook`, \
or default panic hook not a ZST anymore"
);
#[allow(clippy::vtable_address_comparisons)]
for other_hook in more_hooks {
assert!(
std::ptr::eq(&*default_hook, &*other_hook),
"failed to acquire default panic hook using `std::panic::take_hook`, \
or `std::panic::set_hook` was used on another thread"
);
}
}
std::panic::set_hook(Box::new(move |panic_info| {
default_hook(panic_info);
rustc_driver::report_ice(
panic_info,
"https://github.com/EmbarkStudios/rust-gpu/issues/new",
);
eprintln!("note: `rust-gpu` version {}\n", env!("CARGO_PKG_VERSION"));
}));
Box::new(SpirvCodegenBackend) Box::new(SpirvCodegenBackend)
} }

View File

@ -274,8 +274,8 @@ fn post_link_single_module(
if let Err(e) = std::fs::write(out_filename, spirv_tools::binary::from_binary(&spv_binary)) if let Err(e) = std::fs::write(out_filename, spirv_tools::binary::from_binary(&spv_binary))
{ {
let mut err = sess.struct_err("failed to serialize spirv-binary to disk"); let mut err = sess.struct_err("failed to serialize spirv-binary to disk");
err.note(&format!("module `{}`", out_filename.display())); err.note(format!("module `{}`", out_filename.display()));
err.note(&format!("I/O error: {e:#}")); err.note(format!("I/O error: {e:#}"));
err.emit(); err.emit();
} }
@ -324,14 +324,14 @@ fn do_spirv_opt(
Level::Fatal | Level::InternalError => { Level::Fatal | Level::InternalError => {
// FIXME(eddyb) this was `struct_fatal` but that doesn't seem // FIXME(eddyb) this was `struct_fatal` but that doesn't seem
// necessary and also lacks `.forget_guarantee()`. // necessary and also lacks `.forget_guarantee()`.
sess.struct_err(&msg.message).forget_guarantee() sess.struct_err(msg.message).forget_guarantee()
} }
Level::Error => sess.struct_err(&msg.message).forget_guarantee(), Level::Error => sess.struct_err(msg.message).forget_guarantee(),
Level::Warning => sess.struct_warn(&msg.message), Level::Warning => sess.struct_warn(msg.message),
Level::Info | Level::Debug => sess.struct_note_without_error(&msg.message), Level::Info | Level::Debug => sess.struct_note_without_error(msg.message),
}; };
err.note(&format!("module `{}`", filename.display())); err.note(format!("module `{}`", filename.display()));
err.emit(); err.emit();
}, },
Some(options), Some(options),
@ -341,9 +341,9 @@ fn do_spirv_opt(
Ok(spirv_tools::binary::Binary::OwnedU32(words)) => words, Ok(spirv_tools::binary::Binary::OwnedU32(words)) => words,
Ok(binary) => binary.as_words().to_vec(), Ok(binary) => binary.as_words().to_vec(),
Err(e) => { Err(e) => {
let mut err = sess.struct_warn(&e.to_string()); let mut err = sess.struct_warn(e.to_string());
err.note("spirv-opt failed, leaving as unoptimized"); err.note("spirv-opt failed, leaving as unoptimized");
err.note(&format!("module `{}`", filename.display())); err.note(format!("module `{}`", filename.display()));
err.emit(); err.emit();
spv_binary spv_binary
} }
@ -361,9 +361,9 @@ fn do_spirv_val(
let validator = val::create(sess.target.options.env.parse().ok()); let validator = val::create(sess.target.options.env.parse().ok());
if let Err(e) = validator.validate(spv_binary, Some(options)) { if let Err(e) = validator.validate(spv_binary, Some(options)) {
let mut err = sess.struct_err(&e.to_string()); let mut err = sess.struct_err(e.to_string());
err.note("spirv-val failed"); err.note("spirv-val failed");
err.note(&format!("module `{}`", filename.display())); err.note(format!("module `{}`", filename.display()));
err.emit(); err.emit();
} }
} }

View File

@ -184,12 +184,12 @@ fn check_tys_equal(
result result
} }
Err(sess Err(sess
.struct_err(&format!("Types mismatch for {name:?}")) .struct_err(format!("Types mismatch for {name:?}"))
.note(&format!( .note(format!(
"import type: {}", "import type: {}",
format_ty_(&ty_defs, import_type) format_ty_(&ty_defs, import_type)
)) ))
.note(&format!( .note(format!(
"export type: {}", "export type: {}",
format_ty_(&ty_defs, export_type) format_ty_(&ty_defs, export_type)
)) ))

View File

@ -225,6 +225,17 @@ pub fn link(
} }
if opts.early_report_zombies { if opts.early_report_zombies {
// HACK(eddyb) `report_and_remove_zombies` is bad at determining whether
// some things are dead (such as whole blocks), and there's no reason to
// *not* run DCE, given SPIR-T exists and makes DCE mandatory, but we're
// still only going to do the minimum necessary ("block ordering").
{
let _timer = sess.timer("link_block_ordering_pass-before-report_and_remove_zombies");
for func in &mut output.functions {
simple_passes::block_ordering_pass(func);
}
}
let _timer = sess.timer("link_report_and_remove_zombies"); let _timer = sess.timer("link_report_and_remove_zombies");
zombies::report_and_remove_zombies(sess, opts, &mut output)?; zombies::report_and_remove_zombies(sess, opts, &mut output)?;
} }

View File

@ -245,11 +245,11 @@ pub fn check_fragment_insts(sess: &Session, module: &Module) -> Result<()> {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join("\n"); .join("\n");
any_err = Some( any_err = Some(
sess.struct_err(&format!( sess.struct_err(format!(
"{} cannot be used outside a fragment shader", "{} cannot be used outside a fragment shader",
inst.class.opname inst.class.opname
)) ))
.note(&note) .note(note)
.emit(), .emit(),
); );
} }

View File

@ -425,7 +425,7 @@ impl DiagnosticReporter<'_> {
self.span_regen.spirt_attrs_to_rustc_span(self.cx, attrs) self.span_regen.spirt_attrs_to_rustc_span(self.cx, attrs)
}) })
.unwrap_or(DUMMY_SP); .unwrap_or(DUMMY_SP);
let mut err = self.sess.struct_span_err(def_span, reason); let mut err = self.sess.struct_span_err(def_span, reason.to_string());
for use_origin in use_stack_for_def.iter().rev() { for use_origin in use_stack_for_def.iter().rev() {
use_origin.note(self.cx, &mut self.span_regen, &mut err); use_origin.note(self.cx, &mut self.span_regen, &mut err);
} }

View File

@ -115,6 +115,7 @@ fn link_with_linker_opts(
Default::default(), Default::default(),
None, None,
None, None,
rustc_interface::util::rustc_version_str().unwrap_or("unknown"),
); );
// HACK(eddyb) inject `write_diags` into `sess`, to work around // HACK(eddyb) inject `write_diags` into `sess`, to work around

View File

@ -292,7 +292,10 @@ impl<'a> ZombieReporter<'a> {
match zombie.kind { match zombie.kind {
ZombieKind::Leaf => { ZombieKind::Leaf => {
let reason = self.span_regen.zombie_for_id(zombie.id).unwrap().reason; let reason = self.span_regen.zombie_for_id(zombie.id).unwrap().reason;
errors_keyed_by_leaf_id.insert(zombie.id, self.sess.struct_span_err(span, reason)); errors_keyed_by_leaf_id.insert(
zombie.id,
self.sess.struct_span_err(span, reason.to_string()),
);
} }
ZombieKind::Uses(zombie_uses) => { ZombieKind::Uses(zombie_uses) => {
for zombie_use in zombie_uses { for zombie_use in zombie_uses {

View File

@ -2,7 +2,7 @@
<!-- markdownlint-disable-file MD033 --> <!-- markdownlint-disable-file MD033 -->
# `spirv-builder` # `spirv-builder`
![Rust version](https://img.shields.io/badge/rust-nightly--2023--04--15-purple.svg) ![Rust version](https://img.shields.io/badge/rust-nightly--2023--05--27-purple.svg)
This crate gives you `SpirvBuilder`, a tool to build shaders using [rust-gpu][rustgpu]. This crate gives you `SpirvBuilder`, a tool to build shaders using [rust-gpu][rustgpu].
@ -31,7 +31,7 @@ const SHADER: &[u8] = include_bytes!(env!("my_shaders.spv"));
Because of its nature, `rustc_codegen_spirv`, and therefore `spirv-builder` by extension, require the use of a very specific nightly toolchain of Rust. Because of its nature, `rustc_codegen_spirv`, and therefore `spirv-builder` by extension, require the use of a very specific nightly toolchain of Rust.
**The current toolchain is: `nightly-2023-04-15`.** **The current toolchain is: `nightly-2023-05-27`.**
Toolchains for previous versions of `spirv-builder`: Toolchains for previous versions of `spirv-builder`:

View File

@ -440,6 +440,10 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
"-Csymbol-mangling-version=v0".to_string(), "-Csymbol-mangling-version=v0".to_string(),
"-Zcrate-attr=feature(register_tool)".to_string(), "-Zcrate-attr=feature(register_tool)".to_string(),
"-Zcrate-attr=register_tool(rust_gpu)".to_string(), "-Zcrate-attr=register_tool(rust_gpu)".to_string(),
// HACK(eddyb) this is the same configuration that we test with, and
// ensures no unwanted surprises from e.g. `core` debug assertions.
"-Coverflow-checks=off".to_string(),
"-Cdebug-assertions=off".to_string(),
]; ];
// Wrapper for `env::var` that appropriately informs Cargo of the dependency. // Wrapper for `env::var` that appropriately informs Cargo of the dependency.

View File

@ -89,6 +89,7 @@
#![warn(missing_docs)] #![warn(missing_docs)]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
/// Public re-export of the `spirv-std-macros` crate.
#[macro_use] #[macro_use]
pub extern crate spirv_std_macros as macros; pub extern crate spirv_std_macros as macros;
pub use macros::spirv; pub use macros::spirv;

View File

@ -1,7 +1,7 @@
[toolchain] [toolchain]
channel = "nightly-2023-04-15" channel = "nightly-2023-05-27"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"] components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 84dd17b56a931a631a23dfd5ef2018fd3ef49108 # commit_hash = 1a5f8bce74ee432f7cc3aa131bc3d6920e06de10
# Whenever changing the nightly channel, update the commit hash above, and make # Whenever changing the nightly channel, update the commit hash above, and make
# sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also.

View File

@ -75,9 +75,9 @@ help: the return type of this call is `u32` due to the type of the argument pass
| | | |
| this argument influences the return type of `spirv_std` | this argument influences the return type of `spirv_std`
note: function defined here note: function defined here
--> $SPIRV_STD_SRC/lib.rs:134:8 --> $SPIRV_STD_SRC/lib.rs:135:8
| |
134 | pub fn debug_printf_assert_is_type<T>(ty: T) -> T { 135 | pub fn debug_printf_assert_is_type<T>(ty: T) -> T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info)
help: change the type of the numeric literal from `u32` to `f32` help: change the type of the numeric literal from `u32` to `f32`
@ -102,9 +102,9 @@ help: the return type of this call is `f32` due to the type of the argument pass
| | | |
| this argument influences the return type of `spirv_std` | this argument influences the return type of `spirv_std`
note: function defined here note: function defined here
--> $SPIRV_STD_SRC/lib.rs:134:8 --> $SPIRV_STD_SRC/lib.rs:135:8
| |
134 | pub fn debug_printf_assert_is_type<T>(ty: T) -> T { 135 | pub fn debug_printf_assert_is_type<T>(ty: T) -> T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info)
help: change the type of the numeric literal from `f32` to `u32` help: change the type of the numeric literal from `f32` to `u32`
@ -132,9 +132,12 @@ error[E0277]: the trait bound `{float}: Vector<f32, 2>` is not satisfied
<UVec3 as Vector<u32, 3>> <UVec3 as Vector<u32, 3>>
and 5 others and 5 others
note: required by a bound in `debug_printf_assert_is_vector` note: required by a bound in `debug_printf_assert_is_vector`
--> $SPIRV_STD_SRC/lib.rs:141:8 --> $SPIRV_STD_SRC/lib.rs:142:8
| |
141 | V: crate::vector::Vector<TY, SIZE>, 140 | pub fn debug_printf_assert_is_vector<
| ----------------------------- required by a bound in this function
141 | TY: crate::scalar::Scalar,
142 | V: crate::vector::Vector<TY, SIZE>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `debug_printf_assert_is_vector` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `debug_printf_assert_is_vector`
error[E0308]: mismatched types error[E0308]: mismatched types
@ -154,9 +157,9 @@ help: the return type of this call is `Vec2` due to the type of the argument pas
| | | |
| this argument influences the return type of `spirv_std` | this argument influences the return type of `spirv_std`
note: function defined here note: function defined here
--> $SPIRV_STD_SRC/lib.rs:134:8 --> $SPIRV_STD_SRC/lib.rs:135:8
| |
134 | pub fn debug_printf_assert_is_type<T>(ty: T) -> T { 135 | pub fn debug_printf_assert_is_type<T>(ty: T) -> T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -3,11 +3,30 @@
OpLine %5 13 12 OpLine %5 13 12
%6 = OpLoad %7 %8 %6 = OpLoad %7 %8
OpLine %5 14 4 OpLine %5 14 4
%9 = OpCompositeExtract %10 %6 0 %9 = OpULessThan %10 %11 %12
%11 = OpFAdd %10 %9 %12
%13 = OpCompositeInsert %7 %11 %6 0
OpLine %5 15 4
OpStore %14 %13
OpNoLine OpNoLine
OpSelectionMerge %13 None
OpBranchConditional %9 %14 %15
%14 = OpLabel
OpLine %5 14 4
%16 = OpCompositeExtract %17 %6 0
%18 = OpFAdd %17 %16 %19
%20 = OpCompositeInsert %7 %18 %6 0
OpLine %5 15 4
OpStore %21 %20
OpNoLine
OpBranch %13
%15 = OpLabel
OpBranch %22
%22 = OpLabel
OpLoopMerge %23 %24 None
OpBranch %25
%25 = OpLabel
OpBranch %24
%24 = OpLabel
OpBranch %22
%23 = OpLabel
OpBranch %13
%13 = OpLabel
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -3,11 +3,30 @@
OpLine %5 11 12 OpLine %5 11 12
%6 = OpLoad %7 %8 %6 = OpLoad %7 %8
OpLine %5 12 4 OpLine %5 12 4
%9 = OpCompositeExtract %10 %6 0 %9 = OpULessThan %10 %11 %12
%11 = OpFAdd %10 %9 %12
%13 = OpCompositeInsert %7 %11 %6 0
OpLine %5 13 4
OpStore %14 %13
OpNoLine OpNoLine
OpSelectionMerge %13 None
OpBranchConditional %9 %14 %15
%14 = OpLabel
OpLine %5 12 4
%16 = OpCompositeExtract %17 %6 0
%18 = OpFAdd %17 %16 %19
%20 = OpCompositeInsert %7 %18 %6 0
OpLine %5 13 4
OpStore %21 %20
OpNoLine
OpBranch %13
%15 = OpLabel
OpBranch %22
%22 = OpLabel
OpLoopMerge %23 %24 None
OpBranch %25
%25 = OpLabel
OpBranch %24
%24 = OpLabel
OpBranch %22
%23 = OpLabel
OpBranch %13
%13 = OpLabel
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,13 +1,13 @@
error: cannot memcpy dynamically sized data error: cannot memcpy dynamically sized data
--> $CORE_SRC/intrinsics.rs:2724:9 --> $CORE_SRC/intrinsics.rs:2760:9
| |
2724 | copy(src, dst, count) 2760 | copy(src, dst, count)
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
| |
note: used from within `core::intrinsics::copy::<f32>` note: used from within `core::intrinsics::copy::<f32>`
--> $CORE_SRC/intrinsics.rs:2710:21 --> $CORE_SRC/intrinsics.rs:2746:21
| |
2710 | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) { 2746 | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
| ^^^^ | ^^^^
note: called by `ptr_copy::copy_via_raw_ptr` note: called by `ptr_copy::copy_via_raw_ptr`
--> $DIR/ptr_copy.rs:28:18 --> $DIR/ptr_copy.rs:28:18

View File

@ -2,7 +2,7 @@
%4 = OpFunctionParameter %5 %4 = OpFunctionParameter %5
%6 = OpFunctionParameter %5 %6 = OpFunctionParameter %5
%7 = OpLabel %7 = OpLabel
OpLine %8 1188 12 OpLine %8 1178 8
%9 = OpLoad %10 %4 %9 = OpLoad %10 %4
OpLine %11 7 13 OpLine %11 7 13
OpStore %6 %9 OpStore %6 %9

View File

@ -2,7 +2,7 @@
%4 = OpFunctionParameter %5 %4 = OpFunctionParameter %5
%6 = OpFunctionParameter %5 %6 = OpFunctionParameter %5
%7 = OpLabel %7 = OpLabel
OpLine %8 1188 12 OpLine %8 1178 8
%9 = OpLoad %10 %4 %9 = OpLoad %10 %4
OpLine %11 7 13 OpLine %11 7 13
OpStore %6 %9 OpStore %6 %9

View File

@ -4,7 +4,7 @@
%7 = OpLabel %7 = OpLabel
OpLine %8 7 35 OpLine %8 7 35
%9 = OpLoad %10 %4 %9 = OpLoad %10 %4
OpLine %11 1386 8 OpLine %11 1376 8
OpStore %6 %9 OpStore %6 %9
OpNoLine OpNoLine
OpReturn OpReturn

View File

@ -4,7 +4,7 @@
%7 = OpLabel %7 = OpLabel
OpLine %8 7 37 OpLine %8 7 37
%9 = OpLoad %10 %4 %9 = OpLoad %10 %4
OpLine %11 1386 8 OpLine %11 1376 8
OpStore %6 %9 OpStore %6 %9
OpNoLine OpNoLine
OpReturn OpReturn

View File

@ -11,6 +11,9 @@ error[E0277]: the trait bound `Image<f32, 0, 2, 0, 0, 1, 0, 4>: HasGather` is no
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather` note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
--> $SPIRV_STD_SRC/image.rs:197:15 --> $SPIRV_STD_SRC/image.rs:197:15
| |
190 | pub fn gather<F>(
| ------ required by a bound in this associated function
...
197 | Self: HasGather, 197 | Self: HasGather,
| ^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather` | ^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
@ -27,6 +30,9 @@ error[E0277]: the trait bound `Image<f32, 2, 2, 0, 0, 1, 0, 4>: HasGather` is no
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather` note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
--> $SPIRV_STD_SRC/image.rs:197:15 --> $SPIRV_STD_SRC/image.rs:197:15
| |
190 | pub fn gather<F>(
| ------ required by a bound in this associated function
...
197 | Self: HasGather, 197 | Self: HasGather,
| ^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather` | ^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`

View File

@ -12,6 +12,9 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQueryLevels`
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels` note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels`
--> $SPIRV_STD_SRC/image.rs:881:15 --> $SPIRV_STD_SRC/image.rs:881:15
| |
879 | pub fn query_levels(&self) -> u32
| ------------ required by a bound in this associated function
880 | where
881 | Self: HasQueryLevels, 881 | Self: HasQueryLevels,
| ^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels` | ^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels`

View File

@ -12,6 +12,9 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQueryLevels`
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod` note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod`
--> $SPIRV_STD_SRC/image.rs:907:15 --> $SPIRV_STD_SRC/image.rs:907:15
| |
901 | pub fn query_lod(
| --------- required by a bound in this associated function
...
907 | Self: HasQueryLevels, 907 | Self: HasQueryLevels,
| ^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod` | ^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod`

View File

@ -17,6 +17,9 @@ error[E0277]: the trait bound `Image<f32, 1, 2, 0, 0, 1, 0, 4>: HasQuerySize` is
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size` note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size`
--> $SPIRV_STD_SRC/image.rs:938:15 --> $SPIRV_STD_SRC/image.rs:938:15
| |
936 | pub fn query_size<Size: ImageCoordinate<u32, DIM, ARRAYED> + Default>(&self) -> Size
| ---------- required by a bound in this associated function
937 | where
938 | Self: HasQuerySize, 938 | Self: HasQuerySize,
| ^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size` | ^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size`

View File

@ -12,6 +12,9 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQuerySizeLod`
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod` note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod`
--> $SPIRV_STD_SRC/image.rs:982:15 --> $SPIRV_STD_SRC/image.rs:982:15
| |
977 | pub fn query_size_lod<Size: ImageCoordinate<u32, DIM, ARRAYED> + Default>(
| -------------- required by a bound in this associated function
...
982 | Self: HasQuerySizeLod, 982 | Self: HasQuerySizeLod,
| ^^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod` | ^^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod`

View File

@ -8,9 +8,10 @@
use spirv_std::spirv; use spirv_std::spirv;
use core::ptr::Unique; use core::ptr::Unique;
const POINTER: Unique<[u8; 4]> = Unique::<[u8; 4]>::dangling(); const POINTER: Unique<[u8; 4]> = Unique::<[u8; 4]>::dangling();
#[spirv(fragment)] #[spirv(fragment)]
pub fn main() { pub fn main(output: &mut Unique<[u8; 4]>) {
let _pointer = POINTER; *output = POINTER;
} }

View File

@ -1,14 +1,14 @@
error: pointer has non-null integer address error: pointer has non-null integer address
| |
note: used from within `allocate_const_scalar::main` note: used from within `allocate_const_scalar::main`
--> $DIR/allocate_const_scalar.rs:15:20 --> $DIR/allocate_const_scalar.rs:16:5
| |
15 | let _pointer = POINTER; 16 | *output = POINTER;
| ^^^^^^^ | ^^^^^^^^^^^^^^^^^
note: called by `main` note: called by `main`
--> $DIR/allocate_const_scalar.rs:14:8 --> $DIR/allocate_const_scalar.rs:15:8
| |
14 | pub fn main() { 15 | pub fn main(output: &mut Unique<[u8; 4]>) {
| ^^^^ | ^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -3,9 +3,9 @@
OpLine %5 13 11 OpLine %5 13 11
%6 = OpCompositeInsert %7 %8 %9 0 %6 = OpCompositeInsert %7 %8 %9 0
%10 = OpCompositeExtract %11 %6 1 %10 = OpCompositeExtract %11 %6 1
OpLine %12 975 14 OpLine %12 956 14
%13 = OpBitcast %14 %8 %13 = OpBitcast %14 %8
OpLine %12 975 8 OpLine %12 956 8
%15 = OpIEqual %16 %13 %17 %15 = OpIEqual %16 %13 %17
OpNoLine OpNoLine
OpSelectionMerge %18 None OpSelectionMerge %18 None