Merge pull request #290 from alexcrichton/fix-targets
Fix __divsi3 and __udivsi3 on thumbv6m targets
This commit is contained in:
commit
cfa7c7a08d
|
@ -62,7 +62,7 @@ rustc-dep-of-std = ['compiler-builtins', 'core']
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "intrinsics"
|
name = "intrinsics"
|
||||||
required-features = ["c", "compiler-builtins"]
|
required-features = ["compiler-builtins"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["testcrate"]
|
members = ["testcrate"]
|
||||||
|
|
|
@ -33,18 +33,14 @@ jobs:
|
||||||
TARGET: powerpc64-unknown-linux-gnu
|
TARGET: powerpc64-unknown-linux-gnu
|
||||||
powerpc64le:
|
powerpc64le:
|
||||||
TARGET: powerpc64le-unknown-linux-gnu
|
TARGET: powerpc64le-unknown-linux-gnu
|
||||||
# thumbv6m:
|
thumbv6m:
|
||||||
# TARGET: thumbv6m-linux-eabi
|
TARGET: thumbv6m-none-eabi
|
||||||
# XARGO: 1
|
thumbv7em:
|
||||||
# thumbv7em:
|
TARGET: thumbv7em-none-eabi
|
||||||
# TARGET: thumbv7em-linux-eabi
|
thumbv7emhf:
|
||||||
# XARGO: 1
|
TARGET: thumbv7em-none-eabihf
|
||||||
# thumbv7emhf:
|
thumbv7m:
|
||||||
# TARGET: thumbv7em-linux-eabihf
|
TARGET: thumbv7m-none-eabi
|
||||||
# XARGO: 1
|
|
||||||
# thumbv7m:
|
|
||||||
# TARGET: thumbv7m-linux-eabi
|
|
||||||
# XARGO: 1
|
|
||||||
wasm32:
|
wasm32:
|
||||||
TARGET: wasm32-unknown-unknown
|
TARGET: wasm32-unknown-unknown
|
||||||
ONLY_BUILD: 1
|
ONLY_BUILD: 1
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
FROM ubuntu:18.04
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
ca-certificates curl gcc gcc-arm-none-eabi libc6-dev libcurl4-openssl-dev libssh2-1 libnewlib-dev qemu-user-static
|
|
||||||
RUN curl -LSfs https://japaric.github.io/trust/install.sh | \
|
|
||||||
sh -s -- --git japaric/xargo --tag v0.3.1 --target x86_64-unknown-linux-gnu --to /usr/bin
|
|
||||||
ENV AR_thumbv6m_linux_eabi=arm-none-eabi-ar \
|
|
||||||
CARGO_TARGET_THUMBV6M_LINUX_EABI_LINKER=arm-none-eabi-gcc \
|
|
||||||
CARGO_TARGET_THUMBV6M_LINUX_EABI_RUNNER=qemu-arm-static \
|
|
||||||
CC_thumbv6m_linux_eabi=arm-none-eabi-gcc \
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
FROM ubuntu:18.04
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
gcc libc6-dev ca-certificates \
|
||||||
|
gcc-arm-none-eabi \
|
||||||
|
libnewlib-arm-none-eabi
|
||||||
|
ENV XARGO=1
|
|
@ -1,10 +0,0 @@
|
||||||
FROM ubuntu:18.04
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
ca-certificates curl gcc gcc-arm-none-eabi libc6-dev libcurl4-openssl-dev libssh2-1 libnewlib-dev qemu-user-static
|
|
||||||
RUN curl -LSfs https://japaric.github.io/trust/install.sh | \
|
|
||||||
sh -s -- --git japaric/xargo --tag v0.3.1 --target x86_64-unknown-linux-gnu --to /usr/bin
|
|
||||||
ENV AR_thumbv7em_linux_eabi=arm-none-eabi-ar \
|
|
||||||
CARGO_TARGET_THUMBV7EM_LINUX_EABI_LINKER=arm-none-eabi-gcc \
|
|
||||||
CARGO_TARGET_THUMBV7EM_LINUX_EABI_RUNNER=qemu-arm-static \
|
|
||||||
CC_thumbv7em_linux_eabi=arm-none-eabi-gcc \
|
|
|
@ -1,10 +0,0 @@
|
||||||
FROM ubuntu:18.04
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
ca-certificates curl gcc gcc-arm-none-eabi libc6-dev libcurl4-openssl-dev libssh2-1 libnewlib-dev qemu-user-static
|
|
||||||
RUN curl -LSfs https://japaric.github.io/trust/install.sh | \
|
|
||||||
sh -s -- --git japaric/xargo --tag v0.3.1 --target x86_64-unknown-linux-gnu --to /usr/bin
|
|
||||||
ENV AR_thumbv7em_linux_eabihf=arm-none-eabi-ar \
|
|
||||||
CARGO_TARGET_THUMBV7EM_LINUX_EABIHF_LINKER=arm-none-eabi-gcc \
|
|
||||||
CARGO_TARGET_THUMBV7EM_LINUX_EABIHF_RUNNER=qemu-arm-static \
|
|
||||||
CC_thumbv7em_linux_eabihf=arm-none-eabi-gcc \
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
FROM ubuntu:18.04
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
gcc libc6-dev ca-certificates \
|
||||||
|
gcc-arm-none-eabi \
|
||||||
|
libnewlib-arm-none-eabi
|
||||||
|
ENV XARGO=1
|
|
@ -0,0 +1,7 @@
|
||||||
|
FROM ubuntu:18.04
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
gcc libc6-dev ca-certificates \
|
||||||
|
gcc-arm-none-eabi \
|
||||||
|
libnewlib-arm-none-eabi
|
||||||
|
ENV XARGO=1
|
|
@ -1,10 +0,0 @@
|
||||||
FROM ubuntu:18.04
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
ca-certificates curl gcc gcc-arm-none-eabi libc6-dev libcurl4-openssl-dev libssh2-1 libnewlib-dev qemu-user-static
|
|
||||||
RUN curl -LSfs https://japaric.github.io/trust/install.sh | \
|
|
||||||
sh -s -- --git japaric/xargo --tag v0.3.1 --target x86_64-unknown-linux-gnu --to /usr/bin
|
|
||||||
ENV AR_thumbv7m_linux_eabi=arm-none-eabi-ar \
|
|
||||||
CARGO_TARGET_THUMBV7M_LINUX_EABI_LINKER=arm-none-eabi-gcc \
|
|
||||||
CARGO_TARGET_THUMBV7M_LINUX_EABI_RUNNER=qemu-arm-static \
|
|
||||||
CC_thumbv7m_linux_eabi=arm-none-eabi-gcc \
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
FROM ubuntu:18.04
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
gcc libc6-dev ca-certificates \
|
||||||
|
gcc-arm-none-eabi \
|
||||||
|
libnewlib-arm-none-eabi
|
||||||
|
ENV XARGO=1
|
|
@ -18,7 +18,6 @@ run() {
|
||||||
--user $(id -u):$(id -g) \
|
--user $(id -u):$(id -g) \
|
||||||
-e CARGO_HOME=/cargo \
|
-e CARGO_HOME=/cargo \
|
||||||
-e CARGO_TARGET_DIR=/target \
|
-e CARGO_TARGET_DIR=/target \
|
||||||
-e XARGO \
|
|
||||||
-v $HOME/.cargo:/cargo \
|
-v $HOME/.cargo:/cargo \
|
||||||
-v `pwd`/target:/target \
|
-v `pwd`/target:/target \
|
||||||
-v `pwd`:/checkout:ro \
|
-v `pwd`:/checkout:ro \
|
||||||
|
|
50
ci/run.sh
50
ci/run.sh
|
@ -1,53 +1,24 @@
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
# FIXME(japarix/xargo#186) this shouldn't be necessary
|
|
||||||
export RUST_TARGET_PATH=`pwd`
|
|
||||||
|
|
||||||
cargo=cargo
|
cargo=cargo
|
||||||
if [ "$XARGO" = "1" ]; then
|
|
||||||
cargo=xargo
|
|
||||||
fi
|
|
||||||
|
|
||||||
INTRINSICS_FEATURES="c"
|
|
||||||
|
|
||||||
# Some architectures like ARM apparently seem to require the `mem` feature
|
|
||||||
# enabled to successfully compile the `intrinsics` example, and... we're not
|
|
||||||
# sure why!
|
|
||||||
if [ -z "$INTRINSICS_FAILS_WITH_MEM_FEATURE" ]; then
|
|
||||||
INTRINSICS_FEATURES="$INTRINSICS_FEATURES mem"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Test our implementation
|
# Test our implementation
|
||||||
if [ "$XARGO" = "1" ]; then
|
if [ "$XARGO" = "1" ]; then
|
||||||
run="xargo test --manifest-path testcrate/Cargo.toml --target $1"
|
# FIXME: currently these tests don't work...
|
||||||
for t in $(ls testcrate/tests); do
|
echo nothing to do
|
||||||
t=${t%.rs}
|
|
||||||
|
|
||||||
RUSTFLAGS="-C debug-assertions=no -C lto" \
|
|
||||||
CARGO_INCREMENTAL=0 \
|
|
||||||
$run --test $t --no-default-features --features 'mem c' --no-run
|
|
||||||
qemu-arm-static target/${1}/debug/$t-*
|
|
||||||
done
|
|
||||||
|
|
||||||
for t in $(ls testcrate/tests); do
|
|
||||||
t=${t%.rs}
|
|
||||||
RUSTFLAGS="-C lto" \
|
|
||||||
CARGO_INCREMENTAL=0 \
|
|
||||||
$run --test $t --no-default-features --features 'mem c' --no-run --release
|
|
||||||
qemu-arm-static target/${1}/release/$t-*
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
run="cargo test --manifest-path testcrate/Cargo.toml --target $1"
|
run="cargo test --manifest-path testcrate/Cargo.toml --target $1"
|
||||||
$run
|
$run
|
||||||
$run --release
|
$run --release
|
||||||
$run --features c
|
$run --features c
|
||||||
$run --features c --release
|
$run --features c --release
|
||||||
cargo build --target $1
|
|
||||||
cargo build --target $1 --release
|
|
||||||
cargo build --target $1 --features c
|
|
||||||
cargo build --target $1 --release --features c
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cargo build --target $1
|
||||||
|
cargo build --target $1 --release
|
||||||
|
cargo build --target $1 --features c
|
||||||
|
cargo build --target $1 --release --features c
|
||||||
|
|
||||||
PREFIX=$(echo $1 | sed -e 's/unknown-//')-
|
PREFIX=$(echo $1 | sed -e 's/unknown-//')-
|
||||||
case $1 in
|
case $1 in
|
||||||
armv7-*)
|
armv7-*)
|
||||||
|
@ -101,8 +72,11 @@ done
|
||||||
rm -f $path
|
rm -f $path
|
||||||
|
|
||||||
# Verify that we haven't drop any intrinsic/symbol
|
# Verify that we haven't drop any intrinsic/symbol
|
||||||
RUSTFLAGS="-C debug-assertions=no" \
|
build_intrinsics="$cargo build --target $1 -v --example intrinsics"
|
||||||
$cargo build --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -v
|
RUSTFLAGS="-C debug-assertions=no" $build_intrinsics
|
||||||
|
RUSTFLAGS="-C debug-assertions=no" $build_intrinsics --release
|
||||||
|
RUSTFLAGS="-C debug-assertions=no" $build_intrinsics --features c
|
||||||
|
RUSTFLAGS="-C debug-assertions=no" $build_intrinsics --features c --release
|
||||||
|
|
||||||
# Verify that there are no undefined symbols to `panic` within our
|
# Verify that there are no undefined symbols to `panic` within our
|
||||||
# implementations
|
# implementations
|
||||||
|
|
|
@ -27,7 +27,14 @@ extern {}
|
||||||
mod intrinsics {
|
mod intrinsics {
|
||||||
// trunccdfsf2
|
// trunccdfsf2
|
||||||
pub fn aeabi_d2f(x: f64) -> f32 {
|
pub fn aeabi_d2f(x: f64) -> f32 {
|
||||||
x as f32
|
// This is only implemented in C currently, so only test it there.
|
||||||
|
#[cfg(feature = "c")]
|
||||||
|
return x as f32;
|
||||||
|
#[cfg(not(feature = "c"))]
|
||||||
|
{
|
||||||
|
drop(x);
|
||||||
|
0.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixdfsi
|
// fixdfsi
|
||||||
|
@ -263,6 +270,10 @@ mod intrinsics {
|
||||||
pub fn modti3(a: i128, b: i128) -> i128 {
|
pub fn modti3(a: i128, b: i128) -> i128 {
|
||||||
a % b
|
a % b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn udivsi3(a: u32, b: u32) -> u32 {
|
||||||
|
a / b
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run() {
|
fn run() {
|
||||||
|
@ -325,6 +336,7 @@ fn run() {
|
||||||
bb(umodti3(bb(2), bb(2)));
|
bb(umodti3(bb(2), bb(2)));
|
||||||
bb(divti3(bb(2), bb(2)));
|
bb(divti3(bb(2), bb(2)));
|
||||||
bb(modti3(bb(2), bb(2)));
|
bb(modti3(bb(2), bb(2)));
|
||||||
|
bb(udivsi3(bb(2), bb(2)));
|
||||||
|
|
||||||
something_with_a_dtor(&|| assert_eq!(bb(1), 1));
|
something_with_a_dtor(&|| assert_eq!(bb(1), 1));
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl Divmod for i32 {}
|
||||||
impl Divmod for i64 {}
|
impl Divmod for i64 {}
|
||||||
|
|
||||||
intrinsics! {
|
intrinsics! {
|
||||||
#[use_c_shim_if(all(target_arch = "arm", not(target_os = "ios"), not(thumbv6m)))]
|
#[use_c_shim_if(all(target_arch = "arm", not(target_os = "ios"), not(thumb_1)))]
|
||||||
#[arm_aeabi_alias = __aeabi_idiv]
|
#[arm_aeabi_alias = __aeabi_idiv]
|
||||||
pub extern "C" fn __divsi3(a: i32, b: i32) -> i32 {
|
pub extern "C" fn __divsi3(a: i32, b: i32) -> i32 {
|
||||||
a.div(b)
|
a.div(b)
|
||||||
|
|
|
@ -154,7 +154,7 @@ macro_rules! udivmod_inner {
|
||||||
intrinsics! {
|
intrinsics! {
|
||||||
#[use_c_shim_if(all(target_arch = "arm",
|
#[use_c_shim_if(all(target_arch = "arm",
|
||||||
not(target_os = "ios"),
|
not(target_os = "ios"),
|
||||||
not(thumbv6m)))]
|
not(thumb_1)))]
|
||||||
#[arm_aeabi_alias = __aeabi_uidiv]
|
#[arm_aeabi_alias = __aeabi_uidiv]
|
||||||
/// Returns `n / d`
|
/// Returns `n / d`
|
||||||
pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
|
pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
|
||||||
|
|
Loading…
Reference in New Issue