File tree 3 files changed +21
-5
lines changed
3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,15 @@ lto = true
14
14
panic = " abort"
15
15
lto = true
16
16
17
+ [features ]
18
+ default = [" log-serial" , " log-panic" ]
19
+ # Have the log! macro write to serial output. Disabling this significantly
20
+ # reduces code size, but makes debugging essentially impossible
21
+ log-serial = []
22
+ # Log panics to serial output. Disabling this (without disabling log-serial)
23
+ # gets you most of the code size reduction, without losing _all_ debugging.
24
+ log-panic = [" log-serial" ]
25
+
17
26
[dependencies ]
18
27
cpuio = " *"
19
28
spin = " 0.4.9"
Original file line number Diff line number Diff line change @@ -54,9 +54,9 @@ impl fmt::Write for Logger {
54
54
macro_rules! log {
55
55
( $( $arg: tt) * ) => { {
56
56
use core:: fmt:: Write ;
57
- #[ cfg( not( test) ) ]
57
+ #[ cfg( all ( feature = "log-serial" , not( test) ) ) ]
58
58
writeln!( & mut crate :: logger:: LOGGER . lock( ) , $( $arg) * ) . unwrap( ) ;
59
- #[ cfg( test) ]
59
+ #[ cfg( all ( feature = "log-serial" , test) ) ]
60
60
println!( $( $arg) * ) ;
61
61
} } ;
62
62
}
Original file line number Diff line number Diff line change 15
15
#![ feature( global_asm) ]
16
16
#![ cfg_attr( not( test) , no_std) ]
17
17
#![ cfg_attr( not( test) , no_main) ]
18
- #![ cfg_attr( test, allow( unused_imports) ) ]
19
- #![ cfg_attr( test , allow( dead_code ) ) ]
18
+ #![ cfg_attr( test, allow( unused_imports, dead_code ) ) ]
19
+ #![ cfg_attr( not ( feature = "log-serial" ) , allow( unused_variables , unused_imports ) ) ]
20
20
21
21
#[ macro_use]
22
22
mod logger;
@@ -45,12 +45,19 @@ extern "C" {
45
45
fn halt_loop ( ) -> !;
46
46
}
47
47
48
- #[ cfg_attr( not( test) , panic_handler) ]
48
+ #[ cfg( all( not( test) , feature = "log-panic" ) ) ]
49
+ #[ panic_handler]
49
50
fn panic ( info : & PanicInfo ) -> ! {
50
51
log ! ( "PANIC: {}" , info) ;
51
52
unsafe { halt_loop ( ) }
52
53
}
53
54
55
+ #[ cfg( all( not( test) , not( feature = "log-panic" ) ) ) ]
56
+ #[ panic_handler]
57
+ fn panic ( _: & PanicInfo ) -> ! {
58
+ loop { }
59
+ }
60
+
54
61
/// Setup page tables to provide an identity mapping over the full 4GiB range
55
62
fn setup_pagetables ( ) {
56
63
type PageTable = [ u64 ; 512 ] ;
You can’t perform that action at this time.
0 commit comments