diff options
author | 2020-09-01 22:58:22 +0200 | |
---|---|---|
committer | 2020-10-13 21:31:37 +0200 | |
commit | cab2e28f674901cd87d4f88f7eb5ba32d3517b35 (patch) | |
tree | cacc3652c5fda7f5830319abfe88b063e33f5fa3 | |
parent | 9bc9be611b262edf5c7811235e16bdbcbb3509cf (diff) | |
download | cortex-m-cab2e28f674901cd87d4f88f7eb5ba32d3517b35.tar.gz cortex-m-cab2e28f674901cd87d4f88f7eb5ba32d3517b35.tar.zst cortex-m-cab2e28f674901cd87d4f88f7eb5ba32d3517b35.zip |
Integrate semihosting crates
30 files changed, 70 insertions, 385 deletions
diff --git a/cortex-m-semihosting/.github/CODEOWNERS b/cortex-m-semihosting/.github/CODEOWNERS deleted file mode 100644 index d810925..0000000 --- a/cortex-m-semihosting/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @rust-embedded/cortex-m
\ No newline at end of file diff --git a/cortex-m-semihosting/.github/bors.toml b/cortex-m-semihosting/.github/bors.toml deleted file mode 100644 index ca42be0..0000000 --- a/cortex-m-semihosting/.github/bors.toml +++ /dev/null @@ -1,4 +0,0 @@ -block_labels = ["needs-decision"] -delete_merged_branches = true -required_approvals = 1 -status = ["continuous-integration/travis-ci/push"] diff --git a/cortex-m-semihosting/.gitignore b/cortex-m-semihosting/.gitignore deleted file mode 100644 index c857ba8..0000000 --- a/cortex-m-semihosting/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.#* -Cargo.lock -bin/*.after -bin/*.before -bin/*.o -target diff --git a/cortex-m-semihosting/.travis.yml b/cortex-m-semihosting/.travis.yml deleted file mode 100644 index 4ca6a3a..0000000 --- a/cortex-m-semihosting/.travis.yml +++ /dev/null @@ -1,107 +0,0 @@ -language: rust - -env: - global: - - RUSTFLAGS="-D warnings" - -matrix: - include: - - env: TARGET=x86_64-unknown-linux-gnu - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv6m-none-eabi - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7m-none-eabi - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabi - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabihf - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv8m.main-none-eabi - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=x86_64-unknown-linux-gnu - rust: nightly - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv6m-none-eabi - rust: nightly - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7m-none-eabi - rust: nightly - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabi - rust: nightly - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabihf - rust: nightly - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv8m.main-none-eabi - rust: nightly - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - # MSRV - - env: TARGET=x86_64-unknown-linux-gnu - rust: 1.33.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv6m-none-eabi - rust: 1.33.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7m-none-eabi - rust: 1.33.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabi - rust: 1.33.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabihf - rust: 1.33.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv8m.main-none-eabi - rust: 1.33.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - -before_install: set -e - -install: - - bash ci/install.sh - - export PATH="$PATH:$PWD/gcc/bin" - -script: - - bash ci/script.sh - -after_script: set +e - -cache: cargo -before_cache: - # Travis can't cache files that are not readable by "others" - - chmod -R a+r $HOME/.cargo - -branches: - only: - - master - - staging - - trying - -notifications: - email: - on_success: never diff --git a/cortex-m-semihosting/Cargo.toml b/cortex-m-semihosting/Cargo.toml index 2885d3f..4343bdf 100644 --- a/cortex-m-semihosting/Cargo.toml +++ b/cortex-m-semihosting/Cargo.toml @@ -19,4 +19,4 @@ jlink-quirks = [] no-semihosting = [] [dependencies] -cortex-m = ">= 0.5.8, < 0.7" +cortex-m = { path = "..", version = ">= 0.5.8, < 0.7" } diff --git a/cortex-m-semihosting/asm.s b/cortex-m-semihosting/asm.s deleted file mode 100644 index 26a13fc..0000000 --- a/cortex-m-semihosting/asm.s +++ /dev/null @@ -1,6 +0,0 @@ - .section .text.__syscall - .global __syscall - .thumb_func -__syscall: - bkpt 0xAB - bx lr diff --git a/cortex-m-semihosting/assemble.sh b/cortex-m-semihosting/assemble.sh deleted file mode 100755 index f77acf6..0000000 --- a/cortex-m-semihosting/assemble.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -# cflags taken from cc 1.0.22 - -crate=cortex-m-semihosting - -# remove existing blobs because otherwise this will append object files to the old blobs -rm -f bin/*.a - -arm-none-eabi-as -march=armv6s-m asm.s -o bin/$crate.o -ar crs bin/thumbv6m-none-eabi.a bin/$crate.o - -arm-none-eabi-as -march=armv7-m asm.s -o bin/$crate.o -ar crs bin/thumbv7m-none-eabi.a bin/$crate.o - -arm-none-eabi-as -march=armv7e-m asm.s -o bin/$crate.o -ar crs bin/thumbv7em-none-eabi.a bin/$crate.o -ar crs bin/thumbv7em-none-eabihf.a bin/$crate.o - -arm-none-eabi-as -march=armv8-m.base asm.s -o bin/$crate.o -ar crs bin/thumbv8m.base-none-eabi.a bin/$crate.o - -arm-none-eabi-as -march=armv8-m.main asm.s -o bin/$crate.o -ar crs bin/thumbv8m.main-none-eabi.a bin/$crate.o -ar crs bin/thumbv8m.main-none-eabihf.a bin/$crate.o - -rm bin/$crate.o diff --git a/cortex-m-semihosting/bin/thumbv6m-none-eabi.a b/cortex-m-semihosting/bin/thumbv6m-none-eabi.a Binary files differdeleted file mode 100644 index d01b38c..0000000 --- a/cortex-m-semihosting/bin/thumbv6m-none-eabi.a +++ /dev/null diff --git a/cortex-m-semihosting/bin/thumbv7em-none-eabi.a b/cortex-m-semihosting/bin/thumbv7em-none-eabi.a Binary files differdeleted file mode 100644 index 254b42f..0000000 --- a/cortex-m-semihosting/bin/thumbv7em-none-eabi.a +++ /dev/null diff --git a/cortex-m-semihosting/bin/thumbv7em-none-eabihf.a b/cortex-m-semihosting/bin/thumbv7em-none-eabihf.a Binary files differdeleted file mode 100644 index 254b42f..0000000 --- a/cortex-m-semihosting/bin/thumbv7em-none-eabihf.a +++ /dev/null diff --git a/cortex-m-semihosting/bin/thumbv7m-none-eabi.a b/cortex-m-semihosting/bin/thumbv7m-none-eabi.a Binary files differdeleted file mode 100644 index 5b7f5cc..0000000 --- a/cortex-m-semihosting/bin/thumbv7m-none-eabi.a +++ /dev/null diff --git a/cortex-m-semihosting/bin/thumbv8m.base-none-eabi.a b/cortex-m-semihosting/bin/thumbv8m.base-none-eabi.a Binary files differdeleted file mode 100644 index 496a9c8..0000000 --- a/cortex-m-semihosting/bin/thumbv8m.base-none-eabi.a +++ /dev/null diff --git a/cortex-m-semihosting/bin/thumbv8m.main-none-eabi.a b/cortex-m-semihosting/bin/thumbv8m.main-none-eabi.a Binary files differdeleted file mode 100644 index 1d2a03a..0000000 --- a/cortex-m-semihosting/bin/thumbv8m.main-none-eabi.a +++ /dev/null diff --git a/cortex-m-semihosting/bin/thumbv8m.main-none-eabihf.a b/cortex-m-semihosting/bin/thumbv8m.main-none-eabihf.a Binary files differdeleted file mode 100644 index 1d2a03a..0000000 --- a/cortex-m-semihosting/bin/thumbv8m.main-none-eabihf.a +++ /dev/null diff --git a/cortex-m-semihosting/build.rs b/cortex-m-semihosting/build.rs index 4f4a6d6..5fc6a04 100644 --- a/cortex-m-semihosting/build.rs +++ b/cortex-m-semihosting/build.rs @@ -9,9 +9,10 @@ fn main() { if target.starts_with("thumbv") { if env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() { fs::copy( - format!("bin/{}.a", target), + format!("../bin/{}.a", target), out_dir.join(format!("lib{}.a", name)), - ).unwrap(); + ) + .unwrap(); println!("cargo:rustc-link-lib=static={}", name); println!("cargo:rustc-link-search={}", out_dir.display()); diff --git a/cortex-m-semihosting/check-blobs.sh b/cortex-m-semihosting/check-blobs.sh deleted file mode 100755 index 94fde42..0000000 --- a/cortex-m-semihosting/check-blobs.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Checks that the blobs are up to date with the committed assembly files - -set -euxo pipefail - -for lib in $(ls bin/*.a); do - filename=$(basename $lib) - arm-none-eabi-objdump -Cd $lib > bin/${filename%.a}.before -done - -./assemble.sh - -for lib in $(ls bin/*.a); do - filename=$(basename $lib) - arm-none-eabi-objdump -Cd $lib > bin/${filename%.a}.after -done - -for cksum in $(ls bin/*.after); do - diff -u $cksum ${cksum%.after}.before -done diff --git a/cortex-m-semihosting/ci/install.sh b/cortex-m-semihosting/ci/install.sh deleted file mode 100644 index e63e805..0000000 --- a/cortex-m-semihosting/ci/install.sh +++ /dev/null @@ -1,13 +0,0 @@ -set -euxo pipefail - -main() { - if [ $TARGET != x86_64-unknown-linux-gnu ]; then - rustup target add $TARGET - fi - - mkdir gcc - - curl -L https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2?revision=bc2c96c0-14b5-4bb4-9f18-bceb4050fee7?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,7-2018-q2-update | tar --strip-components=1 -C gcc -xj -} - -main diff --git a/cortex-m-semihosting/ci/script.sh b/cortex-m-semihosting/ci/script.sh deleted file mode 100644 index dc0be46..0000000 --- a/cortex-m-semihosting/ci/script.sh +++ /dev/null @@ -1,15 +0,0 @@ -set -euxo pipefail - -main() { - cargo check --target $TARGET - - if [ $TRAVIS_RUST_VERSION = nightly ]; then - cargo check --target $TARGET --features inline-asm - fi - - if [ $TARGET = x86_64-unknown-linux-gnu ]; then - ./check-blobs.sh - fi -} - -main diff --git a/cortex-m-semihosting/triagebot.toml b/cortex-m-semihosting/triagebot.toml deleted file mode 100644 index fa0824a..0000000 --- a/cortex-m-semihosting/triagebot.toml +++ /dev/null @@ -1 +0,0 @@ -[assign] diff --git a/panic-semihosting/.github/CODEOWNERS b/panic-semihosting/.github/CODEOWNERS deleted file mode 100644 index d810925..0000000 --- a/panic-semihosting/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @rust-embedded/cortex-m
\ No newline at end of file diff --git a/panic-semihosting/.github/bors.toml b/panic-semihosting/.github/bors.toml deleted file mode 100644 index ca42be0..0000000 --- a/panic-semihosting/.github/bors.toml +++ /dev/null @@ -1,4 +0,0 @@ -block_labels = ["needs-decision"] -delete_merged_branches = true -required_approvals = 1 -status = ["continuous-integration/travis-ci/push"] diff --git a/panic-semihosting/.gitignore b/panic-semihosting/.gitignore deleted file mode 100644 index 2691a8f..0000000 --- a/panic-semihosting/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -**/*.rs.bk -.#* -/target -Cargo.lock diff --git a/panic-semihosting/.travis.yml b/panic-semihosting/.travis.yml deleted file mode 100644 index 9121565..0000000 --- a/panic-semihosting/.travis.yml +++ /dev/null @@ -1,105 +0,0 @@ -language: rust - -matrix: - include: - - env: TARGET=x86_64-unknown-linux-gnu - rust: stable - - - env: TARGET=thumbv6m-none-eabi - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7m-none-eabi - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabi - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabihf - rust: stable - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=x86_64-unknown-linux-gnu - rust: nightly - - - env: TARGET=thumbv6m-none-eabi - rust: nightly - addons: - apt: - packages: - - gcc-arm-none-eabi - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7m-none-eabi - rust: nightly - addons: - apt: - packages: - - gcc-arm-none-eabi - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabi - rust: nightly - addons: - apt: - packages: - - gcc-arm-none-eabi - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabihf - rust: nightly - addons: - apt: - packages: - - gcc-arm-none-eabi - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - # MSRV - - env: TARGET=x86_64-unknown-linux-gnu - rust: 1.32.0 - - - env: TARGET=thumbv6m-none-eabi - rust: 1.32.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7m-none-eabi - rust: 1.32.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabi - rust: 1.32.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - - - env: TARGET=thumbv7em-none-eabihf - rust: 1.32.0 - if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - -before_install: set -e - -install: - - bash ci/install.sh - -script: - - bash ci/script.sh - -after_success: - - bash ci/after-success.sh - -after_script: set +e - -cache: cargo - -before_cache: - - chmod -R a+r $HOME/.cargo; - -branches: - only: - - master - - staging - - trying - -notifications: - email: - on_success: never diff --git a/panic-semihosting/Cargo.toml b/panic-semihosting/Cargo.toml index 708c029..c09bced 100644 --- a/panic-semihosting/Cargo.toml +++ b/panic-semihosting/Cargo.toml @@ -13,8 +13,8 @@ repository = "https://github.com/rust-embedded/panic-semihosting" version = "0.5.3" [dependencies] -cortex-m = ">= 0.5.6, < 0.7" -cortex-m-semihosting = "0.3" +cortex-m = { path = "..", version = ">= 0.5.6, < 0.7" } +cortex-m-semihosting = { path = "../cortex-m-semihosting", version = "0.3" } [features] exit = [] diff --git a/panic-semihosting/ci/after-success.sh b/panic-semihosting/ci/after-success.sh deleted file mode 100644 index 4377267..0000000 --- a/panic-semihosting/ci/after-success.sh +++ /dev/null @@ -1,20 +0,0 @@ -set -euxo pipefail - -main() { - cargo doc - - mkdir ghp-import - - curl -Ls https://github.com/davisp/ghp-import/archive/master.tar.gz | - tar --strip-components 1 -C ghp-import -xz - - ./ghp-import/ghp_import.py target/doc - - set +x - git push -fq https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git gh-pages && echo OK -} - -# only publish on successful merges to master -if [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TARGET = x86_64-unknown-linux-gnu ]; then - main -fi diff --git a/panic-semihosting/ci/install.sh b/panic-semihosting/ci/install.sh deleted file mode 100644 index 3c41921..0000000 --- a/panic-semihosting/ci/install.sh +++ /dev/null @@ -1,9 +0,0 @@ -set -euxo pipefail - -main() { - if [ $TARGET != x86_64-unknown-linux-gnu ]; then - rustup target add $TARGET - fi -} - -main diff --git a/panic-semihosting/ci/script.sh b/panic-semihosting/ci/script.sh deleted file mode 100644 index eb1a313..0000000 --- a/panic-semihosting/ci/script.sh +++ /dev/null @@ -1,11 +0,0 @@ -set -euxo pipefail - -main() { - cargo check --target $TARGET - - if [ $TRAVIS_RUST_VERSION = nightly ]; then - cargo check --target $TARGET --features inline-asm - fi -} - -main diff --git a/panic-semihosting/src/lib.rs b/panic-semihosting/src/lib.rs index 71d2774..1db7b72 100644 --- a/panic-semihosting/src/lib.rs +++ b/panic-semihosting/src/lib.rs @@ -56,6 +56,7 @@ //! When this feature is disabled semihosting is implemented using FFI calls into an external //! assembly file and compiling this crate works on stable and beta. +#![cfg(all(target_arch = "arm", target_os = "none"))] #![deny(missing_docs)] #![deny(warnings)] #![no_std] diff --git a/panic-semihosting/triagebot.toml b/panic-semihosting/triagebot.toml deleted file mode 100644 index fa0824a..0000000 --- a/panic-semihosting/triagebot.toml +++ /dev/null @@ -1 +0,0 @@ -[assign] diff --git a/xtask/tests/ci.rs b/xtask/tests/ci.rs index 48356e4..5b449ba 100644 --- a/xtask/tests/ci.rs +++ b/xtask/tests/ci.rs @@ -2,6 +2,9 @@ use std::process::Command; use std::{env, str}; use xtask::{check_blobs, install_targets}; +/// List of all compilation targets we support. +/// +/// This should generally list all of the bare-metal thumb targets starting at thumbv6. static TARGETS: &[&str] = &[ "thumbv6m-none-eabi", "thumbv7m-none-eabi", @@ -12,16 +15,71 @@ static TARGETS: &[&str] = &[ "thumbv8m.main-none-eabihf", ]; -fn build(target: &str, features: &[&str]) { - println!("building for {} {:?}", target, features); +fn build(package: &str, target: &str, features: &[&str]) { + println!("building {} for {} {:?}", package, target, features); let mut cargo = Command::new("cargo"); - cargo.args(&["build", "--target", target]); + cargo.args(&["build", "-p", package, "--target", target]); for feat in features { cargo.args(&["--features", *feat]); } + // Cargo features don't work right when invoked from the workspace root, so change to the + // package's directory when necessary. + if package != "cortex-m" { + cargo.current_dir(package); + } + let status = cargo.status().unwrap(); - assert!(status.success()); + assert!(status.success(), "failed to execute: {:?}", cargo); +} + +#[rustfmt::skip] +static PACKAGE_FEATURES: &[(&str, &[&str])] = &[ + ("cortex-m", &["inline-asm", "cm7-r0p1"]), // no `linker-plugin-lto` since it's experimental + ("cortex-m-semihosting", &["inline-asm", "no-semihosting", "jlink-quirks"]), + ("panic-semihosting", &["inline-asm", "exit", "jlink-quirks"]), +]; + +fn check_crates_build(is_nightly: bool) { + // Build all crates for each supported target. + for &target in TARGETS { + // Filters crate features, keeping only those that are supported. + // Relies on all crates in this repo to use the same convention. + let should_use_feature = |feat: &str| { + match feat { + // This is nightly-only, so don't use it on stable. + "inline-asm" => is_nightly, + // This only affects thumbv7em targets. + "cm7-r0p1" => target.starts_with("thumbv7em"), + + _ => true, + } + }; + + for (package, all_features) in PACKAGE_FEATURES { + // Every crate must build with the default feature set. + build(package, target, &[]); + + let used_features = &*all_features + .iter() + .copied() + .filter(|feat| should_use_feature(*feat)) + .collect::<Vec<_>>(); + + // (note: we don't test with default features disabled, since we don't use them yet) + + // Every crate must build with each individual feature enabled. + for feat in used_features { + build(package, target, &[*feat]); + } + + // Every crate must build with *all* features enabled. + build(package, target, used_features); + + // (technically we should be checking the powerset of all features if we wanted to be + // *really* sure, but that takes too much time and isn't very easy to implement) + } + } } fn main() { @@ -36,22 +94,5 @@ fn main() { let output = Command::new("rustc").arg("-V").output().unwrap(); let is_nightly = str::from_utf8(&output.stdout).unwrap().contains("nightly"); - // Build `cortex-m` for each supported target. - for target in TARGETS { - build(*target, &[]); - - if is_nightly { - // This may fail when nightly breaks. That's fine, the CI job isn't essential. - build(*target, &["inline-asm"]); - } - - if target.starts_with("thumbv7em") { - // These can target Cortex-M7s, which have an errata workaround. - build(*target, &["cm7-r0p1"]); - - if is_nightly { - build(*target, &["inline-asm", "cm7-r0p1"]); - } - } - } + check_crates_build(is_nightly); } |