Move panic_handler and eh_personality to spirv-std (#95)

This commit is contained in:
Ashley Hauck 2020-10-22 21:25:50 +02:00 committed by GitHub
parent 79e9282352
commit 985ae7d494
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View File

@ -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() {}

View File

@ -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