Skip to content

Commit

Permalink
Add CI for no-std builds. (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Oct 31, 2023
1 parent 2153ab9 commit 7fbcf0f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,16 @@ jobs:
with:
command: check
args: --target wasm32-unknown-unknown --no-default-features
no_std:
name: no-std build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path=no_std_test/Cargo.toml
34 changes: 34 additions & 0 deletions no_std_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[workspace]

[package]
name = "no_std_test"
version = "0.1.0"
edition = "2018"
authors = ["Stephen Chung"]
description = "no-std test application"

[dependencies]
ahash = { path = "../", default_features = false }
wee_alloc = { version = "0.4.5", default_features = false }

[profile.dev]
panic = "abort"

[profile.release]
opt-level = "z" # optimize for size
debug = false
rpath = false
debug-assertions = false
codegen-units = 1
panic = "abort"

[profile.unix]
inherits = "release"
lto = true

[profile.windows]
inherits = "release"

[profile.macos]
inherits = "release"
lto = "fat"
50 changes: 50 additions & 0 deletions no_std_test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//! This is a bare-bones `no-std` application that hashes a value and
//! uses the hash value as the return value.

#![no_std]
#![feature(alloc_error_handler, start, core_intrinsics, lang_items, link_cfg)]

#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

use core::hash::{Hash, Hasher};

// NB: Rust needs a CRT runtime on Windows MSVC.
#[cfg(all(windows, target_env = "msvc"))]
#[link(name = "msvcrt")]
#[link(name = "libcmt")]
extern "C" {}

#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
let mut h: ahash::AHasher = Default::default();
42_i32.hash(&mut h);
return h.finish() as isize;
}


#[alloc_error_handler]
fn foo(_: core::alloc::Layout) -> ! {
core::intrinsics::abort();
}

#[panic_handler]
#[lang = "panic_impl"]
fn rust_begin_panic(_: &core::panic::PanicInfo) -> ! {
core::intrinsics::abort();
}

#[no_mangle]
extern "C" fn _rust_eh_personality() {}

#[no_mangle]
extern "C" fn rust_eh_personality() {}

#[no_mangle]
extern "C" fn rust_eh_register_frames() {}

#[no_mangle]
extern "C" fn rust_eh_unregister_frames() {}

#[no_mangle]
extern "C" fn _Unwind_Resume() {}

0 comments on commit 7fbcf0f

Please sign in to comment.