Skip to content

Commit 6024080

Browse files
committed
Auto merge of #166 - alexcrichton:test-c, r=japaric
Test with the 'c' feature enabled on CI
2 parents d63757c + 0ebbcae commit 6024080

25 files changed

+1325
-1261
lines changed

.travis.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cache: cargo
21
dist: trusty
32
language: rust
43
rust: nightly
@@ -28,7 +27,7 @@ matrix:
2827
- env: TARGET=thumbv7m-linux-eabi
2928
- env: TARGET=x86_64-apple-darwin
3029
os: osx
31-
env: TARGET=x86_64-unknown-linux-gnu
30+
- env: TARGET=x86_64-unknown-linux-gnu
3231

3332
before_install:
3433
- test "$TRAVIS_OS_NAME" = "osx" || docker run --rm --privileged multiarch/qemu-user-static:register
@@ -52,8 +51,6 @@ script:
5251
else
5352
sh ci/run.sh $TARGET;
5453
fi
55-
# Travis can't cache files that are not readable by "others"
56-
- chmod -R a+r $HOME/.cargo
5754

5855
notifications:
5956
email:

Cargo.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ compiler-builtins = []
1818
default = ["compiler-builtins"]
1919
mem = []
2020
rustbuild = ["compiler-builtins"]
21+
mangled-names = []
22+
2123
# generate tests
24+
#
25+
# Note that this is an internal-only feature used in testing, this should not
26+
# be relied on with crates.io! Enabling this may expose you to breaking
27+
# changes.
2228
gen-tests = ["cast", "rand"]
2329

2430
[target.'cfg(all(target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux"))'.dev-dependencies]
2531
test = { git = "https://github.com/japaric/utest" }
2632
utest-cortex-m-qemu = { default-features = false, git = "https://github.com/japaric/utest" }
2733
utest-macros = { git = "https://github.com/japaric/utest" }
2834

29-
35+
[[example]]
36+
name = "intrinsics"
37+
required-features = ["c", "compiler-builtins"]
3038

3139
[workspace]

appveyor.yml

+30-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
11
environment:
2+
# It's... a little unclear why the memcpy symbols clash on linux but not on
3+
# other platforms. Would be great to not differ on this though!
4+
INTRINSICS_FAILS_WITH_MEM_FEATURE: 1
5+
26
matrix:
37
- TARGET: i686-pc-windows-msvc
48
- TARGET: x86_64-pc-windows-msvc
59

10+
# Ensure MinGW works, but we need to download the 32-bit MinGW compiler from a
11+
# custom location.
12+
#
13+
# Note that the MinGW builds have tons of references to
14+
# `rust_eh_unwind_resume` in the debug LTO builds that aren't optimized out,
15+
# so we skip that test for now. Would be great to not skip it!
16+
- TARGET: i686-pc-windows-gnu
17+
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci
18+
MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z
19+
MINGW_DIR: mingw32
20+
DEBUG_LTO_BUILD_DOESNT_WORK: 1
21+
- TARGET: x86_64-pc-windows-gnu
22+
DEBUG_LTO_BUILD_DOESNT_WORK: 1
23+
624
install:
725
- git submodule update --init
8-
- curl -sSf -o rustup-init.exe https://win.rustup.rs
26+
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
927
- rustup-init.exe --default-host x86_64-pc-windows-msvc --default-toolchain nightly -y
1028
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
11-
- if "%TARGET%"=="i686-pc-windows-msvc" ( rustup target add %TARGET% )
29+
- if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET%
30+
31+
# Use the system msys
32+
- set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%
33+
34+
# download a custom compiler otherwise
35+
- if defined MINGW_URL appveyor DownloadFile %MINGW_URL%/%MINGW_ARCHIVE%
36+
- if defined MINGW_URL 7z x -y %MINGW_ARCHIVE% > nul
37+
- if defined MINGW_URL set PATH=C:\Python27;%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH%
38+
1239
- rustc -Vv
1340
- cargo -V
1441

1542
build: false
1643

1744
test_script:
18-
- cargo build --target %TARGET%
19-
- cargo build --release --target %TARGET%
20-
- cargo test --no-default-features --features gen-tests --target %TARGET%
21-
- cargo test --no-default-features --features gen-tests --release --target %TARGET%
45+
- sh ci/run.sh %TARGET%

build.rs

+14-50
Original file line numberDiff line numberDiff line change
@@ -4066,28 +4066,8 @@ mod c {
40664066
"divxc3.c",
40674067
"extendsfdf2.c",
40684068
"extendhfsf2.c",
4069-
"ffsdi2.c",
4070-
"fixdfdi.c",
4071-
"fixdfsi.c",
4072-
"fixsfdi.c",
4073-
"fixsfsi.c",
4074-
"fixunsdfdi.c",
4075-
"fixunsdfsi.c",
4076-
"fixunssfdi.c",
4077-
"fixunssfsi.c",
4078-
"fixunsxfdi.c",
4079-
"fixunsxfsi.c",
4080-
"fixxfdi.c",
4081-
"floatdidf.c",
40824069
"floatdisf.c",
4083-
"floatdixf.c",
4084-
"floatsidf.c",
4085-
"floatsisf.c",
4086-
"floatundidf.c",
40874070
"floatundisf.c",
4088-
"floatundixf.c",
4089-
"floatunsidf.c",
4090-
"floatunsisf.c",
40914071
"int_util.c",
40924072
"muldc3.c",
40934073
"muldf3.c",
@@ -4124,18 +4104,6 @@ mod c {
41244104
"cmpti2.c",
41254105
"ctzti2.c",
41264106
"ffsti2.c",
4127-
"fixdfti.c",
4128-
"fixsfti.c",
4129-
"fixunsdfti.c",
4130-
"fixunssfti.c",
4131-
"fixunsxfti.c",
4132-
"fixxfti.c",
4133-
"floattidf.c",
4134-
"floattisf.c",
4135-
"floattixf.c",
4136-
"floatuntidf.c",
4137-
"floatuntisf.c",
4138-
"floatuntixf.c",
41394107
"mulvti3.c",
41404108
"negti2.c",
41414109
"negvti2.c",
@@ -4164,30 +4132,26 @@ mod c {
41644132
if target_arch == "x86_64" {
41654133
sources.extend(
41664134
&[
4167-
"x86_64/floatdidf.c",
41684135
"x86_64/floatdisf.c",
41694136
"x86_64/floatdixf.c",
41704137
],
41714138
);
41724139
}
41734140
} else {
4174-
if target_os != "freebsd" && target_os != "netbsd" {
4175-
sources.extend(&["gcc_personality_v0.c"]);
4176-
}
4177-
4178-
if target_arch == "x86_64" {
4179-
sources.extend(
4180-
&[
4181-
"x86_64/chkstk.S",
4182-
"x86_64/chkstk2.S",
4183-
"x86_64/floatdidf.c",
4184-
"x86_64/floatdisf.c",
4185-
"x86_64/floatdixf.c",
4186-
"x86_64/floatundidf.S",
4187-
"x86_64/floatundisf.S",
4188-
"x86_64/floatundixf.S",
4189-
],
4190-
);
4141+
// None of these seem to be used on x86_64 windows, and they've all
4142+
// got the wrong ABI anyway, so we want to avoid them.
4143+
if target_os != "windows" {
4144+
if target_arch == "x86_64" {
4145+
sources.extend(
4146+
&[
4147+
"x86_64/floatdisf.c",
4148+
"x86_64/floatdixf.c",
4149+
"x86_64/floatundidf.S",
4150+
"x86_64/floatundisf.S",
4151+
"x86_64/floatundixf.S",
4152+
],
4153+
);
4154+
}
41914155
}
41924156

41934157
if target_arch == "x86" {

ci/run.sh

+68-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
set -ex
22

3+
case $1 in
4+
thumb*)
5+
cargo=xargo
6+
;;
7+
*)
8+
cargo=cargo
9+
;;
10+
esac
11+
12+
INTRINSICS_FEATURES="c"
13+
14+
# Some architectures like ARM apparently seem to require the `mem` feature
15+
# enabled to successfully compile the `intrinsics` example, and... we're not
16+
# sure why!
17+
if [ -z "$INTRINSICS_FAILS_WITH_MEM_FEATURE" ]; then
18+
INTRINSICS_FEATURES="$INTRINSICS_FEATURES mem"
19+
fi
20+
321
# Test our implementation
422
case $1 in
523
thumb*)
@@ -33,35 +51,14 @@ case $1 in
3351
done
3452
;;
3553
*)
36-
cargo test --no-default-features --features gen-tests --target $1
37-
cargo test --no-default-features --features gen-tests --target $1 --release
54+
run="cargo test --no-default-features --target $1"
55+
$run --features 'gen-tests mangled-names'
56+
$run --features 'gen-tests mangled-names' --release
57+
$run --features 'gen-tests mangled-names c'
58+
$run --features 'gen-tests mangled-names c' --release
3859
;;
3960
esac
4061

41-
# Verify that we haven't drop any intrinsic/symbol
42-
case $1 in
43-
thumb*)
44-
xargo build --features c --target $1 --example intrinsics
45-
;;
46-
*)
47-
cargo build --no-default-features --features c --target $1 --example intrinsics
48-
;;
49-
esac
50-
51-
# Verify that there are no undefined symbols to `panic` within our implementations
52-
# TODO(#79) fix the undefined references problem for debug-assertions+lto
53-
case $1 in
54-
thumb*)
55-
RUSTFLAGS="-C debug-assertions=no" xargo rustc --no-default-features --features c --target $1 --example intrinsics -- -C lto -C link-arg=-nostartfiles
56-
xargo rustc --no-default-features --features c --target $1 --example intrinsics --release -- -C lto
57-
;;
58-
*)
59-
RUSTFLAGS="-C debug-assertions=no" cargo rustc --no-default-features --features c --target $1 --example intrinsics -- -C lto
60-
cargo rustc --no-default-features --features c --target $1 --example intrinsics --release -- -C lto
61-
;;
62-
esac
63-
64-
# Look out for duplicated symbols when we include the compiler-rt (C) implementation
6562
PREFIX=$(echo $1 | sed -e 's/unknown-//')-
6663
case $1 in
6764
armv7-*)
@@ -75,7 +72,7 @@ case $1 in
7572
;;
7673
esac
7774

78-
case $TRAVIS_OS_NAME in
75+
case "$TRAVIS_OS_NAME" in
7976
osx)
8077
# NOTE OSx's nm doesn't accept the `--defined-only` or provide an equivalent.
8178
# Use GNU nm instead
@@ -87,22 +84,60 @@ case $TRAVIS_OS_NAME in
8784
;;
8885
esac
8986

90-
if [ $TRAVIS_OS_NAME = osx ]; then
91-
path=target/${1}/debug/deps/libcompiler_builtins-*.rlib
92-
else
87+
if [ -d /target ]; then
9388
path=/target/${1}/debug/deps/libcompiler_builtins-*.rlib
89+
else
90+
path=target/${1}/debug/deps/libcompiler_builtins-*.rlib
9491
fi
9592

93+
# Look out for duplicated symbols when we include the compiler-rt (C) implementation
9694
for rlib in $(echo $path); do
97-
stdout=$($PREFIX$NM -g --defined-only $rlib)
95+
set +x
96+
stdout=$($PREFIX$NM -g --defined-only $rlib 2>&1)
9897

99-
# NOTE On i586, It's normal that the get_pc_thunk symbol appears several times so ignore it
98+
# NOTE On i586, It's normal that the get_pc_thunk symbol appears several
99+
# times so ignore it
100+
#
101+
# FIXME(#167) - we shouldn't ignore `__builtin_cl` style symbols here.
100102
set +e
101-
echo "$stdout" | sort | uniq -d | grep -v __x86.get_pc_thunk | grep 'T __'
103+
echo "$stdout" | \
104+
sort | \
105+
uniq -d | \
106+
grep -v __x86.get_pc_thunk | \
107+
grep -v __builtin_cl | \
108+
grep 'T __'
109+
110+
if test $? = 0; then
111+
exit 1
112+
fi
113+
set -ex
114+
done
115+
116+
rm -f $path
117+
118+
# Verify that we haven't drop any intrinsic/symbol
119+
RUSTFLAGS="-C debug-assertions=no" \
120+
$cargo build --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -v
121+
122+
# Verify that there are no undefined symbols to `panic` within our
123+
# implementations
124+
#
125+
# TODO(#79) fix the undefined references problem for debug-assertions+lto
126+
if [ -z "$DEBUG_LTO_BUILD_DOESNT_WORK" ]; then
127+
RUSTFLAGS="-C debug-assertions=no" \
128+
$cargo rustc --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -- -C lto
129+
fi
130+
$cargo rustc --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics --release -- -C lto
131+
132+
# Ensure no references to a panicking function
133+
for rlib in $(echo $path); do
134+
set +ex
135+
$PREFIX$NM -u $rlib 2>&1 | grep panicking
102136

103137
if test $? = 0; then
104138
exit 1
105139
fi
140+
set -ex
106141
done
107142

108143
true

0 commit comments

Comments
 (0)