diff --git a/.gitignore b/.gitignore index a9d37c5..c857ba8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ -target +.#* Cargo.lock +bin/*.after +bin/*.before +bin/*.o +target diff --git a/.travis.yml b/.travis.yml index e2b3d36..1abe94d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,22 +3,23 @@ language: rust 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: beta - addons: - apt: - packages: - - gcc-arm-none-eabi + rust: stable if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) - env: TARGET=thumbv7m-none-eabi - rust: beta - addons: - apt: - packages: - - gcc-arm-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 @@ -27,24 +28,25 @@ matrix: - 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 + 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) before_install: set -e install: - bash ci/install.sh + - export PATH="$PATH:$PWD/gcc/bin" script: - bash ci/script.sh diff --git a/Cargo.toml b/Cargo.toml index 6c33b55..c69ad2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,5 @@ name = "cortex-m-semihosting" repository = "https://github.com/japaric/cortex-m-semihosting" version = "0.3.0" -[build-dependencies] -cc = "1.0.10" - [features] inline-asm = [] \ No newline at end of file diff --git a/asm.s b/asm.s index 1b6d9df..26a13fc 100644 --- a/asm.s +++ b/asm.s @@ -1,5 +1,6 @@ -.global __syscall - + .section .text.__syscall + .global __syscall + .thumb_func __syscall: bkpt 0xAB bx lr diff --git a/assemble.sh b/assemble.sh new file mode 100755 index 0000000..0d6c044 --- /dev/null +++ b/assemble.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -euxo pipefail + +# cflags taken from cc 1.0.22 + +crate=cortex-m-semihosting + +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 + +rm bin/$crate.o diff --git a/bin/thumbv6m-none-eabi.a b/bin/thumbv6m-none-eabi.a new file mode 100644 index 0000000..d01b38c Binary files /dev/null and b/bin/thumbv6m-none-eabi.a differ diff --git a/bin/thumbv7em-none-eabi.a b/bin/thumbv7em-none-eabi.a new file mode 100644 index 0000000..254b42f Binary files /dev/null and b/bin/thumbv7em-none-eabi.a differ diff --git a/bin/thumbv7em-none-eabihf.a b/bin/thumbv7em-none-eabihf.a new file mode 100644 index 0000000..254b42f Binary files /dev/null and b/bin/thumbv7em-none-eabihf.a differ diff --git a/bin/thumbv7m-none-eabi.a b/bin/thumbv7m-none-eabi.a new file mode 100644 index 0000000..5b7f5cc Binary files /dev/null and b/bin/thumbv7m-none-eabi.a differ diff --git a/build.rs b/build.rs index c2baa0e..4f4a6d6 100644 --- a/build.rs +++ b/build.rs @@ -1,13 +1,20 @@ -extern crate cc; - -use std::env; +use std::path::PathBuf; +use std::{env, fs}; fn main() { let target = env::var("TARGET").unwrap(); + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let name = env::var("CARGO_PKG_NAME").unwrap(); if target.starts_with("thumbv") { if env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() { - cc::Build::new().file("asm.s").compile("asm"); + fs::copy( + format!("bin/{}.a", target), + out_dir.join(format!("lib{}.a", name)), + ).unwrap(); + + println!("cargo:rustc-link-lib=static={}", name); + println!("cargo:rustc-link-search={}", out_dir.display()); } println!("cargo:rustc-cfg=thumb"); diff --git a/check-blobs.sh b/check-blobs.sh new file mode 100755 index 0000000..94fde42 --- /dev/null +++ b/check-blobs.sh @@ -0,0 +1,21 @@ +#!/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/ci/install.sh b/ci/install.sh index 3c41921..e63e805 100644 --- a/ci/install.sh +++ b/ci/install.sh @@ -4,6 +4,10 @@ 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/ci/script.sh b/ci/script.sh index eb1a313..dc0be46 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -6,6 +6,10 @@ main() { 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