Fix panic not producing output

This commit is contained in:
Jeremy Soller
2019-03-27 21:28:39 -06:00
parent 5dca9843dc
commit bee72373be
7 changed files with 36 additions and 25 deletions
Generated
-3
View File
@@ -82,9 +82,6 @@ dependencies = [
[[package]]
name = "crt0"
version = "0.1.0"
dependencies = [
"relibc 0.1.0",
]
[[package]]
name = "crti"
+6 -6
View File
@@ -90,15 +90,15 @@ $(BUILD)/debug/librelibc.a: $(SRC)
touch $@
$(BUILD)/debug/crt0.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/debug/crti.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/debug/crtn.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/release/librelibc.a: $(SRC)
@@ -106,15 +106,15 @@ $(BUILD)/release/librelibc.a: $(SRC)
touch $@
$(BUILD)/release/crt0.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/release/crti.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/release/crtn.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/include: $(SRC)
-3
View File
@@ -6,6 +6,3 @@ authors = ["Jeremy Soller <jackpot51@gmail.com>"]
[lib]
name = "crt0"
crate-type = ["staticlib"]
[dependencies]
relibc = { path = "../.." }
+7 -3
View File
@@ -2,7 +2,6 @@
#![no_std]
#![feature(asm)]
#![feature(core_intrinsics)]
#![feature(linkage)]
#![feature(naked_functions)]
@@ -29,6 +28,11 @@ pub unsafe extern "C" fn _start() {
}
#[panic_handler]
unsafe fn panic(_pi: &::core::panic::PanicInfo) -> ! {
::core::intrinsics::abort();
#[linkage = "weak"]
#[no_mangle]
pub unsafe extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
extern "C" {
fn relibc_panic(pi: &::core::panic::PanicInfo) -> !;
}
relibc_panic(pi)
}
+7 -3
View File
@@ -1,7 +1,6 @@
//! crti
#![no_std]
#![feature(core_intrinsics)]
#![feature(global_asm)]
#![feature(linkage)]
@@ -47,6 +46,11 @@ global_asm!(r#"
"#);
#[panic_handler]
unsafe fn panic(_pi: &::core::panic::PanicInfo) -> ! {
::core::intrinsics::abort();
#[linkage = "weak"]
#[no_mangle]
pub unsafe extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
extern "C" {
fn relibc_panic(pi: &::core::panic::PanicInfo) -> !;
}
relibc_panic(pi)
}
+7 -3
View File
@@ -1,7 +1,6 @@
//! crti
#![no_std]
#![feature(core_intrinsics)]
#![feature(global_asm)]
#![feature(linkage)]
@@ -37,6 +36,11 @@ global_asm!(r#"
"#);
#[panic_handler]
unsafe fn panic(_pi: &::core::panic::PanicInfo) -> ! {
::core::intrinsics::abort();
#[linkage = "weak"]
#[no_mangle]
pub unsafe extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
extern "C" {
fn relibc_panic(pi: &::core::panic::PanicInfo) -> !;
}
relibc_panic(pi)
}
+9 -4
View File
@@ -58,11 +58,8 @@ use platform::{Allocator, Pal, Sys};
#[global_allocator]
static ALLOCATOR: Allocator = Allocator;
#[cfg(not(test))]
#[panic_handler]
#[linkage = "weak"]
#[no_mangle]
pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
pub extern "C" fn relibc_panic(pi: &::core::panic::PanicInfo) -> ! {
use core::fmt::Write;
let mut w = platform::FileWriter(2);
@@ -71,6 +68,14 @@ pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
Sys::exit(1);
}
#[cfg(not(test))]
#[panic_handler]
#[linkage = "weak"]
#[no_mangle]
pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
relibc_panic(pi)
}
#[cfg(not(test))]
#[lang = "eh_personality"]
#[no_mangle]