From ca988f95decff252dbbd7912d664b5d7b9d13033 Mon Sep 17 00:00:00 2001 From: Ashley Hauck Date: Thu, 20 May 2021 14:46:09 +0200 Subject: [PATCH] rustup update to 2021-05-17 (#621) --- .../src/builder/builder_methods.rs | 4 ++- .../src/builder/spirv_asm.rs | 4 +-- .../src/codegen_cx/declare.rs | 29 ++++++++++++------- .../rustc_codegen_spirv/src/codegen_cx/mod.rs | 13 +++++++-- crates/rustc_codegen_spirv/src/decorations.rs | 2 +- crates/rustc_codegen_spirv/src/lib.rs | 8 ++++- crates/rustc_codegen_spirv/src/link.rs | 28 +++++++++++++----- rust-toolchain | 2 +- tests/ui/dis/ptr_write.stderr | 2 +- tests/ui/dis/ptr_write_method.stderr | 2 +- .../spirv-attr/bad-infer-storage-class.stderr | 2 +- 11 files changed, 66 insertions(+), 30 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 8034edf56f..37f3a55f62 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -518,7 +518,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { fn set_span(&mut self, span: Span) { self.current_span = Some(span); let loc = self.cx.tcx.sess.source_map().lookup_char_pos(span.lo()); - let file = self.builder.def_string(format!("{}", loc.file.name)); + let file = self + .builder + .def_string(format!("{}", loc.file.name.prefer_remapped())); self.emit() .line(file, loc.line as u32, loc.col_display as u32); } diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 1f816fa233..7e3a89e9f2 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -747,7 +747,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { token: Token<'a, 'cx, 'tcx>, ) -> Option> { match token { - Token::Word(word) => match word.strip_prefix("%") { + Token::Word(word) => match word.strip_prefix('%') { Some(id) => Some(OutRegister::Regular({ let num = *id_map.entry(id).or_insert_with(|| self.emit().id()); if !defined_ids.insert(num) { @@ -835,7 +835,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { token: Token<'a, 'cx, 'tcx>, ) -> Option { match token { - Token::Word(word) => match word.strip_prefix("%") { + Token::Word(word) => match word.strip_prefix('%') { Some(id) => Some(*id_map.entry(id).or_insert_with(|| self.emit().id())), None => { self.err("expected ID"); diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index 67cb44e77d..4caeaf1602 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -212,10 +212,13 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> { let linkage = match linkage { Linkage::External => Some(LinkageType::Export), Linkage::Internal => None, - other => self.tcx.sess.fatal(&format!( - "TODO: Linkage type not supported yet: {:?}", - other - )), + other => { + self.tcx.sess.err(&format!( + "TODO: Linkage type {:?} not supported yet for static var symbol {}", + other, symbol_name + )); + None + } }; let g = self.declare_global(span, spvty); @@ -231,15 +234,21 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> { instance: Instance<'tcx>, linkage: Linkage, _visibility: Visibility, - _symbol_name: &str, + symbol_name: &str, ) { let linkage2 = match linkage { - Linkage::External => Some(LinkageType::Export), + // super sketchy hack: memcpy, memmove, memset, memcmp, and bcmp in the + // compiler_builtins crate use the WeakAny linkage type. Treat it as actually External + // linkage because we know there's only one of them. + Linkage::External | Linkage::WeakAny => Some(LinkageType::Export), Linkage::Internal => None, - other => self.tcx.sess.fatal(&format!( - "TODO: Linkage type not supported yet: {:?}", - other - )), + other => { + self.tcx.sess.err(&format!( + "TODO: Linkage type {:?} not supported yet for function symbol {}", + other, symbol_name + )); + None + } }; let declared = self.declare_fn_ext(instance, linkage2); diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index 6df3e6ea5b..944d8ce80d 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -14,12 +14,13 @@ use crate::target::SpirvTarget; use rspirv::dr::{Module, Operand}; use rspirv::spirv::{AddressingModel, Decoration, LinkageType, Op, Word}; +use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, VariableKind}; use rustc_codegen_ssa::traits::{ - AsmMethods, BackendTypes, CoverageInfoMethods, DebugInfoMethods, MiscMethods, + AsmMethods, BackendTypes, CoverageInfoMethods, DebugInfoMethods, GlobalAsmOperandRef, + MiscMethods, }; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_hir::GlobalAsm; use rustc_middle::mir::mono::CodegenUnit; use rustc_middle::mir::Body; use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt}; @@ -616,7 +617,13 @@ impl<'tcx> CoverageInfoMethods<'tcx> for CodegenCx<'tcx> { } impl<'tcx> AsmMethods for CodegenCx<'tcx> { - fn codegen_global_asm(&self, _ga: &GlobalAsm) { + fn codegen_global_asm( + &self, + _template: &[InlineAsmTemplatePiece], + _operands: &[GlobalAsmOperandRef], + _options: InlineAsmOptions, + _line_spans: &[Span], + ) { todo!() } } diff --git a/crates/rustc_codegen_spirv/src/decorations.rs b/crates/rustc_codegen_spirv/src/decorations.rs index 268d781f8a..1740a5ad44 100644 --- a/crates/rustc_codegen_spirv/src/decorations.rs +++ b/crates/rustc_codegen_spirv/src/decorations.rs @@ -197,7 +197,7 @@ impl SerializedSpan { file: match &file.name { // We can only support real files, not "synthetic" ones (which // are almost never exposed to the compiler backend anyway). - FileName::Real(real_name) => real_name.local_path().to_path_buf(), + FileName::Real(real_name) => real_name.local_path()?.to_path_buf(), _ => return None, }, hash: file.src_hash.into(), diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index e0535b8a23..0f3204923a 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -328,6 +328,12 @@ impl CodegenBackend for SpirvCodegenBackend { Box::new(rustc_codegen_ssa::base::codegen_crate( Self, tcx, + tcx.sess + .opts + .cg + .target_cpu + .clone() + .unwrap_or_else(|| tcx.sess.target.cpu.clone()), metadata, need_metadata_module, )) @@ -472,7 +478,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { _: &ModuleCodegen, _: &ModuleConfig, _: bool, - ) { + ) -> Result<(), FatalError> { todo!() } } diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index f3d76e9e82..bf6f0ef642 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -86,10 +86,16 @@ fn link_rlib(sess: &Session, codegen_results: &CodegenResults, out_filename: &Pa } for lib in codegen_results.crate_info.used_libraries.iter() { match lib.kind { - NativeLibKind::StaticBundle => {} - NativeLibKind::StaticNoBundle - | NativeLibKind::Dylib - | NativeLibKind::Framework + NativeLibKind::Static { + bundle: None | Some(true), + .. + } => {} + NativeLibKind::Static { + bundle: Some(false), + .. + } + | NativeLibKind::Dylib { .. } + | NativeLibKind::Framework { .. } | NativeLibKind::RawDylib | NativeLibKind::Unspecified => continue, } @@ -335,15 +341,18 @@ fn add_upstream_native_libraries( continue; } match lib.kind { - NativeLibKind::Dylib | NativeLibKind::Unspecified => sess.fatal(&format!( + NativeLibKind::Dylib { .. } | NativeLibKind::Unspecified => sess.fatal(&format!( "TODO: dylib nativelibkind not supported yet: {}", name )), - NativeLibKind::Framework => sess.fatal(&format!( + NativeLibKind::Framework { .. } => sess.fatal(&format!( "TODO: framework nativelibkind not supported yet: {}", name )), - NativeLibKind::StaticNoBundle => { + NativeLibKind::Static { + bundle: Some(false), + .. + } => { if data[cnum.as_usize() - 1] == Linkage::Static { sess.fatal(&format!( "TODO: staticnobundle nativelibkind not supported yet: {}", @@ -351,7 +360,10 @@ fn add_upstream_native_libraries( )) } } - NativeLibKind::StaticBundle => {} + NativeLibKind::Static { + bundle: None | Some(true), + .. + } => {} NativeLibKind::RawDylib => { sess.fatal(&format!("raw_dylib feature not yet implemented: {}", name)) } diff --git a/rust-toolchain b/rust-toolchain index fc1bc24ce4..f0747eae78 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -5,5 +5,5 @@ # to the user in the error, instead of "error: invalid channel name '[toolchain]'". [toolchain] -channel = "nightly-2021-04-25" +channel = "nightly-2021-05-17" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index 8a04c59304..e8953beb10 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -7,7 +7,7 @@ OpLine %9 7 35 %10 = OpLoad %11 %4 OpLine %9 7 13 OpStore %8 %10 -OpLine %12 886 8 +OpLine %12 878 8 OpCopyMemory %6 %8 OpLine %9 8 1 OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index a937975f5e..96e4e02ab1 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -7,7 +7,7 @@ OpLine %9 7 37 %10 = OpLoad %11 %4 OpLine %12 1012 17 OpStore %8 %10 -OpLine %13 886 8 +OpLine %13 878 8 OpCopyMemory %6 %8 OpLine %9 8 1 OpReturn diff --git a/tests/ui/spirv-attr/bad-infer-storage-class.stderr b/tests/ui/spirv-attr/bad-infer-storage-class.stderr index c337afa341..00288ae4fb 100644 --- a/tests/ui/spirv-attr/bad-infer-storage-class.stderr +++ b/tests/ui/spirv-attr/bad-infer-storage-class.stderr @@ -25,7 +25,7 @@ error: entry parameter type must be by-reference: `&spirv_std::image::Image