Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed 🛠️

- Updated toolchain to `nightly-2022-10-15`
- Applied workspace inheritance to Cargo.toml files

### Removed 🔥
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-2022-10-01"
channel = "nightly-2022-10-15"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6"#;
# commit_hash = bf15a9e5263fcea065a7ae9c179b2d24c2deb670"#;

fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>)
Target::Method(MethodKind::Inherent)
}
}
hir::ImplItemKind::TyAlias(..) => Target::AssocTy,
hir::ImplItemKind::Type(..) => Target::AssocTy,
}
}

Expand Down
13 changes: 5 additions & 8 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use rustc_codegen_ssa::MemFlags;
use rustc_middle::bug;
use rustc_middle::ty::Ty;
use rustc_span::Span;
use rustc_target::abi::call::FnAbi;
use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange};
use std::convert::TryInto;
use std::iter::{self, empty};
Expand Down Expand Up @@ -795,14 +796,15 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
fn invoke(
&mut self,
llty: Self::Type,
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
llfn: Self::Value,
args: &[Self::Value],
then: Self::BasicBlock,
_catch: Self::BasicBlock,
funclet: Option<&Self::Funclet>,
) -> Self::Value {
// Exceptions don't exist, jump directly to then block
let result = self.call(llty, llfn, args, funclet);
let result = self.call(llty, fn_abi, llfn, args, funclet);
self.emit().branch(then).unwrap();
result
}
Expand Down Expand Up @@ -1009,13 +1011,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
result_id.with_type(ptr_ty)
}

fn dynamic_alloca(&mut self, ty: Self::Type, align: Align) -> Self::Value {
let result = self.alloca(ty, align);
self.err("dynamic alloca is not supported yet");
result
}

fn array_alloca(&mut self, _ty: Self::Type, _len: Self::Value, _align: Align) -> Self::Value {
fn byte_array_alloca(&mut self, _len: Self::Value, _align: Align) -> Self::Value {
self.fatal("array alloca not supported yet")
}

Expand Down Expand Up @@ -2293,6 +2289,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
fn call(
&mut self,
callee_ty: Self::Type,
_fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
callee: Self::Value,
args: &[Self::Value],
funclet: Option<&Self::Funclet>,
Expand Down
2 changes: 0 additions & 2 deletions crates/rustc_codegen_spirv/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,6 @@ impl<'a, 'tcx> ArgAbiMethods<'tcx> for Builder<'a, 'tcx> {
}

impl<'a, 'tcx> AbiBuilderMethods<'tcx> for Builder<'a, 'tcx> {
fn apply_attrs_callsite(&mut self, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, _callsite: Self::Value) {}

fn get_param(&mut self, index: usize) -> Self::Value {
self.function_parameter_values.borrow()[&self.current_fn.def(self)][index]
}
Expand Down
8 changes: 4 additions & 4 deletions crates/rustc_codegen_spirv/src/codegen_cx/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'tcx> CodegenCx<'tcx> {
let fn_id = self.shader_entry_stub(
span,
entry_func,
&fn_abi.args,
fn_abi,
hir_params,
name,
entry.execution_model,
Expand All @@ -116,7 +116,7 @@ impl<'tcx> CodegenCx<'tcx> {
&self,
span: Span,
entry_func: SpirvValue,
arg_abis: &[ArgAbi<'tcx, Ty<'tcx>>],
entry_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
hir_params: &[hir::Param<'tcx>],
name: String,
execution_model: ExecutionModel,
Expand All @@ -141,7 +141,7 @@ impl<'tcx> CodegenCx<'tcx> {
let mut bx = Builder::build(self, Builder::append_block(self, stub_fn, ""));
let mut call_args = vec![];
let mut decoration_locations = FxHashMap::default();
for (entry_arg_abi, hir_param) in arg_abis.iter().zip(hir_params) {
for (entry_arg_abi, hir_param) in entry_fn_abi.args.iter().zip(hir_params) {
bx.set_span(hir_param.span);
self.declare_shader_interface_for_param(
execution_model,
Expand All @@ -154,7 +154,7 @@ impl<'tcx> CodegenCx<'tcx> {
);
}
bx.set_span(span);
bx.call(entry_func.ty, entry_func, &call_args, None);
bx.call(entry_func.ty, None, entry_func, &call_args, None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pass Some if you change this function (shader_entry_stub) to take the whole FnAbi (and call it entry_fn_abi) instead of arg_abis (which is the .args field of that very FnAbi).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened here? I see thumbs up but also marked as resolved and no change?

bx.ret_void();

let stub_fn_id = stub_fn.def_cx(self);
Expand Down
16 changes: 0 additions & 16 deletions crates/rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,6 @@ impl<'tcx> MiscMethods<'tcx> for CodegenCx<'tcx> {
self.codegen_unit
}

fn used_statics(&self) -> &RefCell<Vec<Self::Value>> {
todo!()
}

fn compiler_used_statics(&self) -> &RefCell<Vec<Self::Value>> {
todo!()
}

fn set_frame_pointer_type(&self, _llfn: Self::Function) {
todo!()
}
Expand All @@ -575,14 +567,6 @@ impl<'tcx> MiscMethods<'tcx> for CodegenCx<'tcx> {
todo!()
}

fn create_used_variable(&self) {
todo!()
}

fn create_compiler_used_variable(&self) {
todo!()
}

fn declare_c_main(&self, _fn_type: Self::Type) -> Option<Self::Function> {
todo!()
}
Expand Down
11 changes: 1 addition & 10 deletions crates/rustc_codegen_spirv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ impl WriteBackendMethods for SpirvCodegenBackend {
type Module = Vec<u32>;
type TargetMachine = ();
type ModuleBuffer = SpirvModuleBuffer;
type Context = ();
type ThinData = ();
type ThinBuffer = SpirvThinBuffer;

Expand Down Expand Up @@ -401,7 +400,7 @@ impl ExtraBackendMethods for SpirvCodegenBackend {
) -> (ModuleCodegen<Self::Module>, u64) {
let _timer = tcx
.prof
.extra_verbose_generic_activity("codegen_module", cgu_name.to_string());
.verbose_generic_activity_with_arg("codegen_module", cgu_name.to_string());

// TODO: Do dep_graph stuff
let cgu = tcx.codegen_unit(cgu_name);
Expand Down Expand Up @@ -466,14 +465,6 @@ impl ExtraBackendMethods for SpirvCodegenBackend {
{
Arc::new(|_| Ok(()))
}

fn target_cpu<'b>(&self, _: &'b Session) -> &'b str {
todo!()
}

fn tune_cpu<'b>(&self, _: &'b Session) -> Option<&'b str> {
None
}
}

struct DumpModuleOnPanic<'a, 'cx, 'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/target.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rspirv::spirv::MemoryModel;
use rustc_target::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions};
use rustc_target::spec::{Cc, LinkerFlavor, PanicStrategy, Target, TargetOptions};
use spirv_tools::TargetEnv;

const ARCH: &str = "spirv";
Expand Down Expand Up @@ -84,7 +84,7 @@ impl SpirvTarget {
o.dll_suffix = ".spv".into();
o.dynamic_linking = true;
o.emit_debug_gdb_scripts = false;
o.linker_flavor = LinkerFlavor::Ld;
o.linker_flavor = LinkerFlavor::Unix(Cc::No);
o.panic_strategy = PanicStrategy::Abort;
o.os = "unknown".into();
o.env = self.env.to_string().into();
Expand Down
4 changes: 2 additions & 2 deletions examples/runners/ash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl RenderBase {

let swapchain_loader = khr::Swapchain::new(&instance, &device);

let present_queue = unsafe { device.get_device_queue(queue_family_index as u32, 0) };
let present_queue = unsafe { device.get_device_queue(queue_family_index, 0) };

let surface_format = {
let acceptable_formats = {
Expand Down Expand Up @@ -1263,7 +1263,7 @@ unsafe extern "system" fn vulkan_debug_callback(
_user_data: *mut std::os::raw::c_void,
) -> vk::Bool32 {
let callback_data = *p_callback_data;
let message_id_number: i32 = callback_data.message_id_number as i32;
let message_id_number: i32 = callback_data.message_id_number;

let message_id_name = if callback_data.p_message_id_name.is_null() {
Cow::from("")
Expand Down
2 changes: 1 addition & 1 deletion examples/runners/cpu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn srgb_oetf(x: f32) -> f32 {
}

fn color_u32_from_vec4(v: Vec4) -> u32 {
let convert = |f: f32| -> u32 { (f.min(1.0).max(0.0) * 255.0).round() as u32 };
let convert = |f: f32| -> u32 { (f.clamp(0.0, 1.0) * 255.0).round() as u32 };

convert(srgb_oetf(v.z))
| convert(srgb_oetf(v.y)) << 8
Expand Down
2 changes: 1 addition & 1 deletion examples/shaders/shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct ShaderConstants {
}

pub fn saturate(x: f32) -> f32 {
x.max(0.0).min(1.0)
x.clamp(0.0, 1.0)
}

pub fn pow(v: Vec3, power: f32) -> Vec3 {
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# to the user in the error, instead of "error: invalid channel name '[toolchain]'".

[toolchain]
channel = "nightly-2022-10-01"
channel = "nightly-2022-10-15"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6
# commit_hash = bf15a9e5263fcea065a7ae9c179b2d24c2deb670

# 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.
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 1117 8
OpLine %8 1122 8
%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 1117 8
OpLine %8 1122 8
%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 1310 8
OpLine %11 1316 8
OpStore %6 %9
OpLine %8 8 1
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 1310 8
OpLine %11 1316 8
OpStore %6 %9
OpLine %8 8 1
OpReturn
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/lang/core/unwrap_or.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ OpLine %5 11 11
%6 = OpCompositeInsert %7 %8 %9 0
OpLine %5 11 11
%10 = OpCompositeExtract %11 %6 1
OpLine %12 800 14
OpLine %12 803 14
%13 = OpBitcast %14 %8
OpLine %12 800 8
OpLine %12 803 8
OpSelectionMerge %15 None
OpSwitch %13 %16 0 %17 1 %18
%16 = OpLabel
OpLine %12 800 14
OpLine %12 803 14
OpUnreachable
%17 = OpLabel
OpLine %12 802 20
OpLine %12 805 20
OpBranch %15
%18 = OpLabel
OpLine %12 801 23
OpLine %12 804 23
OpBranch %15
%15 = OpLabel
%19 = OpPhi %20 %21 %17 %22 %18
%23 = OpPhi %11 %24 %17 %10 %18
OpBranch %25
%25 = OpLabel
OpLine %12 804 4
OpLine %12 807 4
OpSelectionMerge %26 None
OpBranchConditional %19 %27 %28
%27 = OpLabel
OpLine %12 804 4
OpLine %12 807 4
OpBranch %26
%28 = OpLabel
OpBranch %26
Expand Down