Compile the entry point when using an IDE
diff --git a/src/entry_point/mod.rs b/src/entry_point/mod.rs index 6d299dd..cc5f402 100644 --- a/src/entry_point/mod.rs +++ b/src/entry_point/mod.rs
@@ -85,7 +85,7 @@ /// into the rustc-generated main(). This cannot use mutable global variables or /// global references to globals until it is done setting up the data segment. #[no_mangle] -pub unsafe extern "C" fn rust_start(app_start: usize, stacktop: usize, app_heap_break: usize) -> ! { +unsafe extern "C" fn rust_start(app_start: usize, stacktop: usize, app_heap_break: usize) -> ! { extern "C" { // This function is created internally by `rustc`. See // `src/lang_items.rs` for more details. @@ -146,12 +146,9 @@ use core::ptr::NonNull; use linked_list_allocator::Heap; -#[global_allocator] -static ALLOCATOR: TockAllocator = TockAllocator; - static mut HEAP: Heap = Heap::empty(); -struct TockAllocator; +pub struct TockAllocator; unsafe impl GlobalAlloc for TockAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
diff --git a/src/lang_items.rs b/src/lang_items.rs index ad3e714..4f8d947 100644 --- a/src/lang_items.rs +++ b/src/lang_items.rs
@@ -18,6 +18,7 @@ //! `rustc_main`. That's covered by the `_start` function in the root of this //! crate. +use crate::entry_point::TockAllocator; use crate::leds::LedsDriver; use crate::result::TockResult; use crate::timer::Duration; @@ -82,6 +83,9 @@ } } +#[global_allocator] +static ALLOCATOR: TockAllocator = TockAllocator; + #[alloc_error_handler] unsafe fn alloc_error_handler(_: Layout) -> ! { executor::block_on(async {
diff --git a/src/lib.rs b/src/lib.rs index ec3ffd4..6752ea8 100644 --- a/src/lib.rs +++ b/src/lib.rs
@@ -1,6 +1,11 @@ #![feature(asm, alloc_error_handler, lang_items, naked_functions)] #![cfg_attr(any(target_arch = "arm", target_arch = "riscv32"), no_std)] +mod drivers; +mod entry_point; +#[cfg(any(target_arch = "arm", target_arch = "riscv32"))] +mod lang_items; + pub mod adc; pub mod ble_composer; pub mod ble_parser; @@ -18,19 +23,10 @@ pub mod sensors; pub mod shared_memory; pub mod simple_ble; +pub mod syscalls; pub mod temperature; pub mod timer; pub mod unwind_symbols; -#[cfg(any(target_arch = "arm", target_arch = "riscv32"))] -pub mod entry_point; - -#[cfg(any(target_arch = "arm", target_arch = "riscv32"))] -mod lang_items; - -pub mod syscalls; - -pub use libtock_codegen::main; - -pub(crate) mod drivers; pub use drivers::*; +pub use libtock_codegen::main;
diff --git a/src/unwind_symbols.rs b/src/unwind_symbols.rs index 98debbe..4215626 100644 --- a/src/unwind_symbols.rs +++ b/src/unwind_symbols.rs
@@ -1,3 +1,5 @@ +#![doc(hidden)] + // The stack unwinding ABI in ARM is specified as part of EABI. Although // libunwind has not been ported to Tock OS (and likely will not be), LLVM still // assumes some of the symbols are present. This causes linking errors @@ -6,6 +8,7 @@ // functions; for example, the Linux Kernel does so in arch/arm/kernel/unwind.c. // We do so here as well. The addition of these symbols to libtock-rs was // discussed at https://groups.google.com/forum/#!topic/tock-dev/eov8fJmskLk. + #[cfg(target_arch = "arm")] #[no_mangle] pub extern "C" fn __aeabi_unwind_cpp_pr0() {}