Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustup: update to nightly-2021-08-27 and re-add -Zsymbol-mangling-version=v0. #737

Merged
merged 3 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ar = "0.9.0"
bimap = "0.6"
indexmap = "1.6.0"
rspirv = "0.10"
rustc-demangle = "0.1.18"
rustc-demangle = "0.1.21"
sanitize-filename = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
12 changes: 4 additions & 8 deletions crates/rustc_codegen_spirv/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl AggregatedSpirvAttributes {

// NOTE(eddyb) `delay_span_bug` ensures that if attribute checking fails
// to see an attribute error, it will cause an ICE instead.
for (_, parse_attr_result) in crate::symbols::parse_attrs_for_checking(&cx.sym, attrs) {
for parse_attr_result in crate::symbols::parse_attrs_for_checking(&cx.sym, attrs) {
let (span, parsed_attr) = match parse_attr_result {
Ok(span_and_parsed_attr) => span_and_parsed_attr,
Err((span, msg)) => {
Expand Down Expand Up @@ -263,11 +263,7 @@ impl CheckSpirvAttrVisitor<'_> {
let parse_attrs = |attrs| crate::symbols::parse_attrs_for_checking(&self.sym, attrs);

let attrs = self.tcx.hir().attrs(hir_id);
for (attr, parse_attr_result) in parse_attrs(attrs) {
// Make sure to mark the whole `#[spirv(...)]` attribute as used,
// to avoid warnings about unused attributes.
self.tcx.sess.mark_attr_used(attr);

for parse_attr_result in parse_attrs(attrs) {
let (span, parsed_attr) = match parse_attr_result {
Ok(span_and_parsed_attr) => span_and_parsed_attr,
Err((span, msg)) => {
Expand Down Expand Up @@ -312,7 +308,7 @@ impl CheckSpirvAttrVisitor<'_> {
let parent_hir_id = self.tcx.hir().get_parent_node(hir_id);
let parent_is_entry_point =
parse_attrs(self.tcx.hir().attrs(parent_hir_id))
.filter_map(|(_, r)| r.ok())
.filter_map(|r| r.ok())
.any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_)));
if !parent_is_entry_point {
self.tcx.sess.span_err(
Expand Down Expand Up @@ -494,7 +490,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {

fn check_invalid_macro_level_spirv_attr(tcx: TyCtxt<'_>, sym: &Symbols, attrs: &[Attribute]) {
for attr in attrs {
if tcx.sess.check_name(attr, sym.spirv) {
if attr.has_name(sym.spirv) {
tcx.sess
.span_err(attr.span, "#[spirv(..)] cannot be applied to a macro");
}
Expand Down
9 changes: 6 additions & 3 deletions crates/rustc_codegen_spirv/src/codegen_cx/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,17 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
}

impl<'tcx> CodegenCx<'tcx> {
// This function comes from https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/ty/layout.rs.html,
// and is a lambda in the `layout_raw_uncached` function in Version 1.50.0-nightly (eb4fc71dc 2020-12-17)
// This function comes from `ty::layout`'s `layout_of_uncached`,
// where it's named `scalar_unit`.
pub fn primitive_to_scalar(&self, value: Primitive) -> abi::Scalar {
let bits = value.size(self.data_layout()).bits();
assert!(bits <= 128);
abi::Scalar {
value,
valid_range: 0..=(!0 >> (128 - bits)),
valid_range: abi::WrappingRange {
start: 0,
end: (!0 >> (128 - bits)),
},
}
}

Expand Down
15 changes: 10 additions & 5 deletions crates/rustc_codegen_spirv/src/codegen_cx/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,17 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> {
.set_global_initializer(g.def_cx(self), v.def_cx(self));
}

/// Mark the given global value as "used", to prevent a backend from potentially removing a
/// static variable that may otherwise appear unused.
///
/// Static variables in Rust can be annotated with the `#[used]` attribute to direct the `rustc`
/// compiler to mark the variable as a "used global".
/// Mark the given global value as "used", to prevent the compiler and linker from potentially
/// removing a static variable that may otherwise appear unused.
fn add_used_global(&self, _global: Self::Value) {
// TODO: Ignore for now.
}

/// Same as `add_used_global`, but only prevent the compiler from potentially removing an
/// otherwise unused symbol. The linker is still permitted to drop it.
///
/// This corresponds to the semantics of the `#[used]` attribute.
fn add_compiler_used_global(&self, _global: Self::Value) {
// TODO: Ignore for now.
}
}
8 changes: 8 additions & 0 deletions crates/rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ impl<'tcx> MiscMethods<'tcx> for CodegenCx<'tcx> {
todo!()
}

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

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

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

fn declare_c_main(&self, _fn_type: Self::Type) -> Option<Self::Function> {
todo!()
}
Expand Down
20 changes: 3 additions & 17 deletions crates/rustc_codegen_spirv/src/symbols.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::attr::{Entry, ExecutionModeExtra, IntrinsicType, SpirvAttribute};
use crate::builder::libm_intrinsics;
use rspirv::spirv::{BuiltIn, ExecutionMode, ExecutionModel, StorageClass};
use rustc_ast::ast::{AttrKind, Attribute, Lit, LitIntType, LitKind, NestedMetaItem};
use rustc_ast::ast::{Attribute, Lit, LitIntType, LitKind, NestedMetaItem};
use rustc_data_structures::fx::FxHashMap;
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::Span;
Expand Down Expand Up @@ -409,22 +409,9 @@ type ParseAttrError = (Span, String);
pub(crate) fn parse_attrs_for_checking<'a>(
sym: &'a Symbols,
attrs: &'a [Attribute],
) -> impl Iterator<
Item = (
&'a Attribute,
Result<(Span, SpirvAttribute), ParseAttrError>,
),
> + 'a {
) -> impl Iterator<Item = Result<(Span, SpirvAttribute), ParseAttrError>> + 'a {
attrs.iter().flat_map(move |attr| {
let is_spirv = match attr.kind {
AttrKind::Normal(ref item, _) => {
// TODO: We ignore the rest of the path. Is this right?
let last = item.path.segments.last();
last.map_or(false, |seg| seg.ident.name == sym.spirv)
}
AttrKind::DocComment(..) => false,
};
let (whole_attr_error, args) = if !is_spirv {
let (whole_attr_error, args) = if !attr.has_name(sym.spirv) {
// Use an empty vec here to return empty
(None, Vec::new())
} else if let Some(args) = attr.meta_item_list() {
Expand Down Expand Up @@ -475,7 +462,6 @@ pub(crate) fn parse_attrs_for_checking<'a>(
};
Ok((span, parsed_attr))
}))
.map(move |parse_attr_result| (attr, parse_attr_result))
})
}

Expand Down
3 changes: 1 addition & 2 deletions crates/spirv-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {

let mut rustflags = vec![
format!("-Zcodegen-backend={}", rustc_codegen_spirv.display()),
//FIXME: reintroduce v0 mangling, see issue #642
"-Zsymbol-mangling-version=legacy".to_string(),
"-Zsymbol-mangling-version=v0".to_string(),
];

let mut llvm_args = vec![];
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# to the user in the error, instead of "error: invalid channel name '[toolchain]'".

[toolchain]
channel = "nightly-2021-08-10"
channel = "nightly-2021-08-27"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
2 changes: 2 additions & 0 deletions tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ struct TestDeps {
}

/// The RUSTFLAGS passed to all SPIR-V builds.
// FIXME(eddyb) expose most of these from `spirv-builder`.
fn rust_flags(codegen_backend_path: &Path) -> String {
[
&*format!("-Zcodegen-backend={}", codegen_backend_path.display()),
Expand All @@ -300,6 +301,7 @@ fn rust_flags(codegen_backend_path: &Path) -> String {
"-Cdebuginfo=2",
"-Cembed-bitcode=no",
"-Ctarget-feature=+Int8,+Int16,+Int64,+Float64",
"-Zsymbol-mangling-version=v0",
]
.join(" ")
}
Expand Down
19 changes: 19 additions & 0 deletions tests/ui/dis/generic-fn-op-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Test that generic functions' `OpName` correctly include generic arguments.

// build-pass
// compile-flags: -C llvm-args=--disassemble-globals
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"

#![feature(const_generics)]
#![allow(incomplete_features)]

use spirv_std::image::Dimensionality;

fn generic<T, const DIM: Dimensionality>() {}

#[spirv(fragment)]
pub fn main() {
generic::<f32, { Dimensionality::TwoD }>();
}
13 changes: 13 additions & 0 deletions tests/ui/dis/generic-fn-op-name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
OpCapability Float64
OpCapability Int16
OpCapability Int64
OpCapability Int8
OpCapability Shader
OpMemoryModel Logical Simple
OpEntryPoint Fragment %1 "main"
OpExecutionMode %1 OriginUpperLeft
%2 = OpString "$OPSTRING_FILENAME/generic-fn-op-name.rs"
OpName %3 "generic_fn_op_name::generic::<f32, {spirv_types::image_params::Dimensionality::TwoD}>"
OpName %4 "generic_fn_op_name::main"
%5 = OpTypeVoid
%6 = OpTypeFunction %5
4 changes: 2 additions & 2 deletions tests/ui/dis/ptr_copy.normal.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: Cannot memcpy dynamically sized data
--> $CORE_SRC/intrinsics.rs:2132:14
--> $CORE_SRC/intrinsics.rs:2138:14
|
2132 | unsafe { copy(src, dst, count) }
2138 | unsafe { copy(src, dst, count) }
| ^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error
Expand Down