2049 Commits

Author SHA1 Message Date
Trevor Gross
7222fa6f34 Work around out-of-tree testing with a shim crate
Out-of-tree testing is broken with the most recent update from
rust-lang/rust because it makes `compiler-builtins` depend on `core` by
path, which isn't usually available. In order to enable testing outside
of rust-lang/rust, add a new crate `builtins-shim` that uses the same
source as `compiler-builtins` but drops the `core` dependency. This has
replaced `compiler-builtins` as the workspace member and entrypoint for
tests.
2025-06-14 06:56:18 +00:00
Trevor Gross
c1cd1ef5fc Merge ref 'd087f112b7d1:/library/compiler-builtins' from https://github.com/rust-lang/rust
Pull recent changes from rust-lang/rust via Josh.

Upstream ref: d087f112b7d1323446c7b39a8b616aee7fa56b3d
Filtered ref: 2d43ce8ac022170e5383f7e5a188b55564b6566a
2025-06-14 06:56:04 +00:00
Trevor Gross
c629d857b0 Update the upstream Rust version
To prepare for merging from rust-lang/rust, set the version file to:

    d087f112b7 Auto merge of #134841 - estebank:serde-attr-4, r=wesleywiser
2025-06-14 04:25:55 +00:00
Trevor Gross
4b2b463eea Delete .release-plz.toml
The config file is not needed anymore since compiler-builtins is no
longer published. Removing it will resolve a CI failure.
2025-06-14 03:38:53 +00:00
Trevor Gross
19b47ae1f4 Mark compiler-builtins as publish = false
Now that this repository is a subtree, we have no need to continue
publishing `compiler-builtins`.
2025-06-13 18:15:18 +00:00
Trevor Gross
509b8f2291 Clean up and sort manifest keys
Use a consistent ordering for top-level manifest keys, and remove those
that are now redundant (`homapage` isn't supposed to be the same as
`repository`, and `documentation` automatically points to docs.rs now).
2025-06-13 17:35:21 +00:00
Trevor Gross
10ba25f7ce fmaximum,fminimum: Fix incorrect result and add tests
After adding tests, the current implementation for fminimum fails when
provided a negative zero and NaN as inputs:

    ---- math::fminimum_fmaximum_num::tests::fmaximum_num_spec_tests_f64 stdout ----

    thread 'math::fminimum_fmaximum_num::tests::fmaximum_num_spec_tests_f64' panicked at libm/src/math/fminimum_fmaximum_num.rs:240:13:
    fmaximum_num(-0x0p+0, NaN)
    l: NaN (0x7ff8000000000000)
    r: -0.0 (0x8000000000000000)

    ---- math::fminimum_fmaximum_num::tests::fmaximum_num_spec_tests_f32 stdout ----

    thread 'math::fminimum_fmaximum_num::tests::fmaximum_num_spec_tests_f32' panicked at libm/src/math/fminimum_fmaximum_num.rs:240:13:
    fmaximum_num(-0x0p+0, NaN)
    l: NaN (0x7fc00000)
    r: -0.0 (0x80000000)

Add more thorough spec tests for these functions and correct the
implementations.

Canonicalization is also moved to a trait method to centralize
documentation about what it does and doesn't do.
2025-06-13 15:36:58 +00:00
qinghon
013e06c5ff
Eliminate build.rs-generated Aarch64 atomic macros (#951)
Replace `build.rs` Rust generation with macros, using the unstable
`${concat(...)}`.

Fixes: https://github.com/rust-lang/compiler-builtins/issues/947
2025-06-13 01:27:47 -04:00
Folkert de Vries
b030442eb6
indent the probestack inline assembly 2025-06-10 10:09:00 +02:00
Folkert de Vries
45d649e2ea
merge the sgx/fortanix __rust_probestack into the general x86_64 one 2025-06-10 10:09:00 +02:00
Folkert de Vries
b6eb4f9c3a
use #[naked] for __rust_probestack 2025-06-10 10:08:57 +02:00
Folkert de Vries
f3af86010b
add a fixme to use extern_custom when available 2025-06-10 10:08:08 +02:00
Trevor Gross
b5fafd9816 ci: Fix a typo that was causing a command failure 2025-06-10 07:02:57 +00:00
Trevor Gross
3497619ec1 compiler-builtins: Remove unused lints.rust table
The unexpected configs are now unused or known to `rustc` in our CI.
2025-06-10 06:49:28 +00:00
Trevor Gross
fc71544932 compiler-builtins: Emit rustc-check-cfg earlier
The `build.rs` entrypoint returns early for some targets, so emscripten
and OpenBSD were not getting check-cfg set. Emit these earlier to avoid
the `unexpected_cfgs` lint.
2025-06-09 04:46:54 +00:00
Trevor Gross
f131c2fa47 compiler-builtins: Specify :r registers for usize
On the ILP32 `x86_64-unknown-linux-gnux32` target, `usize` is 32 bits so
there is a sub-register alignment warning. Specify the 64-bit `r`
registers, which matches the current default as well as the size of the
other operands in the routines.
2025-06-09 04:46:54 +00:00
Trevor Gross
58bef69b81 compiler-builtins: Resolve unsafe_op_in_unsafe_fn on Arm32 Android
There are a few places that violate this lint, which showed up in
rust-lang/rust CI (the relevent module is gated behind
`kernel_user_helpers` which is only set for `armv4t`, `armv5te`, and
`arm-linux-androideabi`; none of these are tested in compiler-builtins
CI). Add new `unsafe { /* ... */ }` blocks where needed to address this.

Some blocks should get a more thorough review of their preconditions, so
their safety comments are left as `FIXME`s.
2025-06-09 04:46:52 +00:00
Trevor Gross
f43bb2ac99 compiler-builtins: Fix a rustdoc::bare-urls error 2025-06-08 02:36:58 +00:00
Trevor Gross
cc3e57147e Use the in-tree compiler-builtins
Many of `std`'s dependency have a dependency on the crates.io
`compiler-builtins` when used with the feature
`rustc-std-workspace-core`. Use a Cargo patch to select the in-tree
version instead.

`compiler-builtins` is also added as a dependency of
`rustc-std-workspace-core` so these crates can remove their crates.io
dependency in the future.
2025-06-08 02:36:58 +00:00
Trevor Gross
ab453db3c4 panic-handler: Remove the no_core feature
This was introduced before `#[panic_handler]` was stable, but should no
longer be needed. Additionally, we only need it for
`builtins-test-intrinsics`, not as a dependency of `compiler-builtins`.
2025-06-04 21:27:00 +00:00
Trevor Gross
1599091459 Merge ref 'df8102fe5f24:/library/compiler-builtins' from https://github.com/rust-lang/rust
Pull recent changes from rust-lang/rust via Josh.

Upstream ref: df8102fe5f24f28a918660b0cd918d7331c3896e
Filtered ref: 3c30d8cb1ec24e0b8a88a5cedcf6b9bece0117d7
2025-06-04 18:10:09 +00:00
Trevor Gross
eb45e57afe Update the upstream Rust version
To prepare for merging from rust-lang/rust, set the version file to:

    df8102fe5f Auto merge of #142002 - onur-ozkan:follow-ups2, r=jieyouxu
2025-06-04 18:10:07 +00:00
Trevor Gross
3353a891e3 Add tooling for josh syncs
Create a crate that handles pulling from and pushing to rust-lang/rust.
This can be invoked with the following:

    $ cargo run -p josh-sync -- rustc-pull
    $ RUSTC_GIT=/path/to/rust/checkout cargo run -p josh-sync -- rustc-push <username>
2025-06-04 18:06:15 +00:00
Trevor Gross
f67ca0fe37 Add an empty rust-version file
This will be used by `josh` tooling.
2025-06-04 17:30:37 +00:00
Trevor Gross
e1e3cc24a2 Replace the musl submodule with a download script
The submodule was causing issues in rust-lang/rust, so eliminiate it
here. `build-musl` is also removed from `libm-test`'s default features
so the crate doesn't need to be built by default.
2025-06-04 17:20:43 +00:00
Trevor Gross
aff21f659f compiler-builtins: Eliminate symlinks
compiler-builtins has a symlink to the `libm` source directory so the
two crates can share files but still act as two separate crates. This
causes problems with some sysroot-related tooling, however, since
directory symlinks seem to not be supported.

The reason this was a symlink in the first place is that there isn't an
easy for Cargo to publish two crates that share source (building works
fine but publishing rejects `include`d files from parent directories, as
well as nested package roots). However, after the switch to a subtree,
we no longer need to publish compiler-builtins; this means that we can
eliminate the link and just use `#[path]`.

Similarly, the LICENSE file was symlinked so it could live in the
repository root but be included in the package. This is also removed as
it caused problems with the dist job (error from bootstrap's
`tarball.rs`, "generated a symlink in a tarball").

If we need to publish compiler-builtins again for any reason, it would
be easy to revert these changes in a preprocess step.
2025-06-02 23:59:11 +00:00
Trevor Gross
5778643174 libm-test: Fix unintentional skips in binop_common
`binop_common` emits a `SKIP` that is intended to apply only to
`copysign`, but is instead applying to all binary operators. Correct the
general case but leave the currently-failing `maximum_num` tests as a
FIXME, to be resolved separately in [1].

Also simplify skip logic and NaN checking, and add a few more `copysign`
checks.

[1]: https://github.com/rust-lang/compiler-builtins/pull/939
2025-06-02 22:47:15 +00:00
Trevor Gross
ba7cdb6814 ci: Refactor benchmark regression checks
iai-callgrind now correctly exits with error if regressions were found
[1], so we no longer need to check for regressions manually. Remove this
check and instead exit based on the exit status of the benchmark run.

[1] https://github.com/iai-callgrind/iai-callgrind/issues/337
2025-06-02 21:29:46 +00:00
Trevor Gross
e83ca86341 cleanup: Use x.biteq(y) rather than x.to_bits() == y.to_bits() 2025-06-02 16:10:49 +00:00
Trevor Gross
0a7e59265a Upgrade all dependencies to the latest available version
In particular, this includes a fix to `iai-callgrind` that will allow us
to simplify our benchmark runner.
2025-06-01 19:57:14 +00:00
Trevor Gross
c6df6a72d8 Fix new dead_code warnings from recent nightlies 2025-06-01 19:54:30 +00:00
github-actions[bot]
3c35505fe9 chore: release 2025-05-30 15:18:27 +00:00
Trevor Gross
4d325e8b2c ci: Allow for multiple icount benchmarks in the same run
We don't actually need this for now, but eventually it would be nice to
run icount benchmarks on multiple targets. Start tagging artifact names
with the architecture, and allow passing `--tag` to `ci-util.py` in
order to retrieve the correct one.
2025-05-29 21:58:21 +00:00
Trevor Gross
8edaa6e5c8 libm-test: Make extensive an attribute rather than a test type
Currently we run logspace tests for extensive tests, but there isn't any
reason we couldn't also run more kinds of tests more extensively (e.g.
more edge cases, combine edge cases with logspace for multi-input
functions, etc). As a first step toward making this possible, make
`extensive` a new field in `CheckCtx`, and rename `QuickSpaced` to
`Spaced`.
2025-05-29 21:06:44 +00:00
Trevor Gross
9f84e9904f Increase the benchmark rustc version to 2025-05-28
We may soon want to use some new nightly features in `compiler-builtins`
and `libm`, specifically `cfg_target_has_reliable_f16_f128` which was
added in the past few weeks. This will mean we need a newer toolchain
for benchmarks to continue building.

Bump to the current latest nightly so we are not blocked on this down
the line.
2025-05-29 19:56:59 +00:00
Trevor Gross
3464b4b231 ci: Allow concurrency outside of pull requests
When multiple merges to `master` happen before a CI run completes, the
in-progress job is getting canceled. Fix this by using the commit sha
for the group key if a pull request number is not available, rather than
`github.ref` (which is always `refs/head/master` after merge). This
should prevent jobs running on previous commits from getting cancelled,
while still ensuring there is only ever one active run per pull request.
2025-05-29 19:01:03 +00:00
Trevor Gross
c136fb7734 Run builtins-test-intrinsics when possible
Currently we only build this, but it is possible to run the binary.
Change the CI script to do so here.
2025-05-29 18:46:06 +00:00
Trevor Gross
7db8cf1fea Add benchmarks for float parsing and printing
As part of this, the u256 benchmarks are reorganized to a group.
2025-05-29 18:03:16 +00:00
Trevor Gross
af16553893 symcheck: Print the command to make reproducing errors easier 2025-05-29 16:12:33 +00:00
Trevor Gross
151b1cb047 Change compiler-builtins to edition 2024
Do the same for `builtins-test-intrinsics`. Mostly this means updating
`extern` to `unsafe extern`, and fixing a few new Clippy lints.
2025-05-29 16:12:33 +00:00
Trevor Gross
8db9bd6a59 Remove the now-unneeded llvm-tools-preview
Since a working `nm` is no longer needed as part of CI, the rustup
component can be removed.
2025-05-29 15:38:10 +00:00
Trevor Gross
a63f4826cf Replace the nm symbol check with a Rust implementation
This should be less error-prone and adaptable than the `nm` version, and
have better cross-platform support without needing LLVM `nm` installed.
2025-05-29 15:38:10 +00:00
Trevor Gross
97c0bebdf7 Remove unneeded C symbols
These are now provided by `compiler-builtins`, so there is no need to
also build the C versions. This was detected by checking for duplicate
symbols and not excluding weak symbols (like CI currently does).
2025-05-29 15:38:10 +00:00
Trevor Gross
877feef541 Reuse libm's Caat and CastFrom in compiler-builtins 2025-05-29 03:56:08 +00:00
Trevor Gross
851aa05aa0 cleanup: Reuse MinInt and Int from libm in compiler-builtins
Since the two crates are now in the same repo, it is easier to share
code. Begin some deduplication with the integer traits.
2025-05-29 03:04:59 +00:00
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