Fix __divsi3 and __udivsi3 on thumbv6m targets
This commit fixes a bug accidentally introduced in #285 where some lingering references remained to `#[cfg(thumbv6m)]` but this, since the historical revert, was renamed to `#[cfg(thumb_1)]`. This caused on the thumbv6m platform for the intrinsics to be accidentally omitted because the build script didn't actually compile them but the Rust code thought the C code was in use. After correcting the `#[cfg]` statements the CI configuration for the `thumb*` family of targets was all updated. The support for xargo testing was removed from `run.sh` since it had long since bitrotted, and the script was updated to simply build the intrinsics example to attempt to link for each of these targets. This in turn exposed the bug locally and allowed to confirm a fix once the `#[cfg]` statements were corrected. cc rust-lang/rust#60782
This commit is contained in:
parent
e3b53f9142
commit
8521530f49
@ -62,7 +62,7 @@ rustc-dep-of-std = ['c', 'compiler-builtins', 'core']
|
||||
|
||||
[[example]]
|
||||
name = "intrinsics"
|
||||
required-features = ["c", "compiler-builtins"]
|
||||
required-features = ["compiler-builtins"]
|
||||
|
||||
[workspace]
|
||||
members = ["testcrate"]
|
||||
|
@ -33,18 +33,14 @@ jobs:
|
||||
TARGET: powerpc64-unknown-linux-gnu
|
||||
powerpc64le:
|
||||
TARGET: powerpc64le-unknown-linux-gnu
|
||||
# thumbv6m:
|
||||
# TARGET: thumbv6m-linux-eabi
|
||||
# XARGO: 1
|
||||
# thumbv7em:
|
||||
# TARGET: thumbv7em-linux-eabi
|
||||
# XARGO: 1
|
||||
# thumbv7emhf:
|
||||
# TARGET: thumbv7em-linux-eabihf
|
||||
# XARGO: 1
|
||||
# thumbv7m:
|
||||
# TARGET: thumbv7m-linux-eabi
|
||||
# XARGO: 1
|
||||
thumbv6m:
|
||||
TARGET: thumbv6m-none-eabi
|
||||
thumbv7em:
|
||||
TARGET: thumbv7em-none-eabi
|
||||
thumbv7emhf:
|
||||
TARGET: thumbv7em-none-eabihf
|
||||
thumbv7m:
|
||||
TARGET: thumbv7m-none-eabi
|
||||
wasm32:
|
||||
TARGET: wasm32-unknown-unknown
|
||||
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 \
|
7
ci/docker/thumbv6m-none-eabi/Dockerfile
Normal file
7
ci/docker/thumbv6m-none-eabi/Dockerfile
Normal file
@ -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 \
|
7
ci/docker/thumbv7em-none-eabi/Dockerfile
Normal file
7
ci/docker/thumbv7em-none-eabi/Dockerfile
Normal file
@ -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
|
7
ci/docker/thumbv7em-none-eabihf/Dockerfile
Normal file
7
ci/docker/thumbv7em-none-eabihf/Dockerfile
Normal file
@ -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 \
|
7
ci/docker/thumbv7m-none-eabi/Dockerfile
Normal file
7
ci/docker/thumbv7m-none-eabi/Dockerfile
Normal file
@ -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) \
|
||||
-e CARGO_HOME=/cargo \
|
||||
-e CARGO_TARGET_DIR=/target \
|
||||
-e XARGO \
|
||||
-v $HOME/.cargo:/cargo \
|
||||
-v `pwd`/target:/target \
|
||||
-v `pwd`:/checkout:ro \
|
||||
|
50
ci/run.sh
50
ci/run.sh
@ -1,53 +1,24 @@
|
||||
set -ex
|
||||
|
||||
# FIXME(japarix/xargo#186) this shouldn't be necessary
|
||||
export RUST_TARGET_PATH=`pwd`
|
||||
|
||||
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
|
||||
if [ "$XARGO" = "1" ]; then
|
||||
run="xargo test --manifest-path testcrate/Cargo.toml --target $1"
|
||||
for t in $(ls testcrate/tests); 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
|
||||
# FIXME: currently these tests don't work...
|
||||
echo nothing to do
|
||||
else
|
||||
run="cargo test --manifest-path testcrate/Cargo.toml --target $1"
|
||||
$run
|
||||
$run --release
|
||||
$run --features c
|
||||
$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
|
||||
|
||||
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-//')-
|
||||
case $1 in
|
||||
armv7-*)
|
||||
@ -101,8 +72,11 @@ done
|
||||
rm -f $path
|
||||
|
||||
# Verify that we haven't drop any intrinsic/symbol
|
||||
RUSTFLAGS="-C debug-assertions=no" \
|
||||
$cargo build --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -v
|
||||
build_intrinsics="$cargo build --target $1 -v --example intrinsics"
|
||||
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
|
||||
# implementations
|
||||
|
@ -27,7 +27,14 @@ extern {}
|
||||
mod intrinsics {
|
||||
// trunccdfsf2
|
||||
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
|
||||
@ -263,6 +270,10 @@ mod intrinsics {
|
||||
pub fn modti3(a: i128, b: i128) -> i128 {
|
||||
a % b
|
||||
}
|
||||
|
||||
pub fn udivsi3(a: u32, b: u32) -> u32 {
|
||||
a / b
|
||||
}
|
||||
}
|
||||
|
||||
fn run() {
|
||||
@ -325,6 +336,7 @@ fn run() {
|
||||
bb(umodti3(bb(2), bb(2)));
|
||||
bb(divti3(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));
|
||||
|
||||
|
@ -57,7 +57,7 @@ impl Divmod for i32 {}
|
||||
impl Divmod for i64 {}
|
||||
|
||||
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]
|
||||
pub extern "C" fn __divsi3(a: i32, b: i32) -> i32 {
|
||||
a.div(b)
|
||||
|
@ -154,7 +154,7 @@ macro_rules! udivmod_inner {
|
||||
intrinsics! {
|
||||
#[use_c_shim_if(all(target_arch = "arm",
|
||||
not(target_os = "ios"),
|
||||
not(thumbv6m)))]
|
||||
not(thumb_1)))]
|
||||
#[arm_aeabi_alias = __aeabi_uidiv]
|
||||
/// Returns `n / d`
|
||||
pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
|
||||
|
Loading…
Reference in New Issue
Block a user