2104 Commits

Author SHA1 Message Date
Trevor Gross
0a1e0c65ec
Rollup merge of #144974 - tgross35:update-builtins, r=tgross35
compiler-builtins subtree update

Subtree update of `compiler-builtins` to 87a66ec969.

Created using https://github.com/rust-lang/josh-sync.

r? ``@ghost``
2025-08-07 19:36:37 -05:00
Trevor Gross
fbc700f92b configure: Use CARGO_CFG_*_{F16,F128} rather than invoking rustc
Currently we run the `rustc` from the `RUSTC` environment variable to
figure out whether or not to enable `f16` and `f128`, based on the
`target_has_reliable_{f16,f128}` config. However, this does not know
about the codegen backend used, and the backend isn't trivial to check
in a build script (usually it gets set via `RUSTFLAGS`).

It turns out we don't actually need to run `rustc` here: Cargo
unconditionally emits all config from the relevant compiler as
`CARGO_CFG_*` variables, regardless of whether or not they are known
options. Switch to checking these for setting config rather than
invoking `rustc`.

As an added advantage, this will work with target.json files without any
special handling.

Fixes: ed17b95715dd ("Use the compiler to determine whether or not to enable `f16` and `f128`")
2025-08-05 21:17:03 +00:00
Paul Murphy
3b50253b57 compiler-builtins: plumb LSE support for aarch64 on linux
Add dynamic support for aarch64 LSE atomic ops on linux targets
when optimized-compiler-builtins is not enabled.

A hook, __enable_rust_lse, is provided for the runtime to enable
them if available. A future patch will use this to enable them
if available.

The resulting asm should exactly match that of LLVM's compiler-rt
builtins, though the symbol naming for the support function and
global does not.
2025-08-05 10:30:38 -05:00
Trevor Gross
ecf6d3c6ce Simplify the configuration for no-panic
Currently, attributes for `no-panic` are gated behind both the `test`
config and `assert_no_panic`, because `no-panic` is a dev dependency (so
only available with test configuration). However, we only emit
`assert_no_panic` when the test config is also set anyway, so there
isn't any need to gate on both.

Replace gates on `all(test, assert_no_panic)` with only
`assert_no_panic`. This is simpler, and also has the benefit that
attempting to check for panics without `--test` errors.
2025-07-30 10:02:34 -05:00
Trevor Gross
3cbd088ee4 ci: Set pipefail before running ci-util
Currently, a failure in `ci-util.py` does not cause the job to fail
because the pipe eats the failure status . Set pipefail to fix this.

Fixes: ff2cc0e38e3e ("ci: Don't print output twice in `ci-util`")
2025-07-30 09:57:45 -05:00
Trevor Gross
4ebfdf74db ci: Add a way to run libm tests that would otherwise be skipped
Introduce a new directive `ci: test-libm` to ensure tests run.
2025-07-30 08:59:57 +00:00
Trevor Gross
c045c9b1ca ci: Commonize the way PrInfo is loaded from env 2025-07-30 08:59:57 +00:00
Trevor Gross
eafafc44ab ci: Don't print output twice in ci-util
Use `tee` rather than printing to both stdout and stderr.
2025-07-30 08:59:57 +00:00
Trevor Gross
ab8a2e1cb2 ci: Switch to strongly typed directives
Replace the current system with something that is more structured and
will also catch unknown directives.
2025-07-30 08:59:55 +00:00
Trevor Gross
97c35d3aed ci: Simplify tests for verbatim paths
Rather than setting an environment variable in the workflow job based on
whether or not the environment is non-MinGW Windows, we can just check
this in the ci script.

This was originally added in b0f19660f0 ("Add tests for UNC paths on
windows builds") and its followup commits.
2025-07-29 19:07:55 +00:00
Trevor Gross
54a4f867f8 cleanup: Trim trailing whitespace 2025-07-29 18:56:46 +00:00
Jakub Beránek
54f6ab73b1
Switch to using a GH app for authenticating sync PRs
So there will no longer be the need to close and reopen sync PRs in
order for CI to run.
2025-07-29 08:20:22 +00:00
Trevor Gross
16cb37c957 Remove no-asm gating when there is no alternative implementation
Assembly-related configuration was added in 1621c6dbf9eb ("Use
`specialized-div-rem` 1.0.0 for division algorithms") to account for
Cranelift not yet supporting assembly. This hasn't been relevant for a
while, so we no longer need to gate `asm!` behind this configuration.
Thus, remove `cfg(not(feature = "no-asm"))` in places where there is no
generic fallback.

There are other cases, however, where setting the `no-asm` configuration
enables testing of generic version of builtins when there are platform-
specific implementations available; these cases are left unchanged. This
could be improved in the future by exposing both versions for testing
rather than using a configuration and running the entire testsuite
twice.

This is the compiler-builtins portion of
https://github.com/rust-lang/rust/pull/144471.
2025-07-27 16:39:31 -05:00
Folkert de Vries
9c683d3487
Implement floor and ceil in assembly on i586
Fixes: https://github.com/rust-lang/compiler-builtins/issues/837

The assembly is based on

- 2043392793/lib/libm/arch/i387/s_floor.S
- 2043392793/lib/libm/arch/i387/s_ceil.S

Which both state

    /*
     * Written by J.T. Conklin <jtc@NetBSD.org>.
     * Public domain.
     */

Which I believe means we're good in terms of licensing.
2025-07-27 17:27:40 -04:00
quaternic
c061e73d9f
Avoid inlining floor into rem_pio2
Possible workaround for
https://github.com/rust-lang/compiler-builtins/pull/976#issuecomment-3085530354

Inline assembly in the body of a function currently causes the compiler
to consider that function possibly unwinding, even if said asm
originated from inlining an `extern "C"` function. This patch wraps the
problematic callsite with `#[inline(never)]`.
2025-07-27 00:26:58 -05:00
Trevor Gross
474315828b libm: Update for new warn-by-default clippy lints
Silence the approximate constant lint because it is noisy and not always
correct. `single_component_path_imports` is also not accurate when built
as part of `compiler-builtins`, so that needs to be `allow`ed as well.
2025-07-26 20:21:35 -05:00
Trevor Gross
9dad77f337 Use x86_no_sse configuration in more places
Emit `x86_no_sse` in the compiler-builtins (and builtins-test) build
script, and use it to simplify `all(target_arch = "x86",
not(target_fefature = "sse))` configuration.
2025-07-24 19:37:45 +00:00
Trevor Gross
0b6c1d3861 Enable skipped f32 and f64 multiplication tests
The fix has since made it to nightly, so the skips here can be removed.
2025-07-24 18:49:50 +00:00
Trevor Gross
b168793046 Enable tests that were skipped on aarch64
The LLVM issue was resolved a while ago, these should no longer be a
problem.
2025-07-24 18:49:50 +00:00
Trevor Gross
43c3e1bb97 Enable tests that were skipped on PowerPC
Most of these were skipped because of a bug with the platform
implementation, or some kind of crash unwinding. Since the upgrade to
Ubuntu 25.04, these all seem to be resolved with the exception of a bug
in the host `__floatundisf` [1].

[1] https://github.com/rust-lang/compiler-builtins/pull/384#issuecomment-740413334
2025-07-24 07:18:08 -05:00
Trevor Gross
5c4abe9ca0 ci: Upgrade ubuntu:25.04 for the PowerPC64LE test
Update the last remaining image.

For this to work, the `QEMU_CPU=POWER8` configuration needed to be
dropped to avoid a new SIGILL. Doing some debugging locally, the crash
comes from an `extswsli` (per `powerpc:common64` in gdb-multiarch) in
the `ld64.so` available with PowerPC, which qemu rejects when set to
power8. Testing a build with `+crt-static` hits the same issue at a
`maddld` in `__libc_start_main_impl`.

Rust isn't needed to reproduce this:

    $ cat a.c
    #include <stdio.h>

    int main() {
            printf("Hello, world!\n");
    }
    $ powerpc64le-linux-gnu-gcc a.c
    $ QEMU_CPU=power8 QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu/ ./a.out
    qemu: uncaught target signal 4 (Illegal instruction) - core dumped
    Illegal instruction

So the cross toolchain provided by Debian must have a power9 baseline
rather than rustc's power8. Alternatively, qemu may be incorrectly
rejecting these instructions (I can't find a source on whether or not
they should be available for power8). Testing instead with the `-musl`
toolchain and ppc linker from musl.cc works correctly.

In any case, things work with the default qemu config so it seems fine
to drop. The env was originally added in 5d164a4edafb ("fix the
powerpc64le target") but whatever the problem was there appears to no
longer be relevant.
2025-07-24 05:52:58 -05:00
Trevor Gross
83aea652e4 ci: Use a mirror for musl
We pretty often get at least one job failed because of failure to pull
the musl git repo. Switch this to the unofficial mirror [1] which should
be more reliable.

Link: https://github.com/kraj/musl [1]
2025-07-24 04:06:56 -05:00
Trevor Gross
95c42630eb symcheck: Switch the object dependency from git to crates.io
Wasm support has since been released, so we no longer need to depend on
a git version of `object`.
2025-07-24 03:29:05 -05:00
Trevor Gross
fcc7824b88 ci: Update to the latest ubuntu:25.04 Docker images
This includes a qemu update from 8.2.2 to 9.2.1 which should hopefully
fix some bugs we have encountered.

PowerPC64LE is skipped for now because the new version seems to cause a
number of new SIGILLs.
2025-07-24 01:42:53 -05:00
Trevor Gross
08bca4d6a2
ci: Add native PowerPC64LE and s390x jobs
We now have access to native runners, so make use of them for these
architectures. The existing ppc64le Docker job is kept for now.
2025-07-23 04:50:41 -05:00
Trevor Gross
ed50029b92 ci: Switch to nightly rustfmt
We are getting warnings in CI about unsupported features. There isn't
any reason to use stable rustfmt so switch the channel here.
2025-07-21 12:18:45 -05:00
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