Commit graph

2171 commits

Author SHA1 Message Date
Mateusz Mikuła
69bedd10d2 compiler-builtins: Enable AArch64 __chkstk for MinGW
Similarly to i686 and X86_64 MinGW targets, Rust needs to provide the
right chkstk symbol for AArch64 to avoid relying on the linker to
provide it.

CC https://github.com/rust-lang/rust/issues/150725
2026-01-08 05:01:35 -05:00
Trevor Gross
65639fe0dc ci: Move the dependency installs and wall time benchmarks to scripts
Make it easier to run the same steps outside of GitHub Actions.
2026-01-04 04:30:19 -05:00
SSD
0d366e098c
Fix a typo in libm::Libm::roundeven 2026-01-02 16:30:25 -05:00
Taiki Endo
1276564146 Ignore unused_unsafe lint in libm/src/math/arch/x86/detect.rs 2025-12-28 04:39:08 +00:00
Trevor Gross
380e4d28b2 compiler-builtins: Revert "cpuid is safe since the stdarch sync, so remove unsafe from usages"
We can't drop the `unsafe` here because it is required at the `libm`
MSRV. Instead, we will need to `allow` the lint.

This reverts commit 96ac3624abc144db930d94504a9c67aad7b949ed.
2025-12-28 04:32:23 +00:00
The rustc-josh-sync Cronjob Bot
a5ed928dea Merge ref '23d01cd241' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 23d01cd241
Filtered ref: 5d28c73d267214190903896b4caf2e40a17a56cb
Upstream diff: 2dc30247c5...23d01cd241

This merge was created using https://github.com/rust-lang/josh-sync.
2025-12-28 04:24:12 +00:00
The rustc-josh-sync Cronjob Bot
6da3605bfa Prepare for merging from rust-lang/rust
This updates the rust-version file to 23d01cd241.
2025-12-28 04:22:01 +00:00
bors
2e854a9344 Auto merge of #150357 - ZuseZ4:zusez4-stdarch-push, r=sayantan
stdarch subtree update

Subtree update of `stdarch` to 61119062fb.

Created using https://github.com/rust-lang/josh-sync.

r? `@sayantn`

My first josh sync, it lgtm, but let me know if I missed something.
I'm especially looking forward to the amd GPU module, which we want to use for the offload project.
2025-12-26 10:44:27 +00:00
Manuel Drehwald
6f06d386b8 cpuid is safe since the stdarch sync, so remove unsafe from usages 2025-12-26 08:46:49 +01:00
Juho Kahala
a9fa80ce91
Fix expm1f overflow threshold
Due to an erroneous overflow threshold, `expm1f` was incorrectly
returning `inf` for inputs in the range `[88.72169, 88.72283]`. This
additionally caused `sinhf` to return `NaN` for inputs in that range.

The bug was ported from the original in musl, which has since been fixed
in [1].

[1]: https://git.musl-libc.org/cgit/musl/commit/?id=964104f9f0e056cf58d9defa0b716d7756f040f6
2025-12-17 05:56:45 +00:00
Juho Kahala
5faeb43a5c
remove uses of Ord::clamp in scalbn (#1047)
Avoid using `Ord::clamp` in the `f16`-specific part of the generic
`scalbn`.

It turned out to be redundant anyway, as both callsites follow a pattern
like
```
if n < negative_val {
    let foo = (n + positive_val).clamp(negative_val, positive_val);
}
```
and `n < negative_val < 0` implies `n + positive_val < positive_val`.

Fixes: rust-lang/compiler-builtins#1046
2025-12-17 05:56:27 +00:00
quaternic
bd06672d1a apply the rename to aarch64_outline_atomics in builtins-test 2025-12-17 05:01:44 +00:00
The rustc-josh-sync Cronjob Bot
18067a7fc8 Merge ref '2dc30247c5' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 2dc30247c5
Filtered ref: dab12aee0f52f7b83cc62ae565855c731bed502f
Upstream diff: 47cd7120d9...2dc30247c5

This merge was created using https://github.com/rust-lang/josh-sync.
2025-12-17 04:58:31 +00:00
The rustc-josh-sync Cronjob Bot
fe791619d0 Prepare for merging from rust-lang/rust
This updates the rust-version file to 2dc30247c5.
2025-12-17 04:56:18 +00:00
Urgau
2422c1d9da Remove [no-mentions] handler in our triagebot config
https://github.blog/changelog/2025-11-07-removing-notifications-for-mentions-in-commit-messages/
2025-12-11 12:13:10 -05:00
Matthias Krüger
76370238b0
Rollup merge of #144938 - tgross35:more-outline-atomics, r=davidtwco
Enable `outline-atomics` by default on more AArch64 platforms

The baseline Armv8.0 ISA doesn't have atomics instructions, but in
practice most hardware is at least Armv8.1-A (2014), which includes
single-instruction atomics as part of the LSE feature. As a performance
optimization for these cases, GCC and LLVM have the `-moutline-atomics` flag
to turn atomic operations into calls to symbols like `__aarch64_cas1_acq`.
These can do runtime feature detection and use the LSE instructions if
available, falling back to more portable load-exclusive/store-exclusive
loops.

Since the recent 3b50253b57 ("compiler-builtins: plumb LSE support
for aarch64 on linux") our builtins support this LSE optimization, and
since 6936bb975a ("Dynamically enable LSE for aarch64 rust provided
intrinsics"), std will set the flag as part of its startup code. The first
commit in this PR configures this to work on all platforms built with
`outline-atomics`, not just Linux.

Thus, enable `outline-atomics` by default on Android, OpenBSD, Windows,
and Fuchsia platforms that don't have LSE in the baseline. The feature is
already enabled on Linux. Platform-specific details are included in each
commit message.

The current implementation can still be accessed by setting
`-Ctarget-feature=-outline-atomics`. Setting `-Ctarget-feature=+lse` or
a relevant CPU will use the single-instruction atomics without the call
overhead. https://rust.godbolt.org/z/dsdrzszoe

Link: https://learn.arm.com/learning-paths/servers-and-cloud-computing/lse/intro/
Original Clang outline-atomics benchmarks: https://reviews.llvm.org/D91157#2435844

try-job: aarch64-msvc-*
try-job: arm-android
try-job: dist-android
try-job: dist-aarch64-llvm-mingw
try-job: dist-aarch64-msvc
try-job: dist-various-*
try-job: test-various
2025-12-09 17:36:47 +01:00
Trevor Gross
d6139b1347 ci: Switch the x86 Apple job to the macos-15-intel runner
`macos-13` is being phased out. Now that GitHub has x86 runners with
MacOS 15, switch those.
2025-12-07 14:48:01 -05:00
Trevor Gross
19b809e8bc ci: Print CPU information for benchmarks
Make it easier to explain possible changes to results on CI.
2025-12-07 14:41:17 -05:00
Trevor Gross
01735687d8 ci: Update the default branch name in remaining workflow files
Missed as part of 936db7f5e890 ("ci: Update the default branch name").
2025-12-07 13:42:54 -05:00
Trevor Gross
b3e2074c6c ci: Simplify untar path list output
Currently the benchmark CI jobs prints multiple pages of paths from the
extracted archive, since `tar` is run with `v`. This is a lot of output
that is usually just noise in CI.

Switch to printing the paths from python instead, limiting to a depth of
three segments (and deduplicating). Removing it completely was an
option, but it's still nice to have a hint about what gets updated.
2025-12-07 13:28:12 -05:00
Trevor Gross
6b159bd845 Update Cargo.toml authors fields
Jorge hasn't been very involved with these crates for a while (thank you
for getting these super important projects going!). Update the `authors`
field to include, as far as I am aware, everyone who has effectively
maintained `compiler-builtins` at some point in time.

This field is dropped from non-published crates.
2025-12-06 03:49:54 -05:00
Trevor Gross
e87befcf98
ci: Enable benchmarks on Aarch64
This was originally attempted at [1], but the numbers seemed to indicate
that tests weren't being run or counted completely. That issue appears
to be resolved, so add benchmarks for Aarch64.

[1]:  https://github.com/rust-lang/compiler-builtins/pull/930
2025-12-06 03:22:14 -05:00
Juho Kahala
65a4f94b71
libm: Implement exp and its variants for i586 with inline assembly
Resolve the severe imprecision (~2%) that is due to inconsistent
rounding.

Closes: https://github.com/rust-lang/compiler-builtins/issues/1021
2025-12-06 08:00:15 +00:00
Juho Kahala
2261a505d9
Remove incorrectly placed preserves_flags, and other inline asm fixes
* `repe` is "repeat while equal", which only makes sense for string
  comparisons. Change it to `rep`. (The encoding is the same so there is
  no performance change.)
* Remove an unneeded `test`. This was added in ae557bde4efc ("Skip rep
  movsb in copy_backward if possible"). The `jz` was removed in
  ef37a23d8417 ("Remove branches around rep movsb/stosb") but the `test`
  was missed.
* Remove an incorrect `preserves_flags`; `add` and `sub` affect flags.

Discussion: https://github.com/rust-lang/compiler-builtins/pull/911
Fixes: ef37a23d8417 ("Remove branches around rep movsb/stosb")
Fixes: c30322aafc9c ("Align destination in mem* instructions.")

[ Added details to the commit message - Trevor ]
2025-12-06 00:59:12 +00:00
quaternic
e2ee56b206 libm: Optimize fmod
This is kind of a retry at rust-lang/compiler-builtins#898. One of the
problems there was that it would have added overhead and regressed
performance for typical inputs.

Unlike that PR, this doesn't aim for sub-linear scaling; the cost of
evaluating `fmod(x, y)` is still roughly proportional to `log2(|x/y|)`.
However, the constant factor is much better. Running the
`random`-benchmarks locally, I got walltime reductions of

    fmodf16:  -56.9%
    fmodf:    -85.0%
    fmod:     -95.4%
    fmodf128: -98.7%
2025-12-05 19:30:08 -05:00
quaternic
ec65d89176 Document the purpose of a helper module 2025-12-05 19:30:08 -05:00
Tobias Decking
21b89a9bf5 Remove remaining traces of AT&T assembly syntax 2025-12-05 14:24:36 -05:00
quaternic
3a93154add Implement accelerated computation of (x << e) % y in unsigned integers 2025-12-05 06:07:18 -05:00
quaternic
5f397632e3 require some basic operators in trait DInt 2025-12-05 06:07:18 -05:00
Trevor Gross
15d03decfb ci: bench: Enable all icount benches in CI
So far we haven't been running the `mem_icount` benches in CI, but this
would be useful. Use a glob pattern for the test so this and future
icount benchmarks all get run.
2025-12-05 04:59:10 -05:00
Trevor Gross
b09903f791 bench: Disambiguate benchmark names in mem_icount
The latest release of gungraun uses global symbols to register tests.
Since it doesn't know about modules, these conflict.

Add the module name so this isn't an issue, but keep the modules around
because they are useful for organization.
2025-12-05 04:58:17 -05:00
Trevor Gross
c8f0d643c0 bench: Add strip = false to the bench profile
This is already the default but gungraun requires it, so make it
explicit.
2025-12-05 04:43:01 -05:00
Trevor Gross
1cfe3585e7 bench: Update the benchmark runner to gungraun 0.17
`iai-callgrind` was renamed to `gungraun` and had a new release. Update
everything to match.

There shouldn't be any changes to observable behavior here.
2025-12-04 21:35:41 -05:00
Trevor Gross
382e9fa4a3 ci: Update the default branch name 2025-12-04 21:35:23 -05:00
Trevor Gross
091c62bcf8 triagebot: Enable the range-diff feature 2025-12-04 18:15:35 -05:00
Trevor Gross
0030e8ab18 compiler-builtins: Change gating for outline atomic symbols
Build outline atomic symbols on all targets that have `outline-atomics`
enabled, rather than only on Linux. Since this is no longer OS-specific,
also rename the module.
2025-12-04 02:26:42 -05:00
The rustc-josh-sync Cronjob Bot
55c229b647 Merge ref '47cd7120d9' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 47cd7120d9
Filtered ref: b5a5cb8beb5c1ac848a39bfcd0ccaad98015d017
Upstream diff: caccb4d036...47cd7120d9

This merge was created using https://github.com/rust-lang/josh-sync.
2025-12-02 11:01:27 +00:00
The rustc-josh-sync Cronjob Bot
94a62dc604 Prepare for merging from rust-lang/rust
This updates the rust-version file to 47cd7120d9.
2025-12-02 10:59:26 +00:00
Trevor Gross
93b5361202 ci: Increase the benchmark rustc version to 2025-12-01
Zerocopy (an indirect test dependency) has started requiring
recently-stabilized features, so upgrade our benchmark toolchain to
match.
2025-12-02 05:22:04 -05:00
Mads Marquart
feb1b52180
Compare against CARGO_CFG_TARGET_FAMILY in a multi-valued fashion
`cfg(target_family = "...")` can be set multiple times, and thus
`CARGO_CFG_TARGET_FAMILY` can also contain comma-separated values,
similar to `CARGO_CFG_TARGET_FEATURE`.

This allows `cargo build --target wasm32-unknown-emscripten -p
musl-math-sys` to work, and will become more important if we were to add
e.g. `cfg(target_family = "darwin")` in the future as discussed in
https://github.com/rust-lang/rust/issues/100343.
2025-10-22 09:35:20 +00:00
Folkert de Vries
261d7ebdc3
stabilize asm_cfg 2025-10-15 20:43:53 +02:00
Trevor Gross
37be71b045 Add back the unsafe for intrinsics::fma but allow(unused_unsafe)
Rustc commit 055e05a338 / builtins commit 2fb3a1871bc9 ("Mark float
intrinsics with no preconditions as safe") changed `fma` and other
intrinsics to not be unsafe to call. Unfortunately we can't remove the
`unsafe` just yet since the rustc we pin for benchmarks is older than
this.

Add back `unsafe` but allow it to be unused.
2025-09-25 20:03:55 +00:00
The rustc-josh-sync Cronjob Bot
374d677c54 Merge ref 'caccb4d036' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: caccb4d036
Filtered ref: 3074203aaad351997a9863b04e251efa3e4b5f6e
Upstream diff: 9385c64c95...caccb4d036

This merge was created using https://github.com/rust-lang/josh-sync.
2025-09-25 04:14:39 +00:00
The rustc-josh-sync Cronjob Bot
a7cfc82b64 Prepare for merging from rust-lang/rust
This updates the rust-version file to caccb4d036.
2025-09-25 04:12:30 +00:00
cyrgani
ee1b36a243
Remove usage of the to-be-deprecated core::f32, core::f64 items
Needed for https://github.com/rust-lang/rust/pull/146882.
2025-09-22 18:51:08 +00:00
ltdk
055e05a338 Mark float intrinsics with no preconditions as safe 2025-09-21 20:37:51 -04:00
Mads Marquart
bc57021f09
doc: Document that os_version_check.c is implemented in std
Since https://github.com/rust-lang/rust/pull/138944.
2025-09-13 12:55:11 -04:00
Taiki Endo
3220121a33
ci: Use nextest on PowerPC64LE and s390x
See https://github.com/taiki-e/install-action/issues/1056 for the
context.
2025-09-10 16:22:44 -04:00
Trevor Gross
b2aa2200aa symcheck: Support both archives and object files
If parsing as an archive is unsuccessful, try parsing as an object
instead before erroring out.
2025-09-07 04:55:27 -04:00
Trevor Gross
641fc3f092 symcheck: Allow checking a standalone archive
Provide an option to check without invoking Cargo first.
2025-09-07 04:52:09 -04:00