diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 95466e13..49318e1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -71,4 +73,4 @@ jobs: uses: actions-rs/cargo@v1 with: command: build - args: --manifest-path=no_std/no_std_test/Cargo.toml \ No newline at end of file + args: --manifest-path=no_std/no_std_test/Cargo.toml ${{matrix.flags}} diff --git a/no_std/no_std_test/Cargo.toml b/no_std/no_std_test/Cargo.toml index 4b151047..89a15bbb 100644 --- a/no_std/no_std_test/Cargo.toml +++ b/no_std/no_std_test/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["named-profiles"] + [package] name = "no_std_test" version = "0.1.0" @@ -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" diff --git a/no_std/no_std_test/README.md b/no_std/no_std_test/README.md index e7edfc51..0a12e48b 100644 --- a/no_std/no_std_test/README.md +++ b/no_std/no_std_test/README.md @@ -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. diff --git a/no_std/no_std_test/src/main.rs b/no_std/no_std_test/src/main.rs index 829802f8..3db95447 100644 --- a/no_std/no_std_test/src/main.rs +++ b/no_std/no_std_test/src/main.rs @@ -2,7 +2,7 @@ //! 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; @@ -10,6 +10,12 @@ 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]