From 59869ec58b5b9abe5d0b2008a30a2606da64ec15 Mon Sep 17 00:00:00 2001 From: XAMPPRocky <4464295+XAMPPRocky@users.noreply.github.com> Date: Thu, 26 Nov 2020 10:12:18 +0100 Subject: [PATCH] Move lang_items into spirv-std (#275) --- crates/spirv-builder/src/test/mod.rs | 7 +------ crates/spirv-std/src/lib.rs | 12 +++++++++++- examples/shaders/compute-shader/src/lib.rs | 7 ------- examples/shaders/simplest-shader/src/lib.rs | 11 ----------- examples/shaders/sky-shader/src/lib.rs | 10 ---------- 5 files changed, 12 insertions(+), 35 deletions(-) diff --git a/crates/spirv-builder/src/test/mod.rs b/crates/spirv-builder/src/test/mod.rs index a08b1a597a..e7a41da3a1 100644 --- a/crates/spirv-builder/src/test/mod.rs +++ b/crates/spirv-builder/src/test/mod.rs @@ -49,15 +49,10 @@ spirv-std = { path = "../../crates/spirv-std" } "#; static SRC_PREFIX: &str = r#"#![no_std] -#![feature(lang_items, register_attr, asm)] +#![feature(register_attr, asm)] #![register_attr(spirv)] -use core::panic::PanicInfo; #[allow(unused_imports)] use spirv_std::*; -#[panic_handler] -fn panic(_: &PanicInfo) -> ! { - loop {} -} "#; fn setup(src: &str) -> Result> { diff --git a/crates/spirv-std/src/lib.rs b/crates/spirv-std/src/lib.rs index 7c9c6b7858..8af072787d 100644 --- a/crates/spirv-std/src/lib.rs +++ b/crates/spirv-std/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![feature(register_attr, repr_simd, core_intrinsics)] +#![feature(register_attr, repr_simd, core_intrinsics, lang_items)] #![cfg_attr(target_arch = "spirv", feature(asm))] #![register_attr(spirv)] // Our standard Clippy lints that we use in Embark projects, we opt out of a few that are not appropriate for the specific crate (yet) @@ -40,6 +40,16 @@ pub use glam; pub use num_traits; +#[cfg(all(not(test), target_arch = "spirv"))] +#[panic_handler] +fn panic(_: &core::panic::PanicInfo<'_>) -> ! { + loop {} +} + +#[cfg(all(not(test), target_arch = "spirv"))] +#[lang = "eh_personality"] +extern "C" fn rust_eh_personality() {} + macro_rules! pointer_addrspace_write { (false) => {}; (true) => { diff --git a/examples/shaders/compute-shader/src/lib.rs b/examples/shaders/compute-shader/src/lib.rs index 7d4cd860a7..38d2beef2c 100644 --- a/examples/shaders/compute-shader/src/lib.rs +++ b/examples/shaders/compute-shader/src/lib.rs @@ -1,16 +1,9 @@ #![cfg_attr(target_arch = "spirv", no_std)] -#![feature(lang_items)] #![feature(register_attr)] #![register_attr(spirv)] extern crate spirv_std; -#[cfg(all(not(test), target_arch = "spirv"))] -#[panic_handler] -fn panic(_: &core::panic::PanicInfo) -> ! { - loop {} -} - #[allow(unused_attributes)] #[spirv(gl_compute)] pub fn main_cs() {} diff --git a/examples/shaders/simplest-shader/src/lib.rs b/examples/shaders/simplest-shader/src/lib.rs index f2912ce328..5d0ea6b3de 100644 --- a/examples/shaders/simplest-shader/src/lib.rs +++ b/examples/shaders/simplest-shader/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(target_arch = "spirv", no_std)] -#![feature(lang_items)] #![feature(register_attr)] #![register_attr(spirv)] @@ -26,13 +25,3 @@ pub fn main_vs( 1.0, )); } - -#[cfg(all(not(test), target_arch = "spirv"))] -#[panic_handler] -fn panic(_: &core::panic::PanicInfo) -> ! { - loop {} -} - -#[cfg(all(not(test), target_arch = "spirv"))] -#[lang = "eh_personality"] -extern "C" fn rust_eh_personality() {} diff --git a/examples/shaders/sky-shader/src/lib.rs b/examples/shaders/sky-shader/src/lib.rs index 331196ebaa..827b98d338 100644 --- a/examples/shaders/sky-shader/src/lib.rs +++ b/examples/shaders/sky-shader/src/lib.rs @@ -179,13 +179,3 @@ pub fn main_vs( builtin_pos.store(pos.extend(0.0).extend(1.0)); } - -#[cfg(all(not(test), target_arch = "spirv"))] -#[panic_handler] -fn panic(_: &core::panic::PanicInfo) -> ! { - loop {} -} - -#[cfg(all(not(test), target_arch = "spirv"))] -#[lang = "eh_personality"] -extern "C" fn rust_eh_personality() {}