-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix nightly no_std * Fix nightly no_std
- Loading branch information
Showing
11 changed files
with
187 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use rustc_version::{version_meta, Channel}; | ||
|
||
fn main() { | ||
let version_meta = version_meta().unwrap(); | ||
|
||
// To use nightly features we declare this and then we can use | ||
// #[cfg(nightly)] | ||
// for nightly only features | ||
if version_meta.channel == Channel::Nightly { | ||
println!("cargo:rustc-cfg=nightly") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[build] | ||
target = "thumbv7m-none-eabi" | ||
|
||
[unstable] | ||
build-std = ["core", "alloc"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "rust_test_no_std_compilation" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
flatbuffers = { path = "../../rust/flatbuffers", default-features = false } | ||
|
||
[profile.dev] | ||
panic = "abort" | ||
|
||
[profile.release] | ||
panic = "abort" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![no_std] | ||
#![no_main] | ||
#![feature(default_alloc_error_handler)] | ||
|
||
// Include flatbuffers purely to check that it compiles in a no_std binary | ||
#[allow(unused_imports)] | ||
use flatbuffers; | ||
|
||
// The rest is just no_std boilerplate | ||
|
||
use core::alloc::{GlobalAlloc, Layout}; | ||
|
||
struct NullAllocator; | ||
unsafe impl GlobalAlloc for NullAllocator { | ||
unsafe fn alloc(&self, _lt: Layout) -> *mut u8 { | ||
core::ptr::null_mut() | ||
} | ||
unsafe fn dealloc(&self, _ptr: *mut u8, _lt: Layout) { | ||
panic!("won't deallocate: we never allocated!"); | ||
} | ||
} | ||
|
||
#[global_allocator] | ||
static A: NullAllocator = NullAllocator; | ||
|
||
#[panic_handler] | ||
fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
loop {} | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 { | ||
0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters