Skip to content

Commit

Permalink
ci: Run no-std test also on stable
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jul 29, 2023
1 parent 885adf8 commit f8d2dcb
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 12 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ jobs:

no-std:
needs: tidy
strategy:
fail-fast: false
matrix:
rust:
- stable
- nightly
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
Expand All @@ -384,6 +390,7 @@ jobs:
tool: espup
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(matrix.rust, 'nightly')
- run: |
set -euxo pipefail
sudo apt-get -o Acquire::Retries=10 -qq update && sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends \
Expand All @@ -402,9 +409,12 @@ jobs:
- run: espup install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(matrix.rust, 'nightly')
- run: tools/no-std.sh
- run: tools/build.sh +esp xtensa-esp32-none-elf
if: startsWith(matrix.rust, 'nightly')
- run: tools/no-std.sh +esp xtensa-esp32-none-elf
if: startsWith(matrix.rust, 'nightly')

miri:
needs: tidy
Expand Down
15 changes: 14 additions & 1 deletion tests/no-std-qemu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ test-helper = { path = "../helper" }
paste = "1"
semihosting = { version = "0.1", features = ["stdio", "panic-handler"] }

[target.'cfg(all(target_arch = "arm", target_feature = "mclass"))'.dependencies]
# cfg(target_feature = "mclass") is not available on stable/beta.
[target.thumbv6m-none-eabi.dependencies]
cortex-m-rt = "0.7"
[target.thumbv7m-none-eabi.dependencies]
cortex-m-rt = "0.7"
[target.thumbv7em-none-eabi.dependencies]
cortex-m-rt = "0.7"
[target.thumbv7em-none-eabihf.dependencies]
cortex-m-rt = "0.7"
[target.'thumbv8m.base-none-eabi'.dependencies]
cortex-m-rt = "0.7"
[target.'thumbv8m.main-none-eabi'.dependencies]
cortex-m-rt = "0.7"
[target.'thumbv8m.main-none-eabihf'.dependencies]
cortex-m-rt = "0.7"

[profile.dev]
Expand Down
31 changes: 31 additions & 0 deletions tests/no-std-qemu/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use std::env;

fn main() {
println!("cargo:rerun-if-changed=build.rs");

let target = &*env::var("TARGET").expect("TARGET not set");
let target_arch = &*env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set");

if target_arch == "arm" {
let mut subarch =
target.strip_prefix("arm").or_else(|| target.strip_prefix("thumb")).unwrap();
subarch = subarch.strip_prefix("eb").unwrap_or(subarch); // ignore endianness
subarch = subarch.split('-').next().unwrap(); // ignore vender/os/env
subarch = subarch.split('.').next().unwrap(); // ignore .base/.main suffix
match subarch {
"v6m" | "v7em" | "v7m" | "v8m" => println!("cargo:rustc-cfg=mclass"),
"v5te" => println!("cargo:rustc-cfg=armv5te"),
_ => {}
}
}
if target_arch.starts_with("riscv") {
let mut subarch = target.strip_prefix(target_arch).unwrap();
subarch = subarch.split('-').next().unwrap();
if subarch.contains('f') || subarch.contains('d') || subarch.contains('g') {
println!("cargo:rustc-cfg=f")
}
if subarch.contains('d') || subarch.contains('g') {
println!("cargo:rustc-cfg=d")
}
}
}
19 changes: 8 additions & 11 deletions tests/no-std-qemu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ use core::sync::atomic::Ordering;
use portable_atomic::*;
use semihosting::{print, println};

#[cfg(all(target_arch = "arm", target_feature = "mclass"))]
#[cfg(mclass)]
#[cortex_m_rt::entry]
fn main() -> ! {
run();
semihosting::process::exit(0)
}
#[cfg(not(all(target_arch = "arm", target_feature = "mclass")))]
#[cfg(not(mclass))]
#[no_mangle]
unsafe fn _start(_: usize, _: usize) -> ! {
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
unsafe {
core::arch::asm!("la sp, _stack");
}
#[cfg(all(target_arch = "arm", not(target_feature = "v6"), target_feature = "v5te"))]
#[cfg(armv5te)]
unsafe {
#[instruction_set(arm::a32)]
#[inline]
Expand Down Expand Up @@ -52,10 +52,7 @@ fn run() {
}
};
}
#[cfg_attr(
any(target_arch = "riscv32", target_arch = "riscv64"),
cfg(any(target_feature = "f", target_feature = "d"))
)]
#[cfg_attr(any(target_arch = "riscv32", target_arch = "riscv64"), cfg(f))]
macro_rules! test_atomic_float {
($float_type:ident) => {
paste::paste! {
Expand Down Expand Up @@ -90,7 +87,7 @@ fn run() {
}

// TODO: undefined reference to `__sync_synchronize'
#[cfg(not(all(target_arch = "arm", not(target_feature = "v6"))))]
#[cfg(not(armv5te))]
for &order in &test_helper::FENCE_ORDERINGS {
fence(order);
compiler_fence(order);
Expand All @@ -110,9 +107,9 @@ fn run() {
test_atomic_int!(u64);
test_atomic_int!(i128);
test_atomic_int!(u128);
// TODO
#[cfg_attr(any(target_arch = "riscv32", target_arch = "riscv64"), cfg(target_feature = "f"))]
// TODO: undefined reference to f{max,min}{,f}
#[cfg_attr(any(target_arch = "riscv32", target_arch = "riscv64"), cfg(f))]
test_atomic_float!(f32);
#[cfg_attr(any(target_arch = "riscv32", target_arch = "riscv64"), cfg(target_feature = "d"))]
#[cfg_attr(any(target_arch = "riscv32", target_arch = "riscv64"), cfg(d))]
test_atomic_float!(f64);
}

0 comments on commit f8d2dcb

Please sign in to comment.