szl: reduced binary size.
* Compiled unlzma with -Oz and enable LTO. * Changed one unwrap to manual handling to remove fmt code. * Implemented custom panic handler with minimal code.
This commit is contained in:
parent
3a8a025d5f
commit
7342736124
@ -13,7 +13,7 @@ default = ["target_zc706"]
|
||||
log = "0.4"
|
||||
cstr_core = { version = "0.2", default-features = false }
|
||||
libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" }
|
||||
libsupport_zynq = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" }
|
||||
libsupport_zynq = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", default-features = false, features = ["dummy_irq_handler"] }
|
||||
libcortex_a9 = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" }
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -32,7 +32,8 @@ pub fn compile_unlzma() {
|
||||
cfg.flag("-fPIC");
|
||||
cfg.flag("-fno-stack-protector");
|
||||
cfg.flag("--target=armv7-none-eabihf");
|
||||
cfg.flag("-Os");
|
||||
cfg.flag("-Oz");
|
||||
cfg.flag("-flto=full");
|
||||
|
||||
let sources = vec![
|
||||
"unlzma.c",
|
||||
|
@ -1,5 +1,6 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(panic_info_message)]
|
||||
|
||||
extern crate log;
|
||||
|
||||
@ -15,6 +16,7 @@ use libcortex_a9::{
|
||||
use libboard_zynq::{
|
||||
self as zynq, println,
|
||||
clocks::Clocks, clocks::source::{ClockSource, ArmPll, IoPll},
|
||||
stdio,
|
||||
logger,
|
||||
timer::GlobalTimer,
|
||||
};
|
||||
@ -28,7 +30,17 @@ extern "C" {
|
||||
}
|
||||
|
||||
extern fn lzma_error(message: *const u8) {
|
||||
error!("LZMA error: {}", unsafe { CStr::from_ptr(message) }.to_str().unwrap());
|
||||
let msg = unsafe {CStr::from_ptr(message)}.to_str();
|
||||
if let Ok(msg) = msg {
|
||||
println!("LZMA error: {}", msg);
|
||||
}
|
||||
}
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_: &core::panic::PanicInfo) -> ! {
|
||||
stdio::drop_uart();
|
||||
println!("panicked!");
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
Loading…
Reference in New Issue
Block a user