Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI for no-std builds. #182

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {}
Loading