From f48cf9d9a062fa3765d207a02df1b46f1210d3b4 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 3 Feb 2017 08:11:42 +0000 Subject: [PATCH] firmware: use libcompiler_builtins to build satman. --- artiq/firmware/Cargo.lock | 1 + artiq/firmware/satman/Cargo.toml | 1 + artiq/firmware/satman/Makefile | 13 +++++++------ artiq/firmware/satman/lib.rs | 2 ++ artiq/runtime/Makefile | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/artiq/firmware/Cargo.lock b/artiq/firmware/Cargo.lock index 8e80b2cea..196fef089 100644 --- a/artiq/firmware/Cargo.lock +++ b/artiq/firmware/Cargo.lock @@ -134,6 +134,7 @@ dependencies = [ "alloc_artiq 0.0.0", "board 0.0.0", "build_artiq 0.0.0", + "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "logger_artiq 0.0.0", "std_artiq 0.0.0", diff --git a/artiq/firmware/satman/Cargo.toml b/artiq/firmware/satman/Cargo.toml index 806e85d1a..cab9759c6 100644 --- a/artiq/firmware/satman/Cargo.toml +++ b/artiq/firmware/satman/Cargo.toml @@ -13,6 +13,7 @@ path = "lib.rs" build_artiq = { path = "../libbuild_artiq" } [dependencies] +compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins" } alloc_artiq = { path = "../liballoc_artiq" } std_artiq = { path = "../libstd_artiq", features = ["alloc"] } logger_artiq = { path = "../liblogger_artiq" } diff --git a/artiq/firmware/satman/Makefile b/artiq/firmware/satman/Makefile index 15169bf7c..d2dd7fcf4 100644 --- a/artiq/firmware/satman/Makefile +++ b/artiq/firmware/satman/Makefile @@ -6,14 +6,18 @@ PYTHON ?= python3 RUSTOUT := cargo/or1k-unknown-none/debug LDFLAGS += --gc-sections \ - -L../libcompiler-rt \ -L../libbase +RUSTFLAGS = \ + -C target-feature=+mul,+div,+ffl1,+cmov,+addc \ + -C opt-level=s \ + -C panic=abort +export RUSTFLAGS + all: satman.bin satman.fbi .PHONY: $(RUSTOUT)/libsatman.a $(RUSTOUT)/libsatman.a: - RUSTFLAGS="-C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s -Cpanic=abort" \ CARGO_TARGET_DIR=$(realpath .)/cargo \ cargo build --target=or1k-unknown-none \ --manifest-path $(realpath $(SATMAN_DIRECTORY))/Cargo.toml @@ -23,12 +27,9 @@ satman.elf: $(RUSTOUT)/libsatman.a -T $(SATMAN_DIRECTORY)/satman.ld \ -o $@ \ $^ \ - -lbase-nofloat -lcompiler-rt + -lbase-nofloat @chmod -x $@ -%.o: $(SATMAN_DIRECTORY)/%.c - $(compile) - %.bin: %.elf $(OBJCOPY) -O binary $< $@ @chmod -x $@ diff --git a/artiq/firmware/satman/lib.rs b/artiq/firmware/satman/lib.rs index c51060a66..2cca2421a 100644 --- a/artiq/firmware/satman/lib.rs +++ b/artiq/firmware/satman/lib.rs @@ -1,5 +1,7 @@ +#![feature(compiler_builtins_lib)] #![no_std] +extern crate compiler_builtins; extern crate alloc_artiq; #[macro_use] extern crate std_artiq as std; diff --git a/artiq/runtime/Makefile b/artiq/runtime/Makefile index 18ceac2e2..8bd195a73 100644 --- a/artiq/runtime/Makefile +++ b/artiq/runtime/Makefile @@ -32,7 +32,7 @@ RUSTFLAGS = \ -C target-feature=+mul,+div,+ffl1,+cmov,+addc \ -C relocation-model=static \ -C opt-level=s \ - -Cpanic=abort + -C panic=abort export RUSTFLAGS all: runtime.bin runtime.fbi