rust/library/compiler-builtins
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
..
.github/workflows ci: Increase the benchmark rustc version to 2025-12-01 2025-12-02 05:22:04 -05:00
builtins-shim Remove no-asm gating when there is no alternative implementation 2025-07-27 16:39:31 -05:00
builtins-test Add __addhf3, __subhf3, __mulhf3, __{eq,ge,gt,le,lt,ne,unord}hf2 2025-08-09 15:47:10 -05:00
builtins-test-intrinsics Enable tests that were skipped on PowerPC 2025-07-24 07:18:08 -05:00
ci ci: Add a way to run libm tests that would otherwise be skipped 2025-07-30 08:59:57 +00:00
compiler-builtins Rollup merge of #144938 - tgross35:more-outline-atomics, r=davidtwco 2025-12-09 17:36:47 +01:00
crates Compare against CARGO_CFG_TARGET_FAMILY in a multi-valued fashion 2025-10-22 09:35:20 +00:00
etc Rollup merge of #144443 - WaffleLapkin:integer-target-pointer-width, r=Noratrieb 2025-08-31 13:40:34 +02:00
libm Compare against CARGO_CFG_TARGET_FAMILY in a multi-valued fashion 2025-10-22 09:35:20 +00:00
libm-test Remove usage of the to-be-deprecated core::f32, core::f64 items 2025-09-22 18:51:08 +00:00
.editorconfig Move the libm .editorconfig to root 2025-04-19 20:42:40 -04:00
.git-blame-ignore-revs Update .git-blame-ignore-revs after the libm merge 2025-04-19 20:18:22 +00:00
.gitignore Replace the musl submodule with a download script 2025-06-04 17:20:43 +00:00
.rustfmt.toml Add a .rustfmt.toml with style edition 2024 2025-04-19 19:05:49 -04:00
Cargo.toml Remove josh-sync crate 2025-07-08 08:56:34 +02:00
CONTRIBUTING.md Add documentation about subtree sync 2025-07-10 03:39:18 -04:00
josh-sync.toml Add josh-sync config file 2025-07-08 08:56:34 +02:00
LICENSE.txt Update licensing information after repository refactoring 2025-04-21 06:16:12 -04:00
PUBLISHING.md Update publishing instructions 2019-11-11 10:40:09 -08:00
README.md fixed typo in readme 2025-05-22 11:51:54 +02:00
rust-version Prepare for merging from rust-lang/rust 2025-12-02 10:59:26 +00:00
triagebot.toml Switch to using a GH app for authenticating sync PRs 2025-07-29 08:20:22 +00:00

compiler-builtins and libm

This repository contains two main crates:

  • compiler-builtins: symbols that the compiler expects to be available at link time
  • libm: a Rust implementation of C math libraries, used to provide implementations in core.

More details are at compiler-builtins/README.md and libm/README.md.

For instructions on contributing, see CONTRIBUTING.md.

License

  • libm may be used under the MIT License
  • compiler-builtins may be used under the MIT License and the Apache License, Version 2.0 with the LLVM exception.
  • All original contributions must be under all of: the MIT license, the Apache-2.0 license, and the Apache-2.0 license with the LLVM exception.

More details are in LICENSE.txt and libm/LICENSE.txt.