Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit d33ec98

Browse files
committed
remove build dependency on arm-none-eabi-gcc
by shipping pre-assembled object files. This is the same approach as the one used in rust-embedded/cortex-m#95
1 parent f4ab059 commit d33ec98

13 files changed

+71
-28
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
target
1+
.#*
22
Cargo.lock
3+
bin/*.after
4+
bin/*.before
5+
bin/*.o
6+
target

.travis.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,15 @@ language: rust
33
matrix:
44
include:
55
- env: TARGET=x86_64-unknown-linux-gnu
6+
rust: stable
67
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
78

89
- env: TARGET=thumbv6m-none-eabi
9-
rust: beta
10-
addons:
11-
apt:
12-
packages:
13-
- gcc-arm-none-eabi
10+
rust: stable
1411
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
1512

1613
- env: TARGET=thumbv7m-none-eabi
17-
rust: beta
18-
addons:
19-
apt:
20-
packages:
21-
- gcc-arm-none-eabi
14+
rust: stable
2215
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
2316

2417
- env: TARGET=x86_64-unknown-linux-gnu
@@ -27,24 +20,17 @@ matrix:
2720

2821
- env: TARGET=thumbv6m-none-eabi
2922
rust: nightly
30-
addons:
31-
apt:
32-
packages:
33-
- gcc-arm-none-eabi
3423
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
3524

3625
- env: TARGET=thumbv7m-none-eabi
3726
rust: nightly
38-
addons:
39-
apt:
40-
packages:
41-
- gcc-arm-none-eabi
4227
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
4328

4429
before_install: set -e
4530

4631
install:
4732
- bash ci/install.sh
33+
- export PATH="$PATH:$PWD/gcc/bin"
4834

4935
script:
5036
- bash ci/script.sh

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@ name = "cortex-m-semihosting"
88
repository = "https://github.com/japaric/cortex-m-semihosting"
99
version = "0.3.0"
1010

11-
[build-dependencies]
12-
cc = "1.0.10"
13-
1411
[features]
1512
inline-asm = []

asm.s

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
.global __syscall
2-
1+
.section .text.__syscall
2+
.global __syscall
3+
.thumb_func
34
__syscall:
45
bkpt 0xAB
56
bx lr

assemble.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
set -euxo pipefail
4+
5+
# cflags taken from cc 1.0.22
6+
7+
crate=cortex-m-semihosting
8+
9+
arm-none-eabi-as -march=armv6s-m asm.s -o bin/$crate.o
10+
ar crs bin/thumbv6m-none-eabi.a bin/$crate.o
11+
12+
arm-none-eabi-as -march=armv7-m asm.s -o bin/$crate.o
13+
ar crs bin/thumbv7m-none-eabi.a bin/$crate.o
14+
15+
arm-none-eabi-as -march=armv7e-m asm.s -o bin/$crate.o
16+
ar crs bin/thumbv7em-none-eabi.a bin/$crate.o
17+
ar crs bin/thumbv7em-none-eabihf.a bin/$crate.o
18+
19+
rm bin/$crate.o

bin/thumbv6m-none-eabi.a

894 Bytes
Binary file not shown.

bin/thumbv7em-none-eabi.a

894 Bytes
Binary file not shown.

bin/thumbv7em-none-eabihf.a

894 Bytes
Binary file not shown.

bin/thumbv7m-none-eabi.a

894 Bytes
Binary file not shown.

build.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
extern crate cc;
2-
3-
use std::env;
1+
use std::path::PathBuf;
2+
use std::{env, fs};
43

54
fn main() {
65
let target = env::var("TARGET").unwrap();
6+
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
7+
let name = env::var("CARGO_PKG_NAME").unwrap();
78

89
if target.starts_with("thumbv") {
910
if env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() {
10-
cc::Build::new().file("asm.s").compile("asm");
11+
fs::copy(
12+
format!("bin/{}.a", target),
13+
out_dir.join(format!("lib{}.a", name)),
14+
).unwrap();
15+
16+
println!("cargo:rustc-link-lib=static={}", name);
17+
println!("cargo:rustc-link-search={}", out_dir.display());
1118
}
1219

1320
println!("cargo:rustc-cfg=thumb");

check-blobs.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Checks that the blobs are up to date with the committed assembly files
4+
5+
set -euxo pipefail
6+
7+
for lib in $(ls bin/*.a); do
8+
filename=$(basename $lib)
9+
arm-none-eabi-objdump -Cd $lib > bin/${filename%.a}.before
10+
done
11+
12+
./assemble.sh
13+
14+
for lib in $(ls bin/*.a); do
15+
filename=$(basename $lib)
16+
arm-none-eabi-objdump -Cd $lib > bin/${filename%.a}.after
17+
done
18+
19+
for cksum in $(ls bin/*.after); do
20+
diff -u $cksum ${cksum%.after}.before
21+
done

ci/install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ main() {
44
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
55
rustup target add $TARGET
66
fi
7+
8+
mkdir gcc
9+
10+
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
711
}
812

913
main

ci/script.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ main() {
66
if [ $TRAVIS_RUST_VERSION = nightly ]; then
77
cargo check --target $TARGET --features inline-asm
88
fi
9+
10+
if [ $TARGET = x86_64-unknown-linux-gnu ]; then
11+
./check-blobs.sh
12+
fi
913
}
1014

1115
main

0 commit comments

Comments
 (0)