mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-22 06:45:13 +00:00
Add changes to compile rust-gpu on the latest nightly (#212)
* Update DILocation and update trait impls for nightly * rustc_codegen_spirv: Update mir Scalar handling to nightly 2020-11-043a7970848c
df4d717d0b
* More changes to compile on the latest nightly * Remove unused import warnings Co-authored-by: Marijn Suijten <marijns95@gmail.com>
This commit is contained in:
parent
32c2ea58bc
commit
cf52d51199
@ -20,7 +20,7 @@ use rustc_codegen_ssa::traits::{
|
|||||||
use rustc_errors::DiagnosticBuilder;
|
use rustc_errors::DiagnosticBuilder;
|
||||||
use rustc_hir::LlvmInlineAsmInner;
|
use rustc_hir::LlvmInlineAsmInner;
|
||||||
use rustc_middle::mir::coverage::{
|
use rustc_middle::mir::coverage::{
|
||||||
CodeRegion, CounterValueReference, ExpressionOperandId, InjectedExpressionIndex, Op,
|
CodeRegion, CounterValueReference, ExpressionOperandId, InjectedExpressionId, Op,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, TyAndLayout};
|
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, TyAndLayout};
|
||||||
use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt};
|
use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt};
|
||||||
@ -214,29 +214,29 @@ impl<'a, 'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'tcx> {
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_counter_region(
|
fn set_function_source_hash(&mut self, _: rustc_middle::ty::Instance<'tcx>, _: u64) -> bool {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn add_coverage_counter(
|
||||||
&mut self,
|
&mut self,
|
||||||
_instance: Instance<'tcx>,
|
_: Instance<'tcx>,
|
||||||
_function_source_hash: u64,
|
_: CounterValueReference,
|
||||||
_id: CounterValueReference,
|
_: CodeRegion,
|
||||||
_region: CodeRegion,
|
|
||||||
) -> bool {
|
) -> bool {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
fn add_coverage_counter_expression(
|
||||||
fn add_counter_expression_region(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
_instance: Instance<'tcx>,
|
_: Instance<'tcx>,
|
||||||
_id: InjectedExpressionIndex,
|
_: InjectedExpressionId,
|
||||||
_lhs: ExpressionOperandId,
|
_: ExpressionOperandId,
|
||||||
_op: Op,
|
_: Op,
|
||||||
_rhs: ExpressionOperandId,
|
_: ExpressionOperandId,
|
||||||
_region: CodeRegion,
|
_: Option<CodeRegion>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
fn add_coverage_unreachable(&mut self, _: Instance<'tcx>, _: CodeRegion) -> bool {
|
||||||
fn add_unreachable_region(&mut self, _instance: Instance<'tcx>, _region: CodeRegion) -> bool {
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,17 +245,16 @@ impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> {
|
|||||||
fn dbg_var_addr(
|
fn dbg_var_addr(
|
||||||
&mut self,
|
&mut self,
|
||||||
_dbg_var: Self::DIVariable,
|
_dbg_var: Self::DIVariable,
|
||||||
_scope_metadata: Self::DIScope,
|
_scope_metadata: Self::DILocation,
|
||||||
_variable_alloca: Self::Value,
|
_variable_alloca: Self::Value,
|
||||||
_direct_offset: Size,
|
_direct_offset: Size,
|
||||||
// NB: each offset implies a deref (i.e. they're steps in a pointer chain).
|
// NB: each offset implies a deref (i.e. they're steps in a pointer chain).
|
||||||
_indirect_offsets: &[Size],
|
_indirect_offsets: &[Size],
|
||||||
_span: Span,
|
|
||||||
) {
|
) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_source_location(&mut self, _scope: Self::DIScope, _span: Span) {
|
fn set_dbg_loc(&mut self, _: Self::DILocation) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,6 +374,7 @@ impl<'a, 'tcx> BackendTypes for Builder<'a, 'tcx> {
|
|||||||
|
|
||||||
type DIScope = <CodegenCx<'tcx> as BackendTypes>::DIScope;
|
type DIScope = <CodegenCx<'tcx> as BackendTypes>::DIScope;
|
||||||
type DIVariable = <CodegenCx<'tcx> as BackendTypes>::DIVariable;
|
type DIVariable = <CodegenCx<'tcx> as BackendTypes>::DIVariable;
|
||||||
|
type DILocation = <CodegenCx<'tcx> as BackendTypes>::DILocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> HasCodegen<'tcx> for Builder<'a, 'tcx> {
|
impl<'a, 'tcx> HasCodegen<'tcx> for Builder<'a, 'tcx> {
|
||||||
|
@ -208,10 +208,12 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
ty: Self::Type,
|
ty: Self::Type,
|
||||||
) -> Self::Value {
|
) -> Self::Value {
|
||||||
match scalar {
|
match scalar {
|
||||||
Scalar::Raw { data, size } => match layout.value {
|
Scalar::Int(int) => {
|
||||||
Primitive::Int(int_size, int_signedness) => {
|
assert_eq!(int.size(), layout.value.size(&self.tcx));
|
||||||
assert_eq!(size as u64, int_size.size().bytes());
|
let data = int.to_bits(int.size()).unwrap();
|
||||||
match self.lookup_type(ty) {
|
|
||||||
|
match layout.value {
|
||||||
|
Primitive::Int(int_size, int_signedness) => match self.lookup_type(ty) {
|
||||||
SpirvType::Integer(width, spirv_signedness) => {
|
SpirvType::Integer(width, spirv_signedness) => {
|
||||||
assert_eq!(width as u64, int_size.size().bits());
|
assert_eq!(width as u64, int_size.size().bits());
|
||||||
if !self.kernel_mode {
|
if !self.kernel_mode {
|
||||||
@ -231,20 +233,22 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
"scalar_to_backend Primitive::Int not supported on type {}",
|
"scalar_to_backend Primitive::Int not supported on type {}",
|
||||||
other.debug(ty, self)
|
other.debug(ty, self)
|
||||||
)),
|
)),
|
||||||
|
},
|
||||||
|
Primitive::F32 => {
|
||||||
|
let res = self.constant_f32(f32::from_bits(data as u32));
|
||||||
|
assert_eq!(res.ty, ty);
|
||||||
|
res
|
||||||
|
}
|
||||||
|
Primitive::F64 => {
|
||||||
|
let res = self.constant_f64(f64::from_bits(data as u64));
|
||||||
|
assert_eq!(res.ty, ty);
|
||||||
|
res
|
||||||
|
}
|
||||||
|
Primitive::Pointer => {
|
||||||
|
bug!("scalar_to_backend Primitive::Ptr is an invalid state")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Primitive::F32 => {
|
}
|
||||||
let res = self.constant_f32(f32::from_bits(data as u32));
|
|
||||||
assert_eq!(res.ty, ty);
|
|
||||||
res
|
|
||||||
}
|
|
||||||
Primitive::F64 => {
|
|
||||||
let res = self.constant_f64(f64::from_bits(data as u64));
|
|
||||||
assert_eq!(res.ty, ty);
|
|
||||||
res
|
|
||||||
}
|
|
||||||
Primitive::Pointer => bug!("scalar_to_backend Primitive::Ptr is an invalid state"),
|
|
||||||
},
|
|
||||||
Scalar::Ptr(ptr) => {
|
Scalar::Ptr(ptr) => {
|
||||||
let (base_addr, _base_addr_space) = match self.tcx.global_alloc(ptr.alloc_id) {
|
let (base_addr, _base_addr_space) = match self.tcx.global_alloc(ptr.alloc_id) {
|
||||||
GlobalAlloc::Memory(alloc) => {
|
GlobalAlloc::Memory(alloc) => {
|
||||||
|
@ -20,9 +20,9 @@ use rustc_hir::GlobalAsm;
|
|||||||
use rustc_middle::mir::mono::CodegenUnit;
|
use rustc_middle::mir::mono::CodegenUnit;
|
||||||
use rustc_middle::mir::Body;
|
use rustc_middle::mir::Body;
|
||||||
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt};
|
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt};
|
||||||
use rustc_middle::ty::{Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
|
use rustc_middle::ty::{Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt, TyS};
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::def_id::{CrateNum, LOCAL_CRATE};
|
use rustc_span::def_id::LOCAL_CRATE;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::source_map::Span;
|
||||||
use rustc_span::symbol::{sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
use rustc_span::SourceFile;
|
use rustc_span::SourceFile;
|
||||||
@ -240,6 +240,7 @@ impl<'tcx> BackendTypes for CodegenCx<'tcx> {
|
|||||||
type Funclet = ();
|
type Funclet = ();
|
||||||
|
|
||||||
type DIScope = ();
|
type DIScope = ();
|
||||||
|
type DILocation = ();
|
||||||
type DIVariable = ();
|
type DIVariable = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,13 +327,26 @@ impl<'tcx> DebugInfoMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
// Ignore.
|
// Ignore.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dbg_scope_fn(
|
||||||
|
&self,
|
||||||
|
_: rustc_middle::ty::Instance<'tcx>,
|
||||||
|
_: &FnAbi<'tcx, &'tcx TyS<'tcx>>,
|
||||||
|
_: Option<Self::Function>,
|
||||||
|
) -> Self::DIScope {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dbg_loc(&self, _: Self::DIScope, _: Option<Self::DILocation>, _: Span) -> Self::DILocation {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
fn create_function_debug_context(
|
fn create_function_debug_context(
|
||||||
&self,
|
&self,
|
||||||
_instance: Instance<'tcx>,
|
_instance: Instance<'tcx>,
|
||||||
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||||
_llfn: Self::Function,
|
_llfn: Self::Function,
|
||||||
_mir: &Body<'_>,
|
_mir: &Body<'_>,
|
||||||
) -> Option<FunctionDebugContext<Self::DIScope>> {
|
) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>> {
|
||||||
// TODO: This is ignored. Do we want to implement this at some point?
|
// TODO: This is ignored. Do we want to implement this at some point?
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -341,7 +355,6 @@ impl<'tcx> DebugInfoMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
_scope_metadata: Self::DIScope,
|
_scope_metadata: Self::DIScope,
|
||||||
_file: &SourceFile,
|
_file: &SourceFile,
|
||||||
_defining_crate: CrateNum,
|
|
||||||
) -> Self::DIScope {
|
) -> Self::DIScope {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@ -352,7 +365,6 @@ impl<'tcx> DebugInfoMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
|
|
||||||
fn create_dbg_var(
|
fn create_dbg_var(
|
||||||
&self,
|
&self,
|
||||||
_dbg_context: &FunctionDebugContext<Self::DIScope>,
|
|
||||||
_variable_name: Symbol,
|
_variable_name: Symbol,
|
||||||
_variable_type: Ty<'tcx>,
|
_variable_type: Ty<'tcx>,
|
||||||
_scope_metadata: Self::DIScope,
|
_scope_metadata: Self::DIScope,
|
||||||
|
@ -151,23 +151,19 @@ fn is_blocklisted_fn(symbol_name: &str) -> bool {
|
|||||||
fn target_options() -> Target {
|
fn target_options() -> Target {
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "no-llvm".to_string(),
|
llvm_target: "no-llvm".to_string(),
|
||||||
target_endian: "little".to_string(),
|
|
||||||
pointer_width: 32,
|
pointer_width: 32,
|
||||||
target_c_int_width: "32".to_string(),
|
|
||||||
target_os: "unknown".to_string(),
|
|
||||||
target_env: String::new(),
|
|
||||||
target_vendor: "unknown".to_string(),
|
|
||||||
data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".to_string(),
|
data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".to_string(),
|
||||||
arch: "spirv".to_string(),
|
arch: "spirv".to_string(),
|
||||||
linker_flavor: LinkerFlavor::Ld,
|
|
||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
|
allows_weak_linkage: false,
|
||||||
|
crt_static_allows_dylibs: true,
|
||||||
dll_prefix: "".to_string(),
|
dll_prefix: "".to_string(),
|
||||||
dll_suffix: ".spv".to_string(),
|
dll_suffix: ".spv".to_string(),
|
||||||
panic_strategy: PanicStrategy::Abort,
|
|
||||||
emit_debug_gdb_scripts: false,
|
|
||||||
allows_weak_linkage: false,
|
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
crt_static_allows_dylibs: true,
|
emit_debug_gdb_scripts: false,
|
||||||
|
linker_flavor: LinkerFlavor::Ld,
|
||||||
|
panic_strategy: PanicStrategy::Abort,
|
||||||
|
target_os: "unknown".to_string(),
|
||||||
// TODO: Investigate if main_needs_argc_argv is useful (for building exes)
|
// TODO: Investigate if main_needs_argc_argv is useful (for building exes)
|
||||||
main_needs_argc_argv: false,
|
main_needs_argc_argv: false,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -52,6 +52,7 @@ static SRC_PREFIX: &str = r#"#![no_std]
|
|||||||
#![feature(lang_items, register_attr)]
|
#![feature(lang_items, register_attr)]
|
||||||
#![register_attr(spirv)]
|
#![register_attr(spirv)]
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
#[allow(unused_imports)]
|
||||||
use spirv_std::*;
|
use spirv_std::*;
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(_: &PanicInfo) -> ! {
|
fn panic(_: &PanicInfo) -> ! {
|
||||||
|
@ -80,7 +80,7 @@ impl Optimizer for CompiledOptimizer {
|
|||||||
ctx: *mut std::ffi::c_void,
|
ctx: *mut std::ffi::c_void,
|
||||||
) {
|
) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ctx: &mut Ctx<'_> = &mut *(ctx as *mut Ctx);
|
let ctx: &mut Ctx<'_> = &mut *(ctx as *mut Ctx<'_>);
|
||||||
|
|
||||||
let msg = error::Message::from_parts(level, source, source_pos, msg);
|
let msg = error::Message::from_parts(level, source, source_pos, msg);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use ash::extensions::ext::DebugUtils;
|
|||||||
use ash::extensions::khr::{Surface, Swapchain};
|
use ash::extensions::khr::{Surface, Swapchain};
|
||||||
use ash::util::*;
|
use ash::util::*;
|
||||||
use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};
|
use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};
|
||||||
use ash::{vk, Device, Entry, Instance};
|
use ash::{vk, Device, Instance};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
@ -159,7 +159,7 @@ pub struct ExampleBase {
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub entry: ash_molten::MoltenEntry,
|
pub entry: ash_molten::MoltenEntry,
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
pub entry: Entry,
|
pub entry: ash::Entry,
|
||||||
pub instance: Instance,
|
pub instance: Instance,
|
||||||
pub device: Device,
|
pub device: Device,
|
||||||
pub surface_loader: Surface,
|
pub surface_loader: Surface,
|
||||||
@ -240,7 +240,7 @@ impl ExampleBase {
|
|||||||
if #[cfg(target_os = "macos")] {
|
if #[cfg(target_os = "macos")] {
|
||||||
let entry = ash_molten::MoltenEntry::load().unwrap();
|
let entry = ash_molten::MoltenEntry::load().unwrap();
|
||||||
} else {
|
} else {
|
||||||
let entry = Entry::new().unwrap();
|
let entry = ash::Entry::new().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
nightly-2020-10-25
|
nightly-2020-11-09
|
||||||
|
Loading…
Reference in New Issue
Block a user