diff --git a/Cargo.lock b/Cargo.lock index 148ae426d1..072da425a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,9 +82,6 @@ dependencies = [ [[package]] name = "crt0" version = "0.1.0" -dependencies = [ - "relibc 0.1.0", -] [[package]] name = "crti" diff --git a/Makefile b/Makefile index da3f4d01a0..e00cde7121 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/src/crt0/Cargo.toml b/src/crt0/Cargo.toml index 9b6c91a2bf..8c4bfad227 100644 --- a/src/crt0/Cargo.toml +++ b/src/crt0/Cargo.toml @@ -6,6 +6,3 @@ authors = ["Jeremy Soller "] [lib] name = "crt0" crate-type = ["staticlib"] - -[dependencies] -relibc = { path = "../.." } diff --git a/src/crt0/src/lib.rs b/src/crt0/src/lib.rs index 6b8c255227..85f1c5a1e4 100644 --- a/src/crt0/src/lib.rs +++ b/src/crt0/src/lib.rs @@ -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) } diff --git a/src/crti/src/lib.rs b/src/crti/src/lib.rs index 4f1d7a6eba..4a01af5009 100644 --- a/src/crti/src/lib.rs +++ b/src/crti/src/lib.rs @@ -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) } diff --git a/src/crtn/src/lib.rs b/src/crtn/src/lib.rs index e62acc6531..4462e5dd52 100644 --- a/src/crtn/src/lib.rs +++ b/src/crtn/src/lib.rs @@ -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) } diff --git a/src/lib.rs b/src/lib.rs index 7cc40f81cd..b3757e1909 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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]