From 0ca7fe6f12337dfee49f8923e5aa79157ef14206 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 18 Aug 2020 12:10:46 +0800 Subject: [PATCH] kernel/loader: fix build arguments Signed-off-by: Sean Cross --- kernel/.cargo/config | 6 ++++++ kernel/Cargo.toml | 4 ++-- kernel/src/mem.rs | 21 +++++++++++++++------ loader/.cargo/config | 4 ++++ loader/Cargo.toml | 3 +-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/kernel/.cargo/config b/kernel/.cargo/config index b21225b35..0274614de 100644 --- a/kernel/.cargo/config +++ b/kernel/.cargo/config @@ -1,16 +1,22 @@ [target.riscv32i-unknown-none-elf] rustflags = [ "-C", "link-arg=-Tlink.x", + "-C", "linker-plugin-lto=yes", + "-C", "force-frame-pointers=no", ] [target.riscv32imac-unknown-none-elf] rustflags = [ "-C", "link-arg=-Tlink.x", + "-C", "linker-plugin-lto=yes", + "-C", "force-frame-pointers=no", ] [target.riscv32imac-unknown-xous-elf] rustflags = [ "-C", "link-arg=-Tlink.x", + "-C", "linker-plugin-lto=yes", + "-C", "force-frame-pointers=no", ] [build] diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 68aa3b9f9..f03771675 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -17,6 +17,7 @@ riscv = "0.5.6" [features] debug-print = [] report-memory = ["stats_alloc"] +#default = ["debug-print"] [target.'cfg(any(windows, unix))'.dependencies] lazy_static = "1.4" @@ -27,5 +28,4 @@ debug-here = "0.2.2" [profile.release] codegen-units = 1 # 1 better optimizations debug = true # symbols are nice and they don't increase the size on Flash -lto = thin -force-frame-pointers = no +lto = "thin" diff --git a/kernel/src/mem.rs b/kernel/src/mem.rs index 6dd11aaf2..63e9a0704 100644 --- a/kernel/src/mem.rs +++ b/kernel/src/mem.rs @@ -164,7 +164,9 @@ impl MemoryManager { #[cfg(all(baremetal, feature = "print-debug"))] pub fn print_ownership(&self) { - println!("Ownership ({} bytes in all):", unsafe { MEMORY_ALLOCATIONS.len() }); + println!("Ownership ({} bytes in all):", unsafe { + MEMORY_ALLOCATIONS.len() + }); let mut offset = 0; unsafe { @@ -342,7 +344,8 @@ impl MemoryManager { ) -> Result { // If no address was specified, pick the next address that fits // in the "default" range - let virt = self.find_virtual_address(virt_ptr, size, xous_kernel::MemoryType::Default)? as usize; + let virt = + self.find_virtual_address(virt_ptr, size, xous_kernel::MemoryType::Default)? as usize; if virt & 0xfff != 0 { return Err(xous_kernel::Error::BadAlignment); @@ -363,10 +366,16 @@ impl MemoryManager { /// Attempt to allocate a single page from the default section. /// Note that this will be backed by a real page. #[cfg(baremetal)] - pub fn map_zeroed_page(&mut self, pid: PID, is_user: bool) -> Result<*mut usize, xous_kernel::Error> { - let virt = - self.find_virtual_address(core::ptr::null_mut(), PAGE_SIZE, xous_kernel::MemoryType::Default)? - as usize; + pub fn map_zeroed_page( + &mut self, + pid: PID, + is_user: bool, + ) -> Result<*mut usize, xous_kernel::Error> { + let virt = self.find_virtual_address( + core::ptr::null_mut(), + PAGE_SIZE, + xous_kernel::MemoryType::Default, + )? as usize; // Grab the next available page. This claims it for this process. let phys = self.alloc_page(pid)?; diff --git a/loader/.cargo/config b/loader/.cargo/config index 8249d0bed..d1abc7dae 100644 --- a/loader/.cargo/config +++ b/loader/.cargo/config @@ -1,9 +1,13 @@ [target.riscv32i-unknown-none-elf] rustflags = [ "-C", "link-arg=-Tlink.x", + "-C", "linker-plugin-lto=yes", + "-C", "force-frame-pointers=no", ] [target.riscv32imac-unknown-none-elf] rustflags = [ "-C", "link-arg=-Tlink.x", + "-C", "linker-plugin-lto=yes", + "-C", "force-frame-pointers=no", ] diff --git a/loader/Cargo.toml b/loader/Cargo.toml index a2375f87f..0829947fd 100644 --- a/loader/Cargo.toml +++ b/loader/Cargo.toml @@ -18,5 +18,4 @@ earlyprintk = [] [profile.release] codegen-units = 1 # 1 better optimizations debug = true # symbols are nice and they don't increase the size on Flash -lto = thin -force-frame-pointers = no +lto = "thin"