diff --git a/examples/example-shader/src/lib.rs b/examples/example-shader/src/lib.rs index 333abb1223..0c6a032cf4 100644 --- a/examples/example-shader/src/lib.rs +++ b/examples/example-shader/src/lib.rs @@ -1,13 +1,10 @@ //! Ported to Rust from https://github.com/Tw1ddle/Sky-Shader/blob/master/src/shaders/glsl/sky.fragment #![no_std] -#![feature(lang_items)] #![feature(register_attr)] #![register_attr(spirv)] use core::f32::consts::PI; -#[cfg(not(test))] -use core::panic::PanicInfo; use spirv_std::{Input, Mat4, MathExt, Output, Vec3, Vec4}; const DEPOLARIZATION_FACTOR: f32 = 0.035; @@ -184,13 +181,3 @@ pub fn main_vs( out_pos.store(in_pos.load()); out_color.store(in_pos.load()); } - -#[cfg(not(test))] -#[panic_handler] -fn panic(_: &PanicInfo) -> ! { - loop {} -} - -#[cfg(not(test))] -#[lang = "eh_personality"] -extern "C" fn rust_eh_personality() {} diff --git a/spirv-std/src/lib.rs b/spirv-std/src/lib.rs index 8a644b8d5a..273928a3be 100644 --- a/spirv-std/src/lib.rs +++ b/spirv-std/src/lib.rs @@ -1,10 +1,12 @@ #![no_std] -#![feature(register_attr, repr_simd, core_intrinsics)] +#![feature(register_attr, repr_simd, core_intrinsics, lang_items)] #![register_attr(spirv)] pub mod math; pub use crate::math::MathExt; pub use crate::math::*; +#[cfg(target_arch = "spirv")] +use core::panic::PanicInfo; macro_rules! pointer_addrspace_write { (false) => {}; @@ -67,6 +69,16 @@ pointer_addrspace!("physical_storage_buffer", PhysicalStorageBuffer, true); #[repr(simd)] pub struct f32x4(pub f32, pub f32, pub f32, pub f32); +#[cfg(target_arch = "spirv")] +#[panic_handler] +fn panic(_: &PanicInfo) -> ! { + loop {} +} + +#[cfg(target_arch = "spirv")] +#[lang = "eh_personality"] +extern "C" fn rust_eh_personality() {} + /// libcore requires a few external symbols to be defined: /// https://github.com/rust-lang/rust/blob/c2bc344eb23d8c1d18e803b3f1e631cf99926fbb/library/core/src/lib.rs#L23-L27 /// TODO: This is copied from compiler_builtins/mem.rs. Can we use that one instead? The note in the above link says