From 040bac6ad8104ce087784110ee43fc419bc03420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 23 Nov 2020 14:32:44 +0100 Subject: compile rust to static library --- halt/Cargo.toml | 5 +++++ halt/src/lib.rs | 19 +++++++++++++++++++ halt/src/main.rs | 26 -------------------------- 3 files changed, 24 insertions(+), 26 deletions(-) create mode 100644 halt/src/lib.rs delete mode 100644 halt/src/main.rs diff --git a/halt/Cargo.toml b/halt/Cargo.toml index 160a513..14c75e0 100644 --- a/halt/Cargo.toml +++ b/halt/Cargo.toml @@ -4,6 +4,10 @@ version = "0.1.0" authors = ["Gustav Sörnäs "] edition = "2018" +[lib] +name = "halt" +crate-type = ["staticlib"] + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [profile.dev] @@ -11,6 +15,7 @@ panic = "abort" [profile.release] panic = "abort" +lto = true [dependencies.libc] version = "0.2" diff --git a/halt/src/lib.rs b/halt/src/lib.rs new file mode 100644 index 0000000..43470b2 --- /dev/null +++ b/halt/src/lib.rs @@ -0,0 +1,19 @@ +#![no_std] +//#![feature(asm)] +//#![feature(link_args)] +//#![link_args = "-L -lpintos"] + +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +#[no_mangle] +pub unsafe extern "C" fn entry() { + exit(0x69); +} + +#[link(name="pintos", kind="static")] +extern { + fn exit(status: i32); +} diff --git a/halt/src/main.rs b/halt/src/main.rs deleted file mode 100644 index 8abf38a..0000000 --- a/halt/src/main.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![no_std] -#![no_main] -#![feature(start)] -//#![feature(asm)] -//#![link_args = "-L -lmain"] - -#[panic_handler] -fn panic(_info: &core::panic::PanicInfo) -> ! { - loop {} -} - -#[no_mangle] -pub unsafe extern "C" fn main() { - exit(0x69); -} - -#[link(name="pintos", kind="static")] -extern { - fn exit(status: i32); -} - -//#[no_mangle] -//#[start] -//unsafe extern "C" fn _start() { -// exit(main()); -//} -- cgit v1.2.1