2078 Commits

Author SHA1 Message Date
The rustc-josh-sync Cronjob Bot
3f04631ce0 Merge ref '82310651b93a' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 82310651b93a594a3fd69015e1562186a080d94c
Filtered ref: e13c0be8f13737c64082b89ce834546079767ac4

This merge was created using https://github.com/rust-lang/josh-sync.
2025-07-18 19:06:49 +00:00
The rustc-josh-sync Cronjob Bot
208687e9d3 Prepare for merging from rust-lang/rust
This updates the rust-version file to 82310651b93a594a3fd69015e1562186a080d94c.
2025-07-18 19:04:50 +00:00
Julien THILLARD
6b87978169
Change the memcmp and bcmp return type to c_int
Fix the return type of `memcmp` and `bcmp` builtin functions on targets
with a `c_int` other than `i32`.

Linked issue: https://github.com/rust-lang/rust/issues/144076
2025-07-18 18:19:13 +00:00
Trevor Gross
7dacaef5d3 mem: Use core::ffi::c_int
This alias was added in 9897bfb8a ("Fix memset arguments for MSP430
target"), which predates `core::ffi`. Now that it exists we can just use
`core::ffi::c_int`.
2025-07-18 17:35:57 +00:00
Jakub Beránek
d963c78140
Update the no-merges PR title
Match the new CI-created PRs:
https://github.com/rust-lang/compiler-builtins/pull/974.
2025-07-17 10:30:52 +00:00
Trevor Gross
5157aa1a0f Allow a new lint failure in nightly
```text
warning: function `f32_to_bits` is never used
   --> libm/src/math/support/float_traits.rs:367:14
    |
367 | pub const fn f32_to_bits(x: f32) -> u32 {
    |              ^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: function `f64_to_bits` is never used
   --> libm/src/math/support/float_traits.rs:381:14
    |
381 | pub const fn f64_to_bits(x: f64) -> u64 {
    |              ^^^^^^^^^^^

warning: `libm` (lib) generated 2 warnings
```

This is a false positive, see RUST-144060.
2025-07-17 03:59:25 -05:00
Jakub Beránek
93e0074aca
Tell triagebot to reopen bot PRs to run CI on them 2025-07-12 22:41:45 +02:00
Jakub Beránek
7a1593c597
Add CI workflow for automatically performing subtree sync pulls
This CI workflow will run the https://github.com/rust-lang/josh-sync
tool on Mondays and Thursdays. It will try to do a pull (sync stdarch
changes from rust-lang/rust into this repository). When it runs, three
things can happen:
- There are no rustc changes to be pulled, the bot does nothing.
- There are some new changes to be pulled. In that case, the bot will
either open or update an existing PR titled "Rustc pull update" on this
repository with the changes. After the PR is merged, we should ideally
do the opposite sync (push) manually.
- The pull fails (usually because of a merge conflict), or the bot
determines that a pull PR has been opened for more than a week without
being merged. In that case, it will post a ping to
https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/compiler-builtins.20subtree.20sync.20automation/with/528482375.
2025-07-12 20:30:19 +00:00
Trevor Gross
f5c9403551 Upgrade iai-callgrind to 0.15
Pick up the latest version of iai-callgrind, which includes some output
improvements.

Changelog: https://github.com/iai-callgrind/iai-callgrind/releases
2025-07-10 18:47:26 -04:00
Trevor Gross
0e00ba127b Upgrade dependencies to the latest version
This picks up a fix in `rustc_apfloat` [1] that resolves a problem with
`fma`.

[1]: https://github.com/rust-lang/rustc_apfloat/releases/tag/rustc_apfloat-v0.2.3%2Bllvm-462a31f5a5ab
2025-07-10 17:50:49 -04:00
Matthias Krüger
6c4502d97d
Rollup merge of #143660 - cuviper:lib-doc-false, r=tgross35
Disable docs for `compiler-builtins` and `sysroot`

Bootstrap already had a manual doc filter for the `sysroot` crate, but
other library crates keep themselves out of the public docs by setting
`[lib] doc = false` in their manifest. This seems like a better solution
to hide `compiler-builtins` docs, and removes the `sysroot` hack too.

Fixes rust-lang/rust#143215 (after backport)
```@rustbot``` label beta-nominated
2025-07-10 20:28:50 +02:00
Jakub Beránek
f6d38909b4 Add documentation about subtree sync 2025-07-10 03:39:18 -04:00
Josh Stone
87e7539fcd Disable docs for compiler-builtins and sysroot
Bootstrap already had a manual doc filter for the `sysroot` crate, but
other library crates keep themselves out of the public docs by setting
`[lib] doc = false` in their manifest. This seems like a better solution
to hide `compiler-builtins` docs, and removes the `sysroot` hack too.
2025-07-08 16:59:44 -07:00
Jakub Beránek
f2b5199f4f Add josh-sync config file 2025-07-08 08:56:34 +02:00
Jakub Beránek
2f20628da2 Remove josh-sync crate 2025-07-08 08:56:34 +02:00
Trevor Gross
016bc61312
Test building custom targets and resolve an issue probing rustc
The `rustc` probe done in our build scripts needs to pass `--target` to
get the correct configuration, which usually comes from the `TARGET`
environment variable. However, for targets specified via a `target.json`
file, `TARGET` gets set to the file name without an extension or path.
`rustc` will check a search path to attempt to locate the file, but this
is likely to fail since the directory where Cargo invokes build scripts
(and hence where those scripts invoke `rustc`) might not have any
relation to the JSON spec file.

Resolve this for now by leaving `f16` and `f128` disabled if the `rustc`
command fails. Result of the discussion at CARGO-14208 may eventually
provide a better solution.

A CI test is also added since custom JSON files are an edge case that
could fail in other ways. I verified this fails without the fix here.
The JSON file is the output for `thumbv7em-none-eabi`, just renamed so
`rustc` doesn't identify it.
2025-07-04 21:09:56 -05:00
Trevor Gross
19ab6461fb Remove unused custom target JSON files
8521530f4938 ("Fix __divsi3 and __udivsi3 on thumbv6m targets") removed
tests that use these `thumb*-linux` target files in favor of tests that
use the `thumb*-none` targets, which are available via Rustup. The JSON
files haven't been used since then and are outdated, so remove them.
2025-07-04 19:30:31 -05:00
Trevor Gross
84060f608b symcheck: Improve diagnostics from spawned Cargo
Rather than printing the entire JSON dump, use the rendered version.
2025-07-04 18:18:31 -05:00
Trevor Gross
e164811f5d symcheck: Make target a positional argument
This makes it more obvious what we intend to check rather than looking
for `--target`.
2025-07-04 17:44:54 -05:00
Trevor Gross
6ae56f4e96 Remove the let_chains feature now that it is stable 2025-07-04 16:53:19 -05:00
Trevor Gross
be35d37d8b
Use the compiler to determine whether or not to enable f16 and f128
Currently we whether or not to build and test `f16` and `f128` support
mostly based on the target triple. This isn't always accurate, however,
since support also varies by backend and the backend version.

Since recently, `rustc` is aware of this with the unstable config option
`target_has_reliable_{f16,f128}`, which better represents when the types
are actually expected to be available and usable. Switch our
compiler-builtins and libm configuration to use this by probing `rustc`
for the target's settings.

A few small `cfg` fixes are needed with this.
2025-07-02 01:18:54 -05:00
quaternic
6c4221818e
libm: Improved integer utilities, implement shifts and bug fixes for i256 and u256
`i256` and `u256`
- operators now use the same overflow convention as primitives
- implement `<<` and `-` (previously just `>>` and `+`)
- implement `Ord` correctly (the previous `PartialOrd` was broken)
- correct `i256::SIGNED` to `true`

The `Int`-trait is extended with `trailing_zeros`, `carrying_add`, and
`borrowing_sub`.
2025-07-01 08:07:48 +00:00
Trevor Gross
a4d584e7a6 josh-sync: Replace #xxxx-style links in messages
Often our short summaries will pick up a Bors "Auto merge of #xxxx ...`
commit message. Replace these with something like `rust-lang/rust#1234`
to avoid broken links when going between repositories.
2025-06-30 09:01:21 -05:00
quaternic
76b9fbf5b2 apply suggestions for clippy::manual_is_multiple_of in libm-test 2025-06-29 05:03:12 -05:00
Folkert de Vries
962ff16101
Use asm_cfg in probestack
cc https://www.github.com/rust-lang/rust/issues/140364
2025-06-24 14:40:08 -04:00
Trevor Gross
9f4670fd2b symcheck: Add a wrapper around an archive
Rather than re-opening the archive file for each check, add a wrapper
that keeps the data in memory. Additionally, collect the `--target`
argument so it can be used within this crate.
2025-06-14 23:47:58 +00:00
Urgau
bcc96da3c3
Add minimal triagebot config
This PR adds a minimal `triagebot.toml` config to make contributions to
this repository respect upstream rust-lang/rust conventions and avoid
issues when syncing this subtree.
2025-06-14 22:43:17 +00:00
Folkert de Vries
a413cca7d3
use extern "custom" on naked functions with a custom calling convention 2025-06-14 18:17:23 +00:00
Folkert de Vries
3dc3017691 use is_multiple_of to check if an addr is aligned 2025-06-14 13:10:25 -04:00
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