Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Commit 985ae7d

Browse files
authored
Move panic_handler and eh_personality to spirv-std (#95)
1 parent 79e9282 commit 985ae7d

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

examples/example-shader/src/lib.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
//! Ported to Rust from https://github.com/Tw1ddle/Sky-Shader/blob/master/src/shaders/glsl/sky.fragment
22
33
#![no_std]
4-
#![feature(lang_items)]
54
#![feature(register_attr)]
65
#![register_attr(spirv)]
76

87
use core::f32::consts::PI;
9-
#[cfg(not(test))]
10-
use core::panic::PanicInfo;
118
use spirv_std::{Input, Mat4, MathExt, Output, Vec3, Vec4};
129

1310
const DEPOLARIZATION_FACTOR: f32 = 0.035;
@@ -184,13 +181,3 @@ pub fn main_vs(
184181
out_pos.store(in_pos.load());
185182
out_color.store(in_pos.load());
186183
}
187-
188-
#[cfg(not(test))]
189-
#[panic_handler]
190-
fn panic(_: &PanicInfo) -> ! {
191-
loop {}
192-
}
193-
194-
#[cfg(not(test))]
195-
#[lang = "eh_personality"]
196-
extern "C" fn rust_eh_personality() {}

spirv-std/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#![no_std]
2-
#![feature(register_attr, repr_simd, core_intrinsics)]
2+
#![feature(register_attr, repr_simd, core_intrinsics, lang_items)]
33
#![register_attr(spirv)]
44

55
pub mod math;
66
pub use crate::math::MathExt;
77
pub use crate::math::*;
8+
#[cfg(target_arch = "spirv")]
9+
use core::panic::PanicInfo;
810

911
macro_rules! pointer_addrspace_write {
1012
(false) => {};
@@ -67,6 +69,16 @@ pointer_addrspace!("physical_storage_buffer", PhysicalStorageBuffer, true);
6769
#[repr(simd)]
6870
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
6971

72+
#[cfg(target_arch = "spirv")]
73+
#[panic_handler]
74+
fn panic(_: &PanicInfo) -> ! {
75+
loop {}
76+
}
77+
78+
#[cfg(target_arch = "spirv")]
79+
#[lang = "eh_personality"]
80+
extern "C" fn rust_eh_personality() {}
81+
7082
/// libcore requires a few external symbols to be defined:
7183
/// https://github.com/rust-lang/rust/blob/c2bc344eb23d8c1d18e803b3f1e631cf99926fbb/library/core/src/lib.rs#L23-L27
7284
/// TODO: This is copied from compiler_builtins/mem.rs. Can we use that one instead? The note in the above link says

0 commit comments

Comments
 (0)