Commit graph

2200 commits

Author SHA1 Message Date
Juho Kahala
8cd47adab2
libm: Fix tests for lgamma
The tests were using `rug::ln_gamma` as a reference for `libm::lgamma`,
which actually computes the natural logarithm *of the absolute value* of
the Gamma function.

This changes the range of inputs used for the icount-benchmarks of these
functions, which causes false regressions in [1].

[1]: https://github.com/rust-lang/compiler-builtins/actions/runs/21788698368/job/62864230903?pr=1075#step:7:2710.

Fixes: a1a066611dc2 ("Create interfaces for testing against MPFR")
2026-02-09 04:32:04 -06:00
Trevor Gross
3d0989266d cleanup: Perform some simplifications possible with the MSRV bump 2026-02-07 08:46:41 -06:00
Trevor Gross
1ec5101f20 Bump the libm MSRV to 1.67
This gets us:

* `saturating_sub_unsigned`
* `<int>::ilog2`
* Correct lexing of float literals with the `f16` or `f128` suffix

Link: https://github.com/rust-lang/compiler-builtins/issues/1017
2026-02-07 08:46:41 -06:00
Trevor Gross
7c9ae5b021 meta: Sort Cargo.toml [features] table after [dependencies] 2026-02-07 07:51:17 -06:00
Trevor Gross
0538f7b2ab meta: Switch to workspace dependencies
We have a handful of repeated dependencies that can be cleaned up, so
change here.
2026-02-07 07:51:17 -06:00
Trevor Gross
5768fb7d93 symcheck: Check for core symbols with the new mangling
The recent switch in default mangling meant that the check was no longer
working correctly. Resolve this by checking for both legacy- and
v0-mangled core symbols to the extent that this is possible.
2026-02-07 06:15:42 -06:00
Trevor Gross
9184a5f661 symcheck: Add tests for the symbol checker
Ensure that these are actually doing what is expected.
2026-02-07 05:27:30 -06:00
Trevor Gross
6733cf42a6 symcheck: Enable wasm by default
The build time isn't very different so we can keep things simpler.
2026-02-07 05:27:30 -06:00
Trevor Gross
4d24b508bb meta: Upgrade all dependencies to the latest compatible versions
This allows us to drop wasm-specific configuration for `getrandom`.

Link: 314fd5ab3e/CHANGELOG.md (major-change-to-wasm_js-backend)
2026-02-07 05:13:21 -06:00
Trevor Gross
c9d59bac1e ci: Update all docker images to the latest version 2026-02-07 05:04:08 -06:00
Trevor Gross
7183f983b2 ci: Enable verbose output for josh-sync 2026-02-07 01:42:15 -06:00
Juho Kahala
2f06c639c3 libm: Fix acoshf and acosh for negative inputs
The acosh functions were incorrectly returning finite values for some
negative inputs (should be NaN for any `x < 1.0`)

The bug was inherited when originally ported from musl, and this patch
follows their fix for single-precision acoshf in [1].

A similar fix is applied to acosh, though musl still has an incorrect
implementation requiring tests against that basis to be skipped.

[1]: https://git.musl-libc.org/cgit/musl/commit/?id=c4c38e6364323b6d83ba3428464e19987b981d7a

[ added context to message - Trevor ]
2026-02-07 01:36:46 -06:00
Juho Kahala
5db03861b0 libm-test: Remove exception for fmaximum_num tests
This was left over from f6a23a78c44e ("fmaximum,fminimum: Fix incorrect
result and add tests").

[ added context to body - Trevor ]
2026-02-07 01:36:46 -06:00
Trevor Gross
a47510aa0f Allow unstable_name_collisions
In recent nightlies we are hitting errors like the following:

     error: an associated constant with this name may be added to the standard library in the future
       --> libm/src/math/support/float_traits.rs:248:48
        |
    248 |               const SIGN_MASK: Self::Int = 1 << (Self::BITS - 1);
        |                                                  ^^^^^^^^^^
    ...
    324 | / float_impl!(
    325 | |     f32,
    326 | |     u32,
    327 | |     i32,
    ...   |
    333 | |     fmaf32
    334 | | );
        | |_- in this macro invocation
        |
        = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
        = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
        = note: `-D unstable-name-collisions` implied by `-D warnings`
        = help: to override `-D warnings` add `#[allow(unstable_name_collisions)]`
        = note: this error originates in the macro `float_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
    help: use the fully qualified path to the associated const
        |
    248 -             const SIGN_MASK: Self::Int = 1 << (Self::BITS - 1);
    248 +             const SIGN_MASK: Self::Int = 1 << (<f32 as float_traits::Float>::BITS - 1);
        |
    help: add `#![feature(float_bits_const)]` to the crate attributes to enable `core::f32::<impl f32>::BITS`
       --> libm/src/lib.rs:26:1
        |
     26 + #![feature(float_bits_const)]
        |

Using fully qualified syntax is verbose and `BITS` only exists since
recently, so allow this lint instead.
2026-02-06 22:51:00 +00:00
Trevor Gross
345acb1afd ci: Temporarily disable native PPC and s390x jobs
There are some permission changes that are causing the runners to fail
to launch.

Link: https://github.com/IBM/actionspz/issues/75
2026-02-06 22:51:00 +00:00
The rustc-josh-sync Cronjob Bot
f043a16ffb Merge ref 'db3e99bbab' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: rust-lang/rust@db3e99bbab
Filtered ref: rust-lang/compiler-builtins@970db0bc6d
Upstream diff: 44e34e1ac6...db3e99bbab

This merge was created using https://github.com/rust-lang/josh-sync.
2026-02-05 04:45:01 +00:00
The rustc-josh-sync Cronjob Bot
3a17430745 Prepare for merging from rust-lang/rust
This updates the rust-version file to db3e99bbab.
2026-02-05 04:42:48 +00:00
Stuart Cook
37ece9cf9b
Rollup merge of #151109 - tyhdefu:float_bits_const, r=tgross35
fN::BITS constants for feature float_bits_const

Also enables the feature for compiler_builtins as otherwise this causes a warning and conflicts with the Float extension trait.

---
Implementation for rust-lang/rust#151073

Feature flag: `#![feature(float_bits_const)]`

Note that this is likely to conflict with some extension traits, as it has with compiler builtins. However, assuming correct values for the constants, they are either `u32`, the same type, which should not cause a problem (as shown by enabling the feature for compiler_builtins), or a different type (e.g. `usize`), which should cause a compiler error. Either way this should never change behaviour unless the extension trait implemented an incorrect value.

Also note that it doesn't seem to be possible to put multiple unstable attributes on an item, so `f128::BITS` and `f16::BITS` are gated behind the feature flags for those primitives, rather than `#![feature(float_bits_const)]`
2026-02-03 21:58:39 +11:00
Juho Kahala
d0dc2e7c5f
add -Zjson-target-spec to custom target workflows (#1071)
With the json target specification format destabilized in
https://github.com/rust-lang/rust/pull/150151, `-Zjson-target-spec` is
needed for custom targets. This should resolve the CI failures seen in
rust-lang/compiler-builtins#1070
2026-02-03 00:03:21 -05:00
The rustc-josh-sync Cronjob Bot
ca74d96ac5 Merge ref '44e34e1ac6' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: rust-lang/rust@44e34e1ac6
Filtered ref: rust-lang/compiler-builtins@94ca1bae6b
Upstream diff: 23d01cd241...44e34e1ac6

This merge was created using https://github.com/rust-lang/josh-sync.
2026-01-31 04:34:13 +00:00
The rustc-josh-sync Cronjob Bot
5607150552 Prepare for merging from rust-lang/rust
This updates the rust-version file to 44e34e1ac6.
2026-01-31 04:31:55 +00:00
Brian Cain
1ba6684e16 hexagon: Make fma label local to avoid symbol collision
The `fma:` label in dffma.s was being exported as a global symbol
causing a "symbol 'fma' is already defined" error when linking with
libm's `fma` function.

Unfortunately rust-lang/compiler-builtins#682 removed `.global fma` but
didn't address the implicit global export of the label itself.

    --- old.txt     2026-01-30 20:31:37.265844316 -0600
    +++ new.txt     2026-01-30 20:31:46.531950264 -0600
    @@ -1,4 +1,3 @@
    -00000000 t fma
     00000000 T __hexagon_fmadf4
     00000000 T __hexagon_fmadf5
     00000000 T __qdsp_fmadf5
2026-01-30 21:55:02 -06:00
Trevor Gross
c3eb3fd6df triagebot: Switch to check-commits = "uncanonicalized"
There is now the option to check for `#xxxx`-style issue numbers that
aren't attached to a specific repo. Enable it here.
2026-01-30 21:50:02 -06:00
Trevor Gross
c30563a6bd ci: Pin rustc on the native PowerPC job
Recent nightlies have a miscompile on PowerPC hosts. Pin to a known
working nightly for now.

Link: https://github.com/rust-lang/rust/issues/151807
2026-01-30 21:36:22 -06:00
github-actions[bot]
a88826bb75 chore: release libm v0.2.16
Co-authored-by: Trevor Gross <tg@trevorgross.com>
2026-01-23 21:13:00 -06:00
Juho Kahala
b0f680cfa4
Set codegen-units=1 for benchmarks
This should remove some of the nondeterminism in benchmark results
observed in rust-lang/compiler-builtins#935.
2026-01-23 18:05:22 -06:00
Taiki Endo
bf1239e78c
Implement __sync builtins for thumbv6-none-eabi (#1050)
This is a PR for thumbv6-none-eabi (bere-metal Armv6k in Thumb mode)
which proposed to be added by
https://github.com/rust-lang/rust/pull/150138.

Armv6k supports atomic instructions, but they are unavailable in Thumb
mode unless Thumb-2 instructions available (v6t2).

Using Thumb interworking (can be used via `#[instruction_set]`) allows
us to use these instructions even from Thumb mode without Thumb-2
instructions, but LLVM does not implement that processing (as of LLVM
21), so this PR implements it in compiler-builtins.

The code around `__sync` builtins is basically copied from
`arm_linux.rs` which uses kernel_user_helpers for atomic implementation.
The atomic implementation is a port of my [atomic-maybe-uninit inline
assembly code].

This PR has been tested on QEMU 10.2.0 using patched compiler-builtins
and core that applied the changes in this PR and
https://github.com/rust-lang/rust/pull/150138 and the [portable-atomic
no-std test suite] (can be run with `./tools/no-std.sh
thumbv6-none-eabi` on that repo) which tests wrappers around
`core::sync::atomic`. (Note that the target-spec used in test sets
max-atomic-width to 32 and atomic_cas to true, unlike the current
https://github.com/rust-lang/rust/pull/150138.) The original
atomic-maybe-uninit implementation has been tested on real Arm hardware.

(Note that Armv6k also supports 64-bit atomic instructions, but they are
skipped here. This is because there is no corresponding code in
`arm_linux.rs` (since the kernel requirements increased in 1.64, it may
be possible to implement 64-bit atomics there as well. see also
https://github.com/taiki-e/portable-atomic/pull/82), the code becomes
more complex than for 32-bit and smaller atomics.)

[atomic-maybe-uninit inline assembly code]: https://github.com/taiki-e/atomic-maybe-uninit/blob/HEAD/src/arch/arm.rs
[portable-atomic no-std test suite]: https://github.com/taiki-e/portable-atomic/tree/HEAD/tests/no-std-qemu
2026-01-22 10:09:48 +00:00
James Hendry
3387a58bc7 fN::BITS constants for feature float_bits_const
Also enables the feature for compiler_builtins as otherwise
this causes a warning and conflicts with the Float extension trait

Explicitly use Float trait BITS in miri tests to
prevent warnings against upcoming BITS field for floats
2026-01-15 18:03:08 +00:00
Trevor Gross
c7c5adbe64 compiler-builtins: Remove the no-f16-f128 feature
This option was used to gate `f16` and `f128` when support across
backends and targets was inconsistent. We now have the rustc builtin cfg
`target_has_reliable{f16,f128}` which has taken over this usecase.
Remove no-f16-f128 since it is now unused and redundant.
2026-01-11 07:02:27 -06:00
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