Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 6eef4db

Browse files
committed
Enable build-mpfr and build-musl by default
Most users who are developing this crate are likely running on a Unix system, since there isn't much to test against otherwise. For convenience, enable the features required to run these tests by default.
1 parent aecd822 commit 6eef4db

File tree

4 files changed

+22
-23
lines changed

4 files changed

+22
-23
lines changed

libm/.github/workflows/main.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ jobs:
131131
- uses: Swatinem/rust-cache@v2
132132
- name: Download musl source
133133
run: ./ci/download-musl.sh
134-
- run: |
135-
cargo clippy --all \
136-
--features libm-test/build-musl,libm-test/build-mpfr \
137-
--all-targets
134+
- run: cargo clippy --all --all-features --all-targets
138135

139136
builtins:
140137
name: Check use with compiler-builtins

libm/CONTRIBUTING.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,12 @@ Check [PR #65] for an example.
6262
Normal tests can be executed with:
6363

6464
```sh
65-
cargo test
65+
# `--release` ables more test cases
66+
cargo test --release
6667
```
6768

68-
If you'd like to run tests with randomized inputs that get compared against
69-
infinite-precision results, run:
70-
71-
```sh
72-
cargo test --features libm-test/build-mpfr,libm-test/build-musl --release
73-
```
69+
If you are on a system that cannot build musl or MPFR, passing
70+
`--no-default-features` will run some limited tests.
7471

7572
The multiprecision tests use the [`rug`] crate for bindings to MPFR. MPFR can
7673
be difficult to build on non-Unix systems, refer to [`gmp_mpfr_sys`] for help.

libm/ci/run.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ if [ -z "$target" ]; then
1414
target="$host_target"
1515
fi
1616

17-
extra_flags=""
17+
# We enumerate features manually.
18+
extra_flags="--no-default-features"
19+
20+
# Enable arch-specific routines when available.
21+
extra_flags="$extra_flags --features arch"
22+
23+
# Always enable `unstable-float` since it expands available API but does not
24+
# change any implementations.
25+
extra_flags="$extra_flags --features unstable-float"
1826

1927
# We need to specifically skip tests for musl-math-sys on systems that can't
2028
# build musl since otherwise `--all` will activate it.
@@ -57,14 +65,8 @@ case "$target" in
5765
*windows-gnu) extra_flags="$extra_flags --exclude libm-macros" ;;
5866
esac
5967

60-
# Make sure we can build with overriding features. We test the indibidual
61-
# features it controls separately.
62-
cargo check --no-default-features
63-
cargo check --features "force-soft-floats"
64-
65-
# Always enable `unstable-float` since it expands available API but does not
66-
# change any implementations.
67-
extra_flags="$extra_flags --features unstable-float"
68+
# Make sure we can build with overriding features.
69+
cargo check -p libm --no-default-features
6870

6971
if [ "${BUILD_ONLY:-}" = "1" ]; then
7072
cmd="cargo build --target $target --package libm"
@@ -80,11 +82,14 @@ else
8082
$cmd --features unstable-intrinsics
8183
$cmd --features unstable-intrinsics --benches
8284

83-
# Test the same in release mode, which also increases coverage.
85+
# Test the same in release mode, which also increases coverage. Also ensure
86+
# the soft float routines are checked.
8487
$cmd --profile release-checked
88+
$cmd --profile release-checked --features force-soft-floats
8589
$cmd --profile release-checked --features unstable-intrinsics
8690
$cmd --profile release-checked --features unstable-intrinsics --benches
8791

88-
ENSURE_NO_PANIC=1 cargo build --target "$target" --release
92+
# Ensure that the routines do not panic.
93+
ENSURE_NO_PANIC=1 cargo build -p libm --target "$target" --no-default-features --release
8994
fi
9095

libm/crates/libm-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55
publish = false
66

77
[features]
8-
default = ["unstable-float"]
8+
default = ["build-mpfr", "build-musl", "unstable-float"]
99

1010
# Propagated from libm because this affects which functions we test.
1111
unstable-float = ["libm/unstable-float", "rug?/nightly-float"]

0 commit comments

Comments
 (0)