From 280012b1dfb11d2ebddc2093c0822eb3b3b24a4c Mon Sep 17 00:00:00 2001 From: Paolo Teti Date: Fri, 16 Feb 2018 17:31:25 +0100 Subject: [PATCH 1/6] Fix thumbv6m build (feature=c) 1. Avoid undefined references as: undefined reference to `__modsi3' undefined reference to `__umodsi3' 2. We can't remove assembly implementations that are not in the list --- build.rs | 5 ----- src/int/sdiv.rs | 7 +++++-- src/int/udiv.rs | 4 +++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.rs b/build.rs index 594afbd..9eca26c 100644 --- a/build.rs +++ b/build.rs @@ -423,13 +423,8 @@ mod c { if llvm_target[0] == "thumbv6m" { sources.remove( &[ - "aeabi_cdcmp", - "aeabi_cfcmp", - "aeabi_dcmp", - "aeabi_fcmp", "clzdi2", "clzsi2", - "comparesf2", "divmodsi4", "modsi3", "switch16", diff --git a/src/int/sdiv.rs b/src/int/sdiv.rs index 2f09bd5..2de73b0 100644 --- a/src/int/sdiv.rs +++ b/src/int/sdiv.rs @@ -72,7 +72,9 @@ intrinsics! { a.div(b) } - #[use_c_shim_if(all(target_arch = "arm", not(target_os = "ios")))] + #[use_c_shim_if(all(target_arch = "arm", + not(target_os = "ios")), + not(thumbv6m))] pub extern "C" fn __modsi3(a: i32, b: i32) -> i32 { a.mod_(b) } @@ -87,7 +89,8 @@ intrinsics! { a.mod_(b) } - #[use_c_shim_if(all(target_arch = "arm", not(target_os = "ios")))] + #[use_c_shim_if(all(target_arch = "arm", + not(target_os = "ios"), not(thumbv6m)))] pub extern "C" fn __divmodsi4(a: i32, b: i32, rem: &mut i32) -> i32 { a.divmod(b, rem, |a, b| __divsi3(a, b)) } diff --git a/src/int/udiv.rs b/src/int/udiv.rs index 1d93e17..4382460 100644 --- a/src/int/udiv.rs +++ b/src/int/udiv.rs @@ -209,7 +209,9 @@ intrinsics! { (q << 1) | carry } - #[use_c_shim_if(all(target_arch = "arm", not(target_os = "ios")))] + #[use_c_shim_if(all(target_arch = "arm", + not(target_os = "ios"), + not(thumbv6m)))] /// Returns `n % d` pub extern "C" fn __umodsi3(n: u32, d: u32) -> u32 { let q = __udivsi3(n, d); From 7f92a8ee7ba86b28488f5c6c3d7230818ccc5c67 Mon Sep 17 00:00:00 2001 From: Paolo Teti Date: Sun, 18 Feb 2018 18:15:57 +0100 Subject: [PATCH 2/6] Fix CI for thumb* targets Main fix is inside 'utest' all the rest are minor fixes due to the new 'testcrate'. Still allow failures on TravisCI for a while. --- ci/run.sh | 29 +++++++++++++++-------------- testcrate/Cargo.toml | 11 +++++++---- testcrate/src/lib.rs | 2 ++ testcrate/tests/aeabi_memclr.rs | 1 + testcrate/tests/aeabi_memcpy.rs | 1 + testcrate/tests/aeabi_memset.rs | 1 + testcrate/tests/generated.rs | 29 +++++++++++++++++++++++++++++ 7 files changed, 56 insertions(+), 18 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index bc40e2d..3196400 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -24,29 +24,30 @@ fi # Test our implementation case $1 in thumb*) - for t in $(ls tests); do + run="xargo test --manifest-path testcrate/Cargo.toml --target $1" + for t in $(ls testcrate/tests); do t=${t%.rs} - # TODO(#154) enable these tests when aeabi_*mul are implemented - case $t in - powi*f2) - continue - ;; - esac - - xargo test --test $t --target $1 --features 'mem gen-tests' --no-run + RUSTFLAGS="-C debug-assertions=no -C lto" \ + CARGO_INCREMENTAL=0 \ + $run --test $t --features 'no_std mem c' --no-run qemu-arm-static target/${1}/debug/$t-* + done - xargo test --test $t --target $1 --features 'mem gen-tests' --no-run --release + for t in $(ls testcrate/tests); do + t=${t%.rs} + RUSTFLAGS="-C lto" \ + CARGO_INCREMENTAL=0 \ + $run --test $t --features 'no_std mem c' --no-run --release qemu-arm-static target/${1}/release/$t-* done ;; *) run="cargo test --manifest-path testcrate/Cargo.toml --target $1" - $run - $run --release - $run --features c - $run --features c --release + $run --features mangled-names + $run --features mangled-names --release + $run --features 'mangled-names c' + $run --features 'mangled-names c' --release ;; esac diff --git a/testcrate/Cargo.toml b/testcrate/Cargo.toml index 834df68..d88acda 100644 --- a/testcrate/Cargo.toml +++ b/testcrate/Cargo.toml @@ -14,12 +14,15 @@ rand = { version = "0.4", features = ["i128_support"] } [dependencies.compiler_builtins] path = ".." default-features = false -features = ["mangled-names", "no-lang-items"] +features = ["no-lang-items"] [target.'cfg(all(target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux"))'.dev-dependencies] -test = { git = "https://github.com/japaric/utest" } -utest-cortex-m-qemu = { default-features = false, git = "https://github.com/japaric/utest" } -utest-macros = { git = "https://github.com/japaric/utest" } +test = { git = "https://github.com/paoloteti/utest", branch = "ci" } +utest-cortex-m-qemu = { default-features = false, git = "https://github.com/paoloteti/utest", branch = "ci" } +utest-macros = { git = "https://github.com/paoloteti/utest", branch = "ci" } [features] c = ["compiler_builtins/c"] +mem = ["compiler_builtins/mem"] +mangled-names = ["compiler_builtins/mangled-names"] +no_std = [] diff --git a/testcrate/src/lib.rs b/testcrate/src/lib.rs index 31e1bb2..ae9e4e2 100644 --- a/testcrate/src/lib.rs +++ b/testcrate/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(feature = "no_std", no_std)] + #[cfg(test)] mod tests { #[test] diff --git a/testcrate/tests/aeabi_memclr.rs b/testcrate/tests/aeabi_memclr.rs index 72e944e..08fbd4f 100644 --- a/testcrate/tests/aeabi_memclr.rs +++ b/testcrate/tests/aeabi_memclr.rs @@ -3,6 +3,7 @@ target_os = "linux", feature = "mem"))] #![feature(compiler_builtins_lib)] +#![feature(lang_items)] #![no_std] extern crate compiler_builtins; diff --git a/testcrate/tests/aeabi_memcpy.rs b/testcrate/tests/aeabi_memcpy.rs index 2ba942c..76dad89 100644 --- a/testcrate/tests/aeabi_memcpy.rs +++ b/testcrate/tests/aeabi_memcpy.rs @@ -3,6 +3,7 @@ target_os = "linux", feature = "mem"))] #![feature(compiler_builtins_lib)] +#![feature(lang_items)] #![no_std] extern crate compiler_builtins; diff --git a/testcrate/tests/aeabi_memset.rs b/testcrate/tests/aeabi_memset.rs index 0919f14..71fe37e 100644 --- a/testcrate/tests/aeabi_memset.rs +++ b/testcrate/tests/aeabi_memset.rs @@ -3,6 +3,7 @@ target_os = "linux", feature = "mem"))] #![feature(compiler_builtins_lib)] +#![feature(lang_items)] #![no_std] extern crate compiler_builtins; diff --git a/testcrate/tests/generated.rs b/testcrate/tests/generated.rs index 1a43f43..1263dc2 100644 --- a/testcrate/tests/generated.rs +++ b/testcrate/tests/generated.rs @@ -1,6 +1,35 @@ +#![feature(compiler_builtins_lib)] #![feature(i128_type)] +#![feature(lang_items, core_float, core_float_bits)] #![allow(bad_style)] +#![allow(unused_imports)] +#![no_std] + +use core::num::Float; extern crate compiler_builtins; +#[cfg(all(target_arch = "arm", + not(any(target_env = "gnu", target_env = "musl")), + target_os = "linux", + test))] +extern crate utest_cortex_m_qemu; + +#[cfg(all(target_arch = "arm", + not(any(target_env = "gnu", target_env = "musl")), + target_os = "linux", + test))] +#[macro_use] +extern crate utest_macros; + +#[cfg(all(target_arch = "arm", + not(any(target_env = "gnu", target_env = "musl")), + target_os = "linux", + test))] +macro_rules! panic { // overrides `panic!` + ($($tt:tt)*) => { + upanic!($($tt)*); + }; +} + include!(concat!(env!("OUT_DIR"), "/generated.rs")); From 8289e626fe8d9d0d78bd2d6579f75a47ed98f652 Mon Sep 17 00:00:00 2001 From: Paolo Teti Date: Sat, 24 Feb 2018 22:48:27 +0100 Subject: [PATCH 3/6] Use upstream for utest Fix has been merged into upstream. --- testcrate/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testcrate/Cargo.toml b/testcrate/Cargo.toml index d88acda..7544d94 100644 --- a/testcrate/Cargo.toml +++ b/testcrate/Cargo.toml @@ -17,9 +17,9 @@ default-features = false features = ["no-lang-items"] [target.'cfg(all(target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux"))'.dev-dependencies] -test = { git = "https://github.com/paoloteti/utest", branch = "ci" } -utest-cortex-m-qemu = { default-features = false, git = "https://github.com/paoloteti/utest", branch = "ci" } -utest-macros = { git = "https://github.com/paoloteti/utest", branch = "ci" } +test = { git = "https://github.com/japaric/utest" } +utest-cortex-m-qemu = { default-features = false, git = "https://github.com/japaric/utest" } +utest-macros = { git = "https://github.com/japaric/utest" } [features] c = ["compiler_builtins/c"] From 86612733be769c45482654200054a0d32a7aa923 Mon Sep 17 00:00:00 2001 From: Paolo Teti Date: Sun, 25 Feb 2018 00:22:39 +0100 Subject: [PATCH 4/6] testcrate/lib.rs: use #![no_std] unconditionally --- testcrate/src/lib.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/testcrate/src/lib.rs b/testcrate/src/lib.rs index ae9e4e2..2e7f0d4 100644 --- a/testcrate/src/lib.rs +++ b/testcrate/src/lib.rs @@ -1,9 +1 @@ -#![cfg_attr(feature = "no_std", no_std)] - -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} +#![no_std] \ No newline at end of file From 7b81af044eac45afa01478b47f4bf978353b627b Mon Sep 17 00:00:00 2001 From: Paolo Teti Date: Sun, 25 Feb 2018 01:11:49 +0100 Subject: [PATCH 5/6] Keep mangled-names as a default feature --- ci/run.sh | 14 ++++++++------ testcrate/Cargo.toml | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 3196400..8ce706c 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -30,7 +30,8 @@ case $1 in RUSTFLAGS="-C debug-assertions=no -C lto" \ CARGO_INCREMENTAL=0 \ - $run --test $t --features 'no_std mem c' --no-run + $run --test $t --no-default-features \ + --features 'no_std mem c' --no-run qemu-arm-static target/${1}/debug/$t-* done @@ -38,16 +39,17 @@ case $1 in t=${t%.rs} RUSTFLAGS="-C lto" \ CARGO_INCREMENTAL=0 \ - $run --test $t --features 'no_std mem c' --no-run --release + $run --test $t --no-default-features \ + --features 'no_std mem c' --no-run --release qemu-arm-static target/${1}/release/$t-* done ;; *) run="cargo test --manifest-path testcrate/Cargo.toml --target $1" - $run --features mangled-names - $run --features mangled-names --release - $run --features 'mangled-names c' - $run --features 'mangled-names c' --release + $run + $run --release + $run --features c + $run --features c --release ;; esac diff --git a/testcrate/Cargo.toml b/testcrate/Cargo.toml index 7544d94..eae66ce 100644 --- a/testcrate/Cargo.toml +++ b/testcrate/Cargo.toml @@ -25,4 +25,5 @@ utest-macros = { git = "https://github.com/japaric/utest" } c = ["compiler_builtins/c"] mem = ["compiler_builtins/mem"] mangled-names = ["compiler_builtins/mangled-names"] +default = ["mangled-names"] no_std = [] From 9e99aa2bbee95f5f9ed20ff94d34be70dd78262a Mon Sep 17 00:00:00 2001 From: Paolo Teti Date: Sun, 25 Feb 2018 09:19:34 +0100 Subject: [PATCH 6/6] Remove no_std features Everything default unconditionally to #![no_std]. --- ci/run.sh | 6 ++---- testcrate/Cargo.toml | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 8ce706c..8c85038 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -30,8 +30,7 @@ case $1 in RUSTFLAGS="-C debug-assertions=no -C lto" \ CARGO_INCREMENTAL=0 \ - $run --test $t --no-default-features \ - --features 'no_std mem c' --no-run + $run --test $t --no-default-features --features 'mem c' --no-run qemu-arm-static target/${1}/debug/$t-* done @@ -39,8 +38,7 @@ case $1 in t=${t%.rs} RUSTFLAGS="-C lto" \ CARGO_INCREMENTAL=0 \ - $run --test $t --no-default-features \ - --features 'no_std mem c' --no-run --release + $run --test $t --no-default-features --features 'mem c' --no-run --release qemu-arm-static target/${1}/release/$t-* done ;; diff --git a/testcrate/Cargo.toml b/testcrate/Cargo.toml index eae66ce..2a10266 100644 --- a/testcrate/Cargo.toml +++ b/testcrate/Cargo.toml @@ -26,4 +26,3 @@ c = ["compiler_builtins/c"] mem = ["compiler_builtins/mem"] mangled-names = ["compiler_builtins/mangled-names"] default = ["mangled-names"] -no_std = []