Skip to content

Commit 946e467

Browse files
committed
Merge remote-tracking branch 'libm/merge-into-builtins-prep' into absorb-libm
Absorb the libm repository into `compiler-builtins`. This was done using `git-filter-repo` to ensure hashes mentioned in commit messages were correctly rewritten, I used the same strategy to merge `ctest` into `libc` [1] and it worked quite well. Approximately: # `git filter-repo` requires a clean clone git clone https://github.com/rust-lang/libm.git # Move all code to a `libm` subdirectory for all history git filter-repo --to-subdirectory-filter libm # The default merge messages are "merge pull request #nnn from # user/branch". GH links these incorrectly in the new repo, so # rewrite messages from `#nnn` to `rust-lang/libm#nnn`. echo 'regex:(^|\s)(#\d+)==>\1rust-lang/libm\2' > messages.txt git filter-repo --replace-message messages.txt # Re-add a remote and push as a new branch git remote add upstream https://github.com/rust-lang/libm.git git switch -c merge-into-builtins-prep git push --set-upstream upstream merge-into-builtins-prep # Now in a compiler-builtins, add `libm` as a remote git remote add libm https://github.com/rust-lang/libm.git git fetch libm # Do the merge that creates this commit git merge libm/merge-into-builtins-prep --allow-unrelated-histories The result should be correct git history and blame for all files, with messages that use correct rewritten hashes when they are referenced. There is some reorganization and CI work needed, but that will be a follow up. After this merges I will need to push tags from `libm`, which I have already rewritten to include a `libm-` prefix. Old tags in compiler-builtins should likely also be rewritten to add a prefix (we already have this for newer tags), but this can be done at any point. * Original remote: https://github.com/rust-lang/libm.git * Default HEAD: c94017af75c3ec4616d5b7f9b6b1b3826b934469 ("Migrate all crates except `libm` to edition 2024") * HEAD after rewriting history: 15fb630 ("Migrate all crates except `libm` to edition 2024") [1]: rust-lang/libc#4283 (comment)
2 parents cf4fd02 + 15fb630 commit 946e467

File tree

261 files changed

+31149
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+31149
-0
lines changed

libm/.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
indent_style = space
13+
indent_size = 4
14+
15+
[*.md]
16+
# double whitespace at end of line
17+
# denotes a line break in Markdown
18+
trim_trailing_whitespace = false
19+
20+
[*.yml]
21+
indent_size = 2

libm/.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Use `git config blame.ignorerevsfile .git-blame-ignore-revs` to make
2+
# `git blame` ignore the following commits.
3+
4+
# Reformat with a new `.rustfmt.toml`
5+
5882cabb83c30bf7c36023f9a55a80583636b0e8

libm/.github/workflows/main.yaml

Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
8+
concurrency:
9+
# Make sure that new pushes cancel running jobs
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
RUSTDOCFLAGS: -Dwarnings
16+
RUSTFLAGS: -Dwarnings
17+
RUST_BACKTRACE: full
18+
BENCHMARK_RUSTC: nightly-2025-01-16 # Pin the toolchain for reproducable results
19+
20+
jobs:
21+
test:
22+
name: Build and test
23+
timeout-minutes: 60
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- target: aarch64-apple-darwin
29+
os: macos-15
30+
# FIXME: pinned due to https://github.com/llvm/llvm-project/issues/127804
31+
channel: nightly-2025-02-07
32+
- target: aarch64-unknown-linux-gnu
33+
os: ubuntu-24.04-arm
34+
# FIXME: pinned due to https://github.com/llvm/llvm-project/issues/127804
35+
channel: nightly-2025-02-07
36+
- target: aarch64-pc-windows-msvc
37+
os: windows-2025
38+
build_only: 1 # Can't run on x86 hosts
39+
- target: arm-unknown-linux-gnueabi
40+
os: ubuntu-24.04
41+
- target: arm-unknown-linux-gnueabihf
42+
os: ubuntu-24.04
43+
- target: armv7-unknown-linux-gnueabihf
44+
os: ubuntu-24.04
45+
- target: i586-unknown-linux-gnu
46+
os: ubuntu-24.04
47+
- target: i686-unknown-linux-gnu
48+
os: ubuntu-24.04
49+
- target: loongarch64-unknown-linux-gnu
50+
os: ubuntu-24.04
51+
- target: powerpc-unknown-linux-gnu
52+
os: ubuntu-24.04
53+
- target: powerpc64-unknown-linux-gnu
54+
os: ubuntu-24.04
55+
- target: powerpc64le-unknown-linux-gnu
56+
os: ubuntu-24.04
57+
- target: riscv64gc-unknown-linux-gnu
58+
os: ubuntu-24.04
59+
- target: thumbv6m-none-eabi
60+
os: ubuntu-24.04
61+
- target: thumbv7em-none-eabi
62+
os: ubuntu-24.04
63+
- target: thumbv7em-none-eabihf
64+
os: ubuntu-24.04
65+
- target: thumbv7m-none-eabi
66+
os: ubuntu-24.04
67+
- target: x86_64-unknown-linux-gnu
68+
os: ubuntu-24.04
69+
- target: x86_64-apple-darwin
70+
os: macos-13
71+
- target: wasm32-unknown-unknown
72+
os: ubuntu-24.04
73+
build_only: 1
74+
- target: i686-pc-windows-msvc
75+
os: windows-2025
76+
- target: x86_64-pc-windows-msvc
77+
os: windows-2025
78+
- target: i686-pc-windows-gnu
79+
os: windows-2025
80+
# FIXME: pinned due to https://github.com/rust-lang/rust/issues/136795
81+
channel: nightly-2025-02-07-i686-gnu
82+
- target: x86_64-pc-windows-gnu
83+
os: windows-2025
84+
channel: nightly-x86_64-gnu
85+
runs-on: ${{ matrix.os }}
86+
env:
87+
BUILD_ONLY: ${{ matrix.build_only }}
88+
steps:
89+
- name: Print runner information
90+
run: uname -a
91+
- uses: actions/checkout@v4
92+
with:
93+
submodules: true
94+
- name: Install Rust (rustup)
95+
shell: bash
96+
run: |
97+
channel="nightly"
98+
# Account for channels that have required components (MinGW)
99+
[ -n "${{ matrix.channel }}" ] && channel="${{ matrix.channel }}"
100+
rustup update "$channel" --no-self-update
101+
rustup default "$channel"
102+
rustup target add "${{ matrix.target }}"
103+
rustup component add clippy llvm-tools-preview
104+
- uses: taiki-e/install-action@nextest
105+
- uses: Swatinem/rust-cache@v2
106+
with:
107+
key: ${{ matrix.target }}
108+
109+
- name: Verify API list
110+
if: matrix.os == 'ubuntu-24.04'
111+
run: python3 etc/update-api-list.py --check
112+
113+
# Non-linux tests just use our raw script
114+
- name: Run locally
115+
if: matrix.os != 'ubuntu-24.04' || contains(matrix.target, 'wasm')
116+
shell: bash
117+
run: ./ci/run.sh ${{ matrix.target }}
118+
119+
# Otherwise we use our docker containers to run builds
120+
- name: Run in Docker
121+
if: matrix.os == 'ubuntu-24.04' && !contains(matrix.target, 'wasm')
122+
run: |
123+
rustup target add x86_64-unknown-linux-musl
124+
cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }}
125+
126+
- name: Print test logs if available
127+
if: always()
128+
run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi
129+
shell: bash
130+
131+
clippy:
132+
name: Clippy
133+
runs-on: ubuntu-24.04
134+
timeout-minutes: 10
135+
steps:
136+
- uses: actions/checkout@master
137+
with:
138+
submodules: true
139+
- name: Install Rust
140+
run: |
141+
rustup update nightly --no-self-update
142+
rustup default nightly
143+
rustup component add clippy
144+
- uses: Swatinem/rust-cache@v2
145+
- run: cargo clippy --all --all-features --all-targets
146+
147+
builtins:
148+
name: Check use with compiler-builtins
149+
runs-on: ubuntu-24.04
150+
timeout-minutes: 10
151+
steps:
152+
- uses: actions/checkout@master
153+
- name: Install Rust
154+
run: rustup update nightly --no-self-update && rustup default nightly
155+
- uses: Swatinem/rust-cache@v2
156+
- run: cargo check --manifest-path crates/compiler-builtins-smoke-test/Cargo.toml
157+
- run: cargo test --manifest-path crates/compiler-builtins-smoke-test/Cargo.toml
158+
159+
benchmarks:
160+
name: Benchmarks
161+
runs-on: ubuntu-24.04
162+
timeout-minutes: 20
163+
steps:
164+
- uses: actions/checkout@master
165+
with:
166+
submodules: true
167+
- uses: taiki-e/install-action@cargo-binstall
168+
169+
- name: Set up dependencies
170+
run: |
171+
sudo apt update
172+
sudo apt install -y valgrind gdb libc6-dbg # Needed for iai-callgrind
173+
rustup update "$BENCHMARK_RUSTC" --no-self-update
174+
rustup default "$BENCHMARK_RUSTC"
175+
# Install the version of iai-callgrind-runner that is specified in Cargo.toml
176+
iai_version="$(cargo metadata --format-version=1 --features icount |
177+
jq -r '.packages[] | select(.name == "iai-callgrind").version')"
178+
cargo binstall -y iai-callgrind-runner --version "$iai_version"
179+
sudo apt-get install valgrind
180+
181+
- uses: Swatinem/rust-cache@v2
182+
183+
- name: Run icount benchmarks
184+
env:
185+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
186+
PR_NUMBER: ${{ github.event.pull_request.number }}
187+
run: ./ci/bench-icount.sh
188+
189+
- name: Upload the benchmark baseline
190+
uses: actions/upload-artifact@v4
191+
with:
192+
name: ${{ env.BASELINE_NAME }}
193+
path: ${{ env.BASELINE_NAME }}.tar.xz
194+
195+
- name: Run wall time benchmarks
196+
run: |
197+
# Always use the same seed for benchmarks. Ideally we should switch to a
198+
# non-random generator.
199+
export LIBM_SEED=benchesbenchesbenchesbencheswoo!
200+
cargo bench --all --features short-benchmarks,build-musl,force-soft-floats
201+
202+
- name: Print test logs if available
203+
if: always()
204+
run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi
205+
shell: bash
206+
207+
msrv:
208+
name: Check MSRV
209+
runs-on: ubuntu-24.04
210+
timeout-minutes: 10
211+
env:
212+
RUSTFLAGS: # No need to check warnings on old MSRV, unset `-Dwarnings`
213+
steps:
214+
- uses: actions/checkout@master
215+
- name: Install Rust
216+
run: |
217+
msrv="$(perl -ne 'print if s/rust-version\s*=\s*"(.*)"/\1/g' libm/Cargo.toml)"
218+
echo "MSRV: $msrv"
219+
rustup update "$msrv" --no-self-update && rustup default "$msrv"
220+
- uses: Swatinem/rust-cache@v2
221+
- run: |
222+
# FIXME(msrv): Remove the workspace Cargo.toml so 1.63 cargo doesn't see
223+
# `edition = "2024"` and get spooked.
224+
rm Cargo.toml
225+
cargo build --manifest-path libm/Cargo.toml
226+
227+
rustfmt:
228+
name: Rustfmt
229+
runs-on: ubuntu-24.04
230+
timeout-minutes: 10
231+
steps:
232+
- uses: actions/checkout@master
233+
- name: Install Rust
234+
run: |
235+
rustup update nightly --no-self-update
236+
rustup default nightly
237+
rustup component add rustfmt
238+
- run: cargo fmt -- --check
239+
240+
# Determine which extensive tests should be run based on changed files.
241+
calculate_extensive_matrix:
242+
name: Calculate job matrix
243+
runs-on: ubuntu-24.04
244+
timeout-minutes: 10
245+
env:
246+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
247+
PR_NUMBER: ${{ github.event.pull_request.number }}
248+
outputs:
249+
matrix: ${{ steps.script.outputs.matrix }}
250+
steps:
251+
- uses: actions/checkout@v4
252+
with:
253+
fetch-depth: 100
254+
- name: Fetch pull request ref
255+
run: git fetch origin "$GITHUB_REF:$GITHUB_REF"
256+
if: github.event_name == 'pull_request'
257+
- run: python3 ci/ci-util.py generate-matrix >> "$GITHUB_OUTPUT"
258+
id: script
259+
260+
extensive:
261+
name: Extensive tests for ${{ matrix.ty }}
262+
needs:
263+
# Wait on `clippy` so we have some confidence that the crate will build
264+
- clippy
265+
- calculate_extensive_matrix
266+
runs-on: ubuntu-24.04
267+
timeout-minutes: 240 # 4 hours
268+
strategy:
269+
matrix:
270+
# Use the output from `calculate_extensive_matrix` to calculate the matrix
271+
# FIXME: it would be better to run all jobs (i.e. all types) but mark those that
272+
# didn't change as skipped, rather than completely excluding the job. However,
273+
# this is not currently possible https://github.com/actions/runner/issues/1985.
274+
include: ${{ fromJSON(needs.calculate_extensive_matrix.outputs.matrix).matrix }}
275+
env:
276+
TO_TEST: ${{ matrix.to_test }}
277+
steps:
278+
- uses: actions/checkout@v4
279+
with:
280+
submodules: true
281+
- name: Install Rust
282+
run: |
283+
rustup update nightly --no-self-update
284+
rustup default nightly
285+
- uses: Swatinem/rust-cache@v2
286+
- name: Run extensive tests
287+
run: |
288+
echo "Tests to run: '$TO_TEST'"
289+
if [ -z "$TO_TEST" ]; then
290+
echo "No tests to run, exiting."
291+
exit
292+
fi
293+
294+
set -x
295+
296+
# Run the non-extensive tests first to catch any easy failures
297+
cargo t --profile release-checked -- "$TO_TEST"
298+
299+
LIBM_EXTENSIVE_TESTS="$TO_TEST" cargo t \
300+
--features build-mpfr,unstable,force-soft-floats \
301+
--profile release-checked \
302+
-- extensive
303+
- name: Print test logs if available
304+
run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi
305+
shell: bash
306+
307+
success:
308+
needs:
309+
- test
310+
- builtins
311+
- benchmarks
312+
- msrv
313+
- rustfmt
314+
- extensive
315+
runs-on: ubuntu-24.04
316+
timeout-minutes: 10
317+
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
318+
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
319+
# dependencies fails.
320+
if: always() # make sure this is never "skipped"
321+
steps:
322+
# Manually check the status of all dependencies. `if: failure()` does not work.
323+
- name: check if any dependency failed
324+
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

libm/.github/workflows/publish.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release-plz
2+
3+
permissions:
4+
pull-requests: write
5+
contents: write
6+
7+
on:
8+
push:
9+
branches:
10+
- master
11+
12+
jobs:
13+
release-plz:
14+
name: Release-plz
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
- name: Install Rust (rustup)
22+
run: rustup update nightly --no-self-update && rustup default nightly
23+
- name: Run release-plz
24+
uses: MarcoIeni/release-plz-action@v0.5
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

libm/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**.bk
2+
.#*
3+
/bin
4+
/math/src
5+
target
6+
Cargo.lock
7+
**.tar.gz
8+
9+
# Benchmark cache
10+
iai-home
11+
baseline-*

libm/.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "musl"]
2+
path = crates/musl-math-sys/musl
3+
url = https://git.musl-libc.org/git/musl
4+
shallow = true

0 commit comments

Comments
 (0)