Skip to content

Fix building no_std on Windows and Linux #201

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

Merged
merged 1 commit into from
Jul 25, 2020
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
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ jobs:
no_std_build:
name: NoStdBuild
runs-on: ${{matrix.os}}
# TODO: remove once build works.
continue-on-error: true
continue-on-error: ${{matrix.experimental}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- {os: ubuntu-latest, flags: "--profile unix -Z unstable-options", experimental: false}
- {os: windows-latest, flags: "--profile windows -Z unstable-options", experimental: true}
- {os: macos-latest, flags: "--profile macos -Z unstable-options", experimental: false}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -71,4 +73,4 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path=no_std/no_std_test/Cargo.toml
args: --manifest-path=no_std/no_std_test/Cargo.toml ${{matrix.flags}}
14 changes: 13 additions & 1 deletion no_std/no_std_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["named-profiles"]

[package]
name = "no_std_test"
version = "0.1.0"
Expand All @@ -18,7 +20,17 @@ panic = "abort"
opt-level = "z" # optimize for size
debug = false
rpath = false
lto = "fat"
debug-assertions = false
codegen-units = 1
panic = "abort"

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

[profile.windows]
inherits = "release"

[profile.macos]
inherits = "release"
lto = "fat"
4 changes: 3 additions & 1 deletion no_std/no_std_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ To Compile
The nightly compiler is required:

```bash
cargo +nightly build --release
cargo +nightly build --release --profile unix -Z unstable-features
```

Available profiles are: `unix`, `windows` and `macos`.

The release build is optimized for size. It can be changed to optimize on speed instead.
8 changes: 7 additions & 1 deletion no_std/no_std_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
//! a simple expression and uses the result as the return value.

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

extern crate alloc;
extern crate wee_alloc;

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

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

use rhai::{Engine, INT};

#[start]
Expand Down