Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

[RFC] remove build dependency on arm-none-eabi-gcc (binary blob alternative) #95

Merged
merged 8 commits into from
Aug 26, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/*.rs.bk
Cargo.lock
bin/*.o
target/
16 changes: 0 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,18 @@ matrix:
rust: stable
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv6m-none-eabi CC=clang
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=thumbv7m-none-eabi CC=clang
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-eabi CC=clang
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=thumbv7em-none-eabihf CC=clang
rust: stable
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)
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ name = "cortex-m-rt"
repository = "https://github.com/japaric/cortex-m-rt"
version = "0.5.2"

[build-dependencies]
cc = "1.0.10"

[dependencies]
r0 = "0.2.1"

Expand Down
1 change: 1 addition & 0 deletions asm.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.section .text.HardFault
.global HardFault
.thumb_func
HardFault:
Expand Down
19 changes: 19 additions & 0 deletions assemble.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -euxo pipefail

# cflags taken from cc 1.0.22

crate=cortex-m-rt

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
Binary file added bin/thumbv6m-none-eabi.a
Binary file not shown.
Binary file added bin/thumbv7em-none-eabi.a
Binary file not shown.
Binary file added bin/thumbv7em-none-eabihf.a
Binary file not shown.
Binary file added bin/thumbv7m-none-eabi.a
Binary file not shown.
11 changes: 7 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
extern crate cc;

use std::env;
use std::fs::File;
use std::fs::{self, File};
use std::io::Write;
use std::path::PathBuf;

fn main() {
let target = env::var("TARGET").unwrap();
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());

has_fpu(&target);
let is_armv6m = is_armv6m(&target);

if target.starts_with("thumbv") {
cc::Build::new().file("asm.s").compile("asm");
fs::copy(
format!("bin/{}.a", target),
out_dir.join("libcortex-m-rt.a"),
).unwrap();
println!("cargo:rustc-link-lib=static=cortex-m-rt");
}

// Put the linker script somewhere the linker can find it
Expand Down
30 changes: 12 additions & 18 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,63 +20,57 @@ main() {
# linking with GNU LD
for ex in "${examples[@]}"; do
cargo rustc --target $TARGET --example $ex -- \
-C link-arg=-nostartfiles \
-C link-arg=-Wl,-Tlink.x
-C linker=arm-none-eabi-ld \
-C link-arg=-Tlink.x

cargo rustc --target $TARGET --example $ex --release -- \
-C link-arg=-nostartfiles \
-C link-arg=-Wl,-Tlink.x
-C linker=arm-none-eabi-ld \
-C link-arg=-Tlink.x
done
for ex in "${fail_examples[@]}"; do
! cargo rustc --target $TARGET --example $ex -- \
-C link-arg=-nostartfiles \
-C link-arg=-Wl,-Tlink.x
-C linker=arm-none-eabi-ld \
-C link-arg=-Tlink.x

! cargo rustc --target $TARGET --example $ex --release -- \
-C link-arg=-nostartfiles \
-C link-arg=-Wl,-Tlink.x
-C linker=arm-none-eabi-ld \
-C link-arg=-Tlink.x
done

cargo rustc --target $TARGET --example device --features device -- \
-C link-arg=-nostartfiles \
-C link-arg=-Wl,-Tlink.x
-C linker=arm-none-eabi-ld \
-C link-arg=-Tlink.x

cargo rustc --target $TARGET --example device --features device --release -- \
-C link-arg=-nostartfiles \
-C link-arg=-Wl,-Tlink.x
-C linker=arm-none-eabi-ld \
-C link-arg=-Tlink.x

# linking with rustc's LLD
for ex in "${examples[@]}"; do
cargo rustc --target $TARGET --example $ex -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x

cargo rustc --target $TARGET --example $ex --release -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x
done
for ex in "${fail_examples[@]}"; do
! cargo rustc --target $TARGET --example $ex -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x

! cargo rustc --target $TARGET --example $ex --release -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x
done

cargo rustc --target $TARGET --example device --features device -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x

cargo rustc --target $TARGET --example device --features device --release -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x
fi
}
Expand Down