Skip to content

Commit 7fbcf0f

Browse files
authored
Add CI for no-std builds. (tkaitchuck#182)
1 parent 2153ab9 commit 7fbcf0f

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

.github/workflows/rust.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,16 @@ jobs:
167167
with:
168168
command: check
169169
args: --target wasm32-unknown-unknown --no-default-features
170+
no_std:
171+
name: no-std build
172+
runs-on: ubuntu-latest
173+
steps:
174+
- uses: actions/checkout@v2
175+
- uses: actions-rs/toolchain@v1
176+
with:
177+
toolchain: nightly
178+
override: true
179+
- uses: actions-rs/cargo@v1
180+
with:
181+
command: build
182+
args: --manifest-path=no_std_test/Cargo.toml

no_std_test/Cargo.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[workspace]
2+
3+
[package]
4+
name = "no_std_test"
5+
version = "0.1.0"
6+
edition = "2018"
7+
authors = ["Stephen Chung"]
8+
description = "no-std test application"
9+
10+
[dependencies]
11+
ahash = { path = "../", default_features = false }
12+
wee_alloc = { version = "0.4.5", default_features = false }
13+
14+
[profile.dev]
15+
panic = "abort"
16+
17+
[profile.release]
18+
opt-level = "z" # optimize for size
19+
debug = false
20+
rpath = false
21+
debug-assertions = false
22+
codegen-units = 1
23+
panic = "abort"
24+
25+
[profile.unix]
26+
inherits = "release"
27+
lto = true
28+
29+
[profile.windows]
30+
inherits = "release"
31+
32+
[profile.macos]
33+
inherits = "release"
34+
lto = "fat"

no_std_test/src/main.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//! This is a bare-bones `no-std` application that hashes a value and
2+
//! uses the hash value as the return value.
3+
4+
#![no_std]
5+
#![feature(alloc_error_handler, start, core_intrinsics, lang_items, link_cfg)]
6+
7+
#[global_allocator]
8+
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
9+
10+
use core::hash::{Hash, Hasher};
11+
12+
// NB: Rust needs a CRT runtime on Windows MSVC.
13+
#[cfg(all(windows, target_env = "msvc"))]
14+
#[link(name = "msvcrt")]
15+
#[link(name = "libcmt")]
16+
extern "C" {}
17+
18+
#[start]
19+
fn main(_argc: isize, _argv: *const *const u8) -> isize {
20+
let mut h: ahash::AHasher = Default::default();
21+
42_i32.hash(&mut h);
22+
return h.finish() as isize;
23+
}
24+
25+
26+
#[alloc_error_handler]
27+
fn foo(_: core::alloc::Layout) -> ! {
28+
core::intrinsics::abort();
29+
}
30+
31+
#[panic_handler]
32+
#[lang = "panic_impl"]
33+
fn rust_begin_panic(_: &core::panic::PanicInfo) -> ! {
34+
core::intrinsics::abort();
35+
}
36+
37+
#[no_mangle]
38+
extern "C" fn _rust_eh_personality() {}
39+
40+
#[no_mangle]
41+
extern "C" fn rust_eh_personality() {}
42+
43+
#[no_mangle]
44+
extern "C" fn rust_eh_register_frames() {}
45+
46+
#[no_mangle]
47+
extern "C" fn rust_eh_unregister_frames() {}
48+
49+
#[no_mangle]
50+
extern "C" fn _Unwind_Resume() {}

0 commit comments

Comments
 (0)