2104 Commits

Author SHA1 Message Date
Trevor Gross
5978b8b875 aarch64: Add a note saying why we use frintx rather than frintn 2025-05-28 21:10:28 +00:00
Dario Damiani
c04f133858 Typo in README.md
Link to Apache License changed from htps:// to https://
2025-05-28 15:51:49 -04:00
Trevor Gross
4c264c96ae Update CmpResult to use a pointer-sized return type
As seen at [1], LLVM uses `long long` on LLP64 (to get a 64-bit integer
matching pointer size) and `long` on everything else, with exceptions
for AArch64 and AVR. Our current logic always uses an `i32`. This
happens to work because LLVM uses 32-bit instructions to check the
output on x86-64, but the GCC checks the full 64-bit register so garbage
in the upper half leads to incorrect results.

Update our return type to be `isize`, with exceptions for AArch64 and
AVR.

Fixes: https://github.com/rust-lang/compiler-builtins/issues/919

[1]: 0cf3c437c1/compiler-rt/lib/builtins/fp_compare_impl.inc (L11-L27)
2025-05-28 02:58:42 -04:00
Trevor Gross
db21837095 libm: Clean up unused files
These were deleted during refactoring in 0a2dc5d9 ("Combine the source
files for more generic implementations") but got added back by accident
in 54bac411 ("refactor: Move the libm crate to a subdirectory"). Remove
them again here.
2025-05-22 13:22:51 +02:00
Pályi Lőrinc
7966f1b556 fixed typo in readme 2025-05-22 11:51:54 +02:00
beetrees
11c1522955 Enable __powitf2 on MSVC 2025-05-21 19:24:24 +02:00
Folkert de Vries
abbf8fe6e7 fix an if statement that can be collapsed 2025-05-18 12:01:05 +02:00
Tobias Decking
d16c82dba1 Fix i256::MAX 2025-05-13 15:01:51 +02:00
github-actions[bot]
65663b538f chore(compiler_builtins): release v0.1.159 2025-05-12 16:37:12 +02:00
nora
c4c7f25c4c Remove cfg(bootstrap)
Foe the  bootstrap bump
2025-05-12 16:26:35 +02:00
Trevor Gross
1768cb1731 release-plz: Include the libm changelog in compiler-builtins 2025-05-06 19:37:58 -04:00
github-actions[bot]
0d63b99799 chore: release 2025-05-06 19:37:58 -04:00
Trevor Gross
61a14fcea0 Require target_has_atomic = "ptr" for runtime feature detection
The `feature_detect` module is currently being built on all targets, but
the use of `AtomicU32` causes a problem if atomics are not available
(such as with `bpfel-unknown-none`). Gate this module behind
`target_has_atomic = "ptr"`.

The below now completes successfully:

    cargo build -p compiler_builtins --target=bpfel-unknown-none -Z build-std=core

Fixes: https://github.com/rust-lang/compiler-builtins/issues/908
2025-05-06 17:59:03 -04:00
Trevor Gross
339793d62b ci: Mention ci: skip-extensive in the error message 2025-05-05 02:31:52 -04:00
Trevor Gross
687902c1af Replace super::super with crate::support where possible
Since `crate::support` now works in both `compiler-builtins` and `libm`,
we can get rid of some of these unusual paths.
2025-05-05 02:31:52 -04:00
ELginas
5032002c2f docs: fix typo in Cargo.toml
Initially introduced in 63ccaf11f08fb5d0b39cc33884c5a1a63f547ace

Signed-off-by: ELginas <gintaras.z123@yahoo.com>
2025-05-04 23:35:00 -04:00
github-actions[bot]
16150ebb31 chore: release 2025-05-04 18:52:58 -04:00
Trevor Gross
8995ac0448 Use runtime feature detection for fma routines on x86
Get performance closer to the glibc implementations by adding assembly
fma routines, with runtime feature detection so they are used even if
not compiled with `+fma` (as the distributed standard library is often
not). Glibc uses ifuncs, this implementation stores a function pointer
in an atomic.

Results of CPU flags are also cached in order to avoid repeating the
startup time in calls to different functions. The feature detection code
is a slightly simplified version of `std-detect`.

Musl sources were used as a reference [1].

Fixes: https://github.com/rust-lang/rust/issues/140452 once synced

[1]: c47ad25ea3/src/math/x32/fma.c
2025-05-03 14:17:49 -04:00
Trevor Gross
4a1dc96652 Rename the i686 module to x86
This module is used for both i686 and x86-64.
2025-05-03 14:17:49 -04:00
Trevor Gross
2705f686b5 update-api-list: Match subdirectories within arch 2025-05-03 14:17:49 -04:00
Trevor Gross
1c5f8cc72d fmaf: Add a test case from a MinGW failure
This is a known problem in the MinGW fmaf implementation, identified at
[1].  Make sure our implementation passes this edge case.

[1]: https://github.com/rust-lang/rust/issues/140515
2025-05-01 21:24:34 -04:00
Trevor Gross
4c2659f9ce builtins-test: Remove no_mangle from eh_personality
Rustc now mangles these symbols on its own, so `no_mangle` is rejected
as an error.
2025-05-01 15:03:07 -04:00
Trevor Gross
caf337d467 Refactor the fma modules
Move implementations to `generic/` like the other functions. This also
allows us to combine the `fma` and `fma_wide` modules.
2025-04-29 19:09:50 -04:00
Trevor Gross
6d83a3226f Move fma implementations to mod generic
This will not build correctly, the move is done as a separate step from
the rest of refactoring so git's history is cleaner.
2025-04-29 19:09:50 -04:00
Trevor Gross
8d789ea8f1 Resolve unnecessary_transmutes lints
These appeared in a later nightly. In compiler-builtins we can apply the
suggestion, but in `libm` we need to ignore them since `fx::from_bits`
is not `const` at the MSRV.

`clippy::uninlined_format_args` also seems to have gotten stricter, so
fix those here.
2025-04-29 18:15:02 -04:00
Trevor Gross
975617e8d4 Warn on unsafe_op_in_unsafe_fn by default
Edition 2024 requires that we avoid this. There is a lot of code that
will need to be adjusted, so start the process here with a warning that
will show up in CI.
2025-04-23 15:27:05 -04:00
Trevor Gross
99202af075 libm-macros: Allow a way to bulk match f16 and f128 functions
These are never available in musl, so introduce easier ways to skip them
rather than needing to exclude f16/f128 functions in three different
places.
2025-04-23 15:04:51 -04:00
Trevor Gross
1dd39e27f0 libm-macros: Start tracking which functions are public
It would be nice to reuse some of the macro structure for internal
functions, like `rem_pio2`. To facilitate this, add a `public` field and
make it available in the macro's API.
2025-04-23 03:48:02 -04:00
Trevor Gross
b6db36061e musl: Update submodule
Update the musl submodule to c47ad25ea3 ("iconv: harden UTF-8 output
code path against input decoder bugs").
2025-04-22 17:09:18 -04:00
Trevor Gross
5028ecd025 chore: Release libm v0.2.13 2025-04-22 04:44:00 -04:00
Trevor Gross
d30dde73b3 fix: Switch to resolver v2
The published crates fail to build with an edition less than 2024
because they are packaged with `resolver = "3"`, which is a 2024-only
option. Revert back to resolver v2 to drop this requirement.

Fixes: https://github.com/rust-lang/compiler-builtins/issues/883
2025-04-22 04:00:49 -04:00
Trevor Gross
aec649faae chore: Combine CHANGELOG files for compiler-builtins
This unintentionally got split when compiler-builtins was moved to a
subdirectory.
2025-04-22 01:34:46 -04:00
github-actions[bot]
1fa9d0fce3 chore: release builtins 0.1.156 and libm 0.2.12 2025-04-22 01:34:46 -04:00
quaternic
e075e9fbde Reimplement the generic fmod 2025-04-22 00:53:56 -04:00
Trevor Gross
a8652953e4 Rename the public-test-deps feature to unstable-public-internals
`compiler-builtins` uses `public-test-deps`, `libm` uses
`unstable-public-internals`. Consolidate these under the `libm` name.

Once compiler-builtins is no longer published, this feature can probably
be dropped.

Also switch to `dep:` syntax for features that enable dependencies.
2025-04-21 23:24:52 -04:00
Trevor Gross
13b94cf89f ci: Fix extensive tests
Move this to a script and ensure only `libm-test` gets built to avoid
default feature issues with `compiler-builtins`.
2025-04-21 22:50:42 -04:00
Trevor Gross
913796c1c5 Fix compiler-builtins publish
compiler-builtins currently wouldn't publish correctly because of a
relative path to `libm` that doesn't get included in the package. Fix
this by simlinking `libm` to within the `compiler-builtins` directory.

Also symlink LICENSE.txt which lets us drop the `include` array in
Cargo.toml. LICENSE.txt and compiler-rt were not being included anyway,
since Cargo silently drops items that are not within the crate
directory.
2025-04-21 06:16:12 -04:00
Trevor Gross
94448a6ff6 Update README and CONTRIBUTING for the new repository layout 2025-04-21 06:16:12 -04:00
Trevor Gross
8ce02e8ef5 Move README.md to compiler-builtins, CONTRIBUTING.md to root
Do this in a commit so git tracks the move; a new README will be
introduced in the root, and CONTRIBUTING will be updated to apply to
both crates.
2025-04-21 06:16:12 -04:00
Trevor Gross
013a83acdd Update licensing information after repository refactoring
In order to disambiguate things now that libm is part of the
compiler-builtins repository, do the following:

* Mention libm in LICENSE.txt
* Clarify the default license for crates other than libm and
  compiler-builtins
* Add an explicit license field to Cargo.toml for all other crates
2025-04-21 06:16:12 -04:00
Patryk Wychowaniec
e0d07241d0 avr: Provide abort() 2025-04-21 03:02:24 -04:00
Trevor Gross
97ddaca356 Remove unsafe from naked_asm! blocks
This was changed in a recent nightly so the unsafety is only in the
attribute, `#[unsafe(naked)]`.
2025-04-21 02:45:06 -04:00
Trevor Gross
cf13785636 ci: Fix release-plz configuration 2025-04-20 14:50:27 -04:00
Trevor Gross
4e8eea696d Add panic-handler to the workspace
This crate does not interact with features so there isn't any reason it
can't become part of the workspace.
2025-04-20 05:33:19 -04:00
Trevor Gross
66be06a1a7 ci: Remove the old libm workflow file
All jobs are now run as part of `compiler-builtins`.
2025-04-20 05:33:19 -04:00
Trevor Gross
97e4729525 ci: Configure release-plz to run semver checks on libm 2025-04-20 05:33:19 -04:00
Trevor Gross
46bbc3dd88 ci: Clean up workflow file and docker script 2025-04-20 05:33:19 -04:00
Trevor Gross
13bf5f5bb4 ci: Use lowercase for bash locals, fix shellcheck 2025-04-20 05:33:19 -04:00
Trevor Gross
ee431374eb ci: Add a timeout for all jobs 2025-04-20 04:39:06 -04:00
Trevor Gross
8902f740da ci: Skip testing libm in PRs if it did not change
Many contributions to compiler-builtins don't have any need to touch
libm, and could get by with the few minutes of CI for compiler-builtins
rather than the ~30 minutes for libm. We already have some scripts that
handle changed file detection, so expand its use to skip libm CI if it
doesn't need to run.
2025-04-20 04:24:24 -04:00