Skip to content

Commit cfa7c7a

Browse files
authored
Merge pull request #290 from alexcrichton/fix-targets
Fix __divsi3 and __udivsi3 on thumbv6m targets
2 parents e0e54de + 8521530 commit cfa7c7a

File tree

15 files changed

+64
-95
lines changed

15 files changed

+64
-95
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ rustc-dep-of-std = ['compiler-builtins', 'core']
6262

6363
[[example]]
6464
name = "intrinsics"
65-
required-features = ["c", "compiler-builtins"]
65+
required-features = ["compiler-builtins"]
6666

6767
[workspace]
6868
members = ["testcrate"]

azure-pipelines.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,14 @@ jobs:
3333
TARGET: powerpc64-unknown-linux-gnu
3434
powerpc64le:
3535
TARGET: powerpc64le-unknown-linux-gnu
36-
# thumbv6m:
37-
# TARGET: thumbv6m-linux-eabi
38-
# XARGO: 1
39-
# thumbv7em:
40-
# TARGET: thumbv7em-linux-eabi
41-
# XARGO: 1
42-
# thumbv7emhf:
43-
# TARGET: thumbv7em-linux-eabihf
44-
# XARGO: 1
45-
# thumbv7m:
46-
# TARGET: thumbv7m-linux-eabi
47-
# XARGO: 1
36+
thumbv6m:
37+
TARGET: thumbv6m-none-eabi
38+
thumbv7em:
39+
TARGET: thumbv7em-none-eabi
40+
thumbv7emhf:
41+
TARGET: thumbv7em-none-eabihf
42+
thumbv7m:
43+
TARGET: thumbv7m-none-eabi
4844
wasm32:
4945
TARGET: wasm32-unknown-unknown
5046
ONLY_BUILD: 1

ci/docker/thumbv6m-linux-eabi/Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ubuntu:18.04
2+
RUN apt-get update && \
3+
apt-get install -y --no-install-recommends \
4+
gcc libc6-dev ca-certificates \
5+
gcc-arm-none-eabi \
6+
libnewlib-arm-none-eabi
7+
ENV XARGO=1

ci/docker/thumbv7em-linux-eabi/Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

ci/docker/thumbv7em-linux-eabihf/Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ubuntu:18.04
2+
RUN apt-get update && \
3+
apt-get install -y --no-install-recommends \
4+
gcc libc6-dev ca-certificates \
5+
gcc-arm-none-eabi \
6+
libnewlib-arm-none-eabi
7+
ENV XARGO=1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ubuntu:18.04
2+
RUN apt-get update && \
3+
apt-get install -y --no-install-recommends \
4+
gcc libc6-dev ca-certificates \
5+
gcc-arm-none-eabi \
6+
libnewlib-arm-none-eabi
7+
ENV XARGO=1

ci/docker/thumbv7m-linux-eabi/Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ubuntu:18.04
2+
RUN apt-get update && \
3+
apt-get install -y --no-install-recommends \
4+
gcc libc6-dev ca-certificates \
5+
gcc-arm-none-eabi \
6+
libnewlib-arm-none-eabi
7+
ENV XARGO=1

ci/run-docker.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ run() {
1818
--user $(id -u):$(id -g) \
1919
-e CARGO_HOME=/cargo \
2020
-e CARGO_TARGET_DIR=/target \
21-
-e XARGO \
2221
-v $HOME/.cargo:/cargo \
2322
-v `pwd`/target:/target \
2423
-v `pwd`:/checkout:ro \

ci/run.sh

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,24 @@
11
set -ex
22

3-
# FIXME(japarix/xargo#186) this shouldn't be necessary
4-
export RUST_TARGET_PATH=`pwd`
5-
63
cargo=cargo
7-
if [ "$XARGO" = "1" ]; then
8-
cargo=xargo
9-
fi
10-
11-
INTRINSICS_FEATURES="c"
12-
13-
# Some architectures like ARM apparently seem to require the `mem` feature
14-
# enabled to successfully compile the `intrinsics` example, and... we're not
15-
# sure why!
16-
if [ -z "$INTRINSICS_FAILS_WITH_MEM_FEATURE" ]; then
17-
INTRINSICS_FEATURES="$INTRINSICS_FEATURES mem"
18-
fi
194

205
# Test our implementation
216
if [ "$XARGO" = "1" ]; then
22-
run="xargo test --manifest-path testcrate/Cargo.toml --target $1"
23-
for t in $(ls testcrate/tests); do
24-
t=${t%.rs}
25-
26-
RUSTFLAGS="-C debug-assertions=no -C lto" \
27-
CARGO_INCREMENTAL=0 \
28-
$run --test $t --no-default-features --features 'mem c' --no-run
29-
qemu-arm-static target/${1}/debug/$t-*
30-
done
31-
32-
for t in $(ls testcrate/tests); do
33-
t=${t%.rs}
34-
RUSTFLAGS="-C lto" \
35-
CARGO_INCREMENTAL=0 \
36-
$run --test $t --no-default-features --features 'mem c' --no-run --release
37-
qemu-arm-static target/${1}/release/$t-*
38-
done
7+
# FIXME: currently these tests don't work...
8+
echo nothing to do
399
else
4010
run="cargo test --manifest-path testcrate/Cargo.toml --target $1"
4111
$run
4212
$run --release
4313
$run --features c
4414
$run --features c --release
45-
cargo build --target $1
46-
cargo build --target $1 --release
47-
cargo build --target $1 --features c
48-
cargo build --target $1 --release --features c
4915
fi
5016

17+
cargo build --target $1
18+
cargo build --target $1 --release
19+
cargo build --target $1 --features c
20+
cargo build --target $1 --release --features c
21+
5122
PREFIX=$(echo $1 | sed -e 's/unknown-//')-
5223
case $1 in
5324
armv7-*)
@@ -101,8 +72,11 @@ done
10172
rm -f $path
10273

10374
# Verify that we haven't drop any intrinsic/symbol
104-
RUSTFLAGS="-C debug-assertions=no" \
105-
$cargo build --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -v
75+
build_intrinsics="$cargo build --target $1 -v --example intrinsics"
76+
RUSTFLAGS="-C debug-assertions=no" $build_intrinsics
77+
RUSTFLAGS="-C debug-assertions=no" $build_intrinsics --release
78+
RUSTFLAGS="-C debug-assertions=no" $build_intrinsics --features c
79+
RUSTFLAGS="-C debug-assertions=no" $build_intrinsics --features c --release
10680

10781
# Verify that there are no undefined symbols to `panic` within our
10882
# implementations

examples/intrinsics.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ extern {}
2727
mod intrinsics {
2828
// trunccdfsf2
2929
pub fn aeabi_d2f(x: f64) -> f32 {
30-
x as f32
30+
// This is only implemented in C currently, so only test it there.
31+
#[cfg(feature = "c")]
32+
return x as f32;
33+
#[cfg(not(feature = "c"))]
34+
{
35+
drop(x);
36+
0.0
37+
}
3138
}
3239

3340
// fixdfsi
@@ -263,6 +270,10 @@ mod intrinsics {
263270
pub fn modti3(a: i128, b: i128) -> i128 {
264271
a % b
265272
}
273+
274+
pub fn udivsi3(a: u32, b: u32) -> u32 {
275+
a / b
276+
}
266277
}
267278

268279
fn run() {
@@ -325,6 +336,7 @@ fn run() {
325336
bb(umodti3(bb(2), bb(2)));
326337
bb(divti3(bb(2), bb(2)));
327338
bb(modti3(bb(2), bb(2)));
339+
bb(udivsi3(bb(2), bb(2)));
328340

329341
something_with_a_dtor(&|| assert_eq!(bb(1), 1));
330342

src/int/sdiv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Divmod for i32 {}
5757
impl Divmod for i64 {}
5858

5959
intrinsics! {
60-
#[use_c_shim_if(all(target_arch = "arm", not(target_os = "ios"), not(thumbv6m)))]
60+
#[use_c_shim_if(all(target_arch = "arm", not(target_os = "ios"), not(thumb_1)))]
6161
#[arm_aeabi_alias = __aeabi_idiv]
6262
pub extern "C" fn __divsi3(a: i32, b: i32) -> i32 {
6363
a.div(b)

src/int/udiv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ macro_rules! udivmod_inner {
154154
intrinsics! {
155155
#[use_c_shim_if(all(target_arch = "arm",
156156
not(target_os = "ios"),
157-
not(thumbv6m)))]
157+
not(thumb_1)))]
158158
#[arm_aeabi_alias = __aeabi_uidiv]
159159
/// Returns `n / d`
160160
pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {

0 commit comments

Comments
 (0)