diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index c89575e576..50956f82da 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -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-01-21" +channel = "nightly-2023-02-01" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] -# commit_hash = 5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14"#; +# commit_hash = dc1d9d50fba2f6a1ccab8748a0050cde38253f60"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index a1427ef4f5..a0cd95ac74 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -44,11 +44,13 @@ pub(crate) fn provide(providers: &mut Providers) { // We can't capture the old fn_sig and just call that, because fn_sig is a `fn`, not a `Fn`, i.e. it can't // capture variables. Fortunately, the defaults are exposed (thanks rustdoc), so use that instead. let result = (rustc_interface::DEFAULT_QUERY_PROVIDERS.fn_sig)(tcx, def_id); - result.map_bound(|mut inner| { - if let SpecAbi::C { .. } = inner.abi { - inner.abi = SpecAbi::Unadjusted; - } - inner + result.map_bound(|outer| { + outer.map_bound(|mut inner| { + if let SpecAbi::C { .. } = inner.abi { + inner.abi = SpecAbi::Unadjusted; + } + inner + }) }) }; @@ -502,7 +504,7 @@ fn trans_scalar<'tcx>( } Primitive::F32 => SpirvType::Float(32).def(span, cx), Primitive::F64 => SpirvType::Float(64).def(span, cx), - Primitive::Pointer => { + 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 // the same type, emit an OpTypeForwardPointer and use that ID. diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index 34267e7655..93bf42e157 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -250,7 +250,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { assert_eq!(res.ty, ty); res } - Primitive::Pointer => { + Primitive::Pointer(_) => { if data == 0 { self.constant_null(ty) } else { @@ -317,14 +317,13 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { // let offset = self.constant_u64(ptr.offset.bytes()); // self.gep(base_addr, once(offset)) }; - if layout.primitive() != Primitive::Pointer { + if let Primitive::Pointer(_) = layout.primitive() { + assert_ty_eq!(self, value.ty, ty); + value + } else { self.tcx .sess .fatal("Non-pointer-typed scalar_to_backend Scalar::Ptr not supported"); - // unsafe { llvm::LLVMConstPtrToInt(llval, llty) } - } else { - assert_ty_eq!(self, value.ty, ty); - value } } } @@ -440,7 +439,7 @@ impl<'tcx> CodegenCx<'tcx> { .fatal(format!("invalid size for float: {other}")); } }, - SpirvType::Pointer { .. } => Primitive::Pointer, + SpirvType::Pointer { .. } => Primitive::Pointer(AddressSpace::DATA), unsupported_spirv_type => bug!( "invalid spirv type internal to create_alloc_const2: {:?}", unsupported_spirv_type @@ -454,7 +453,7 @@ impl<'tcx> CodegenCx<'tcx> { let value = match alloc.inner().read_scalar( self, alloc_range(*offset, size), - primitive.is_ptr(), + matches!(primitive, Primitive::Pointer(_)), ) { Ok(scalar) => { self.scalar_to_backend(scalar, self.primitive_to_scalar(primitive), ty) diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 77b537ac08..10fdbb9406 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -284,6 +284,7 @@ impl CodegenBackend for SpirvCodegenBackend { impl WriteBackendMethods for SpirvCodegenBackend { type Module = Vec; type TargetMachine = (); + type TargetMachineError = String; type ModuleBuffer = SpirvModuleBuffer; type ThinData = (); type ThinBuffer = SpirvThinBuffer; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 65de5c2709..c0540c69a2 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2023-01-21" +channel = "nightly-2023-02-01" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] -# commit_hash = 5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14 +# commit_hash = dc1d9d50fba2f6a1ccab8748a0050cde38253f60 # 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.