Commit Graph

112 Commits

Author SHA1 Message Date
Trevor Gross
7d3ee7a588 ci: Build MPFR on all native CI targets
Currently this is the ppc64le and s390x IBM runners, as well as the
ppc64-musl self-hosted runner.
2026-10-08 12:35:38 -05:00
Trevor Gross
91480ccf44 ci: Do a quick check for system runtime performance
This gives a very rough idea of what is reasonable for test volume on
each arch, and hints if a job happens to pick up a slow runner. We don't
really need this to run each time but we have been adding and removing
runners with some frequency recently, and it only takes about five
seconds to build and run.

Results from CI:

| Target                              | Environment      | Single-core score | Multi-core score  |
|-------------------------------------|------------------|-------------------|-------------------|
| aarch64-apple-darwin                | Native           | 490               | 1371              |
| aarch64-pc-windows-msvc             | Native           | 492               | 1819              |
| aarch64-unknown-linux-gnu           | Native           | 627               | 2318              |
| arm-unknown-linux-gnueabi           | QEMU (Docker)    | 19                | 72                |
| arm-unknown-linux-gnueabihf         | QEMU (Docker)    | 37                | 136               |
| armv7-unknown-linux-gnueabihf       | Native           | 278               | 2026              |
| armv7-unknown-linux-gnueabihf       | QEMU (Docker)    | 37                | 137               |
| i586-unknown-linux-gnu              | Native (Docker)  | 248               | 916               |
| i686-pc-windows-gnu                 | Native           | 321               | 1188              |
| i686-pc-windows-msvc                | Native           | 541               | 2002              |
| i686-unknown-linux-gnu              | Native (Docker)  | 323               | 1193              |
| loongarch64-unknown-linux-gnu       | QEMU (Docker)    | 86                | 320               |
| powerpc-unknown-linux-gnu           | QEMU (Docker)    | 23                | 86                |
| powerpc64-unknown-linux-gnu         | QEMU (Docker)    | 44                | 164               |
| powerpc64-unknown-linux-musl        | Native           | 215               | 7770              |
| powerpc64le-unknown-linux-gnu       | Native           | 107               | 397               |
| powerpc64le-unknown-linux-gnu       | QEMU (Docker)    | 42                | 157               |
| riscv64gc-unknown-linux-gnu         | QEMU (Docker)    | 100               | 371               |
| s390x-unknown-linux-gnu             | Native           | 243               | 899               |
| thumbv7neon-unknown-linux-gnueabihf | QEMU (Docker)    | 50                | 186               |
| x86_64-apple-darwin                 | Native           | 192               | 711               |
| x86_64-pc-windows-gnu,              | Native           | 456               | 1689              |
| x86_64-pc-windows-msvc              | Native           | 462               | 1709              |
| x86_64-unknown-linux-gnu            | Native (Docker)  | 457               | 1689              |
2026-10-08 11:37:17 -05:00
Trevor Gross
eead13d540 ci: Update which targets build musl
Provide reasoning for skips, and enable thumb since this seems to work.
Also, change wasm32-unknown-unknown to be a proper build-only target.

The mentioned failures on MinGW are cases like:

    thread 'musl_edge_case_expf' (1728) panicked at libm-test\tests\compare_built_musl.rs:26:50:
    called `Result::unwrap()` on an `Err` value:
      input:    (0.0,)
      as hex:   (+0x0p+0,)
      as bits:  (0x00000000,)
      expected: 0.0                 +0x0p+0   0x00000000
      actual:   1.0                 +0x1.000000p+0   0x3f800000

    thread 'musl_edge_case_ceil' (1964) panicked at libm-test\tests\compare_built_musl.rs:26:50:
    called `Result::unwrap()` on an `Err` value:
      input:    (1.0000000000000002,)
      as hex:   (+0x1.0000000000001p+0,)
      as bits:  (0x3ff0000000000001,)
      expected: 1.0                 +0x1.0000000000000p+0   0x3ff0000000000000
      actual:   2.0                 +0x1.0000000000000p+1   0x4000000000000000

Our libm's results are correct, for some reason musl is off (something
about the fp environment on x86, or a different FLT_EVAL_MODE?)
2026-09-03 01:15:09 -05:00
Trevor Gross
90c7ab4912 ci: Group output into sections 2026-08-18 03:35:13 -05:00
Trevor Gross
06a01635de ci: Don't test with --benches in debug mode
Benchmarks are designed to run in release mode so these can be pretty
slow. Running once with `release-checked` is sufficient.
2026-08-18 02:36:58 -05:00
Trevor Gross
8c60f10165 ci: Re-enable the musl build on ppc64le
This may have been a qemu bug or something with `QEMU_CPU`, but appears
resolved now. More context at [1].

[1]: https://github.com/rust-lang/compiler-builtins/pull/1096
2026-08-12 16:38:20 -04:00
Trevor Gross
d83d00db62 ci: Print the version of cc 2026-08-12 15:34:22 -04:00
Trevor Gross
dfc678553d symcheck: Make the crate actually called symcheck
I've always referred to the crate as `symcheck` rather than
`symbol-check`; make this its actual name.
2026-08-07 10:01:55 -04:00
Trevor Gross
d9b79b2802 ci: Print rustc version with machine info 2026-08-07 05:28:25 -04:00
Trevor Gross
b2877ac70d ci: Exclude update-api-list from libm tests 2026-04-16 05:24:29 -04:00
Trevor Gross
3af9faa6cd test: Move tidy_lists from update-api-list.py to a new crate
This is the first step of migrating `update-api-list.py` to something
that handles the compiler-builtins functions.
2026-04-10 06:30:25 -04:00
Trevor Gross
dee26f70d1 libm: Deprecate feature = "force-soft-float"
This was needed while some codegen backends did not support inline
assembly, or ran into circular issues using vector intrinsics. All such
issues have since been resolved with the in-tree backends. The remaining
need was to be able to toggle these features in tests, which we can do
via the enabled-by-default `arch` feature. Since there aren't any cases
requiring `force-soft-float`, remove its functionality and deprecate it.

It is possible that future codegen backends may have a similar need to
disable inline assembly until pairity with the LLVM backend can be
reached. In these cases rather than having `force-soft-float`, it would
be better to have rustc provide a `cfg(target_supports_inline_asm)`.
`build.rs` can then do something like:

    let nightly = cfg!(feature = "compiler-builtins") || cfg!(feature = "unstable");
    let asm_support = env::var("CARGO_CFG_TARGET_SUPPORTS_INLINE_ASM").is_ok();
    let arch_enabled = cfg!(feature = "arch") && (!nightly || (nightly && asm_support));
    set_cfg("arch_enabled", arch_enabled);

This is about what we have now with `cfg(target_has_reliable_f16)` and
`cfg(target_has_reliable_f128)` being set by rustc, which is
significantly easier to use than the `feature = "no-f16-f128"` that it
replaced. Having rustc directly tell us what it supports means we don't
need to bubble subtractive options up to bootstrap via a chain of Cargo
features that aren't really meant to support disabling things.

I'm sketching this out for future reference since it seems likely that
the need comes back up eventually.
2026-04-01 19:45:21 -04:00
Trevor Gross
6b97e039e4 c-b: Replace the no-asm feature with an opposite-polarity arch
Make `libm` and `compiler-builtins` use the same configuration:

* By default there is an `arch` feature which allows `core::arch` and
  inline assembly.
* Disabling the `arch` feature turns these off.

Positive feature flags are easier to reason about than negative, so this
will allow for some build script cleanup as well.
2026-04-01 09:49:04 -04:00
Trevor Gross
03e408b22b ci: Explicitly set the compiler-builtins feature for symcheck
Since this is no longer a default feature, we need to enable it to avoid
getting errors about symbols from `core`.
2026-03-31 17:02:03 -04:00
Trevor Gross
419cad6d7e ci: Also use nextest to run compiler-builtins tests
Currently nextest is always installed but only used for libm. Enable it
for compiler-builtins too to help speed up CI.
2026-03-30 08:53:29 -04:00
Bo YU
90bb1f20b8 ci: use CARGO_TARGET_DIR instead of .dockerenv for nextest config
The .dockerenv check was a workaround for Docker CI where the
checkout is mounted read-only. However, its presence does not reliably
indicate that the filesystem is unwritable.

Use CARGO_TARGET_DIR as the condition instead, which directly
captures when a custom writable target directory is in use and avoids
false assumptions.
2026-03-24 13:49:26 -04:00
Trevor Gross
15d02fc0d7 symcheck: Check for binaries requiring a writeable + executable stack
Implement the following logic:

* For elf executable binaries, check for PT_GNU_STACK with PF_X. This
  combination tells the kernel to make the stack executable.
* For elf intermediate objects, check for `.note.GNU-stack` with
  SHF_EXECINSTR. This combination in an object file tells the linker to
  give the final binary PT_GNU_STACK PF_X.
* For elf intermediate objects with no `.note.GNU-stack`, assume the
  legacy behavior that assumes an executable stack is required.
* For non-elf binaries, don't check anything. In a follow up it may be
  possible to check for `MH_ALLOW_STACK_EXECUTION` on Mach-O binaries,
  but it doesn't seem possible to get the latest compiler to emit this.

This appears to match what is done by `scanelf` to emit `!WX` [1], which
seems to be the tool used to create the output in the issue. The ld
manpage [2] also has some useful notes about these flags, as does the
presentation at [3].

Closes: https://github.com/rust-lang/compiler-builtins/issues/183

[1]: 9ef54b472e/scanelf.c
[2]: https://man7.org/linux/man-pages/man1/ld.1.html
[3]: https://www.ndss-symposium.org/wp-content/uploads/6D-s0924-ye.pdf
2026-02-11 14:45:47 -06:00
Trevor Gross
0d2a5d24d3 symcheck: Switch to getopts for argument parsing
It would be nice to support a few more flags here, but the current
implementation is a bit limited. Switch to `getopts` which should make
things a bit easier in the future.
2026-02-10 00:56:43 -06:00
Trevor Gross
9184a5f661 symcheck: Add tests for the symbol checker
Ensure that these are actually doing what is expected.
2026-02-07 05:27:30 -06:00
Trevor Gross
6733cf42a6 symcheck: Enable wasm by default
The build time isn't very different so we can keep things simpler.
2026-02-07 05:27:30 -06:00
Trevor Gross
4d24b508bb meta: Upgrade all dependencies to the latest compatible versions
This allows us to drop wasm-specific configuration for `getrandom`.

Link: 314fd5ab3e/CHANGELOG.md (major-change-to-wasm_js-backend)
2026-02-07 05:13:21 -06:00
Trevor Gross
c7c5adbe64 compiler-builtins: Remove the no-f16-f128 feature
This option was used to gate `f16` and `f128` when support across
backends and targets was inconsistent. We now have the rustc builtin cfg
`target_has_reliable{f16,f128}` which has taken over this usecase.
Remove no-f16-f128 since it is now unused and redundant.
2026-01-11 07:02:27 -06: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
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
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
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
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
Trevor Gross
a829d916b5 ci: Add /cargo/bin to the path in Docker
This makes it possible to use nextest within the container.
2025-04-20 04:11:53 -04:00
Trevor Gross
9c96f245b8 ci: Enable testing of libm crates
Update `run.sh` to start testing `libm`. Currently this is somewhat
inefficient because `builtins-test` gets run more than once on some
targets; this can be cleaned up later.
2025-04-20 03:22:27 -04:00
Trevor Gross
141c7b06c4 Add remaining libm crates to the workspace
These are still not yet covered in CI since we always name explicit
packages there, but all crates are now part of the workspace.
2025-04-19 23:20:13 -04:00
Trevor Gross
a48de6950c Move builtins-test-intrinsics out of the workspace
This crate doesn't need to be a default member since it requires the
opposite settings from everything else. Exclude it from the workspace
and run it only when explicitly requested.

This also makes `cargo t --no-default-features` work without additional
qualifiers. `--no-default-features` still needs to be passed to ensure
`#![compiler_builtins]` does not get set.

compiler-builtins needs doctests disabled in order for everything to
work correctly, since this causes an error running rustdoc that is
unrelated to features (our `compiler_builtins` is getting into the crate
graph before that from the sysroot, but `#![compiler_builtins]` is not
set).

We can also remove `test = false` and `doctest = false` in
`builtins-test` since these no longer cause issues. This is unlikely to
be used but it is better to not quietly skip if anything ever gets added
by accident.
2025-04-19 22:30:58 -04:00
Trevor Gross
01c5888246 ci: Make CI configuration more similar to libm
Apply a handful of changes to reduce the diff between the two:

* Cancel running jobs on new pushes
* Enable log color and backtraces
* Add timeouts
* Specify CI runner versions
* Add an armv7 job
* Replace the name NO_STD with BUILD_ONLY
* Update the extension to the canonical .yaml
* Set AR_ and CC_ environments in docker
* Install requirements to build MPFR
2025-04-18 23:49:29 -04:00
Trevor Gross
92b1e8454d Rename testcrate to builtins-test
The repo will soon have `libm` as a top-level crate, so make it clear
that this is only the test crate for `compiler-builtins`.
2025-04-18 21:14:41 -04:00
Trevor Gross
683485cda2 Switch repository layout to use a virtual manifest
The current setup has the `Cargo.toml` for `compiler-builtins` at the
repository root, which means all support crates and other files are
located within the package root. This works for now but is not the
cleanest setup since files that should or shouldn't be included in the
package need to be configured in `Cargo.toml`. If we eventually merge
`libm` development into this repository, it would be nice to make this
separation more straightforward.

Begin cleaning things up by moving the crate source to a new
`compiler-builtins` directory and adding a virtual manifest. For now the
`libm` submodule is also moved, but in the future it can likely move
back to the top level (ideally `compiler-builtins/src` would contain a
symlink to `libm/src/math`, but unfortunately it seems like Cargo does
not like something about the submodule + symlink combination).
2025-03-19 00:49:34 -05:00
Trevor Gross
a179959e0b Move examples/intrinsics.rs to its own crate
Currently there is an interesting situation with the way features get
enabled; `testcrate` enables `mangled-names`, but the `intrinsics.rs`
example requires this feature be disabled (otherwise the test fails with
missing symbols, as expected). This is also the reason that `testcrate`
is not a default workspace member, meaning `cargo test` doesn't actually
run `testcrate`'s tests; making it a default member would mean that
`compiler-builtins/mangled-names` gets enabled when
`examples/intrinsics.rs` gets built, due to the way features get
unified.

Simplify the situation by making moving the example to its own crate as
`builtins-test-intrinsics`. This also means `testcrate` can become a
default member so it is included in `cargo check` or `cargo test` when
run at the workspace root.

`testcrate` and `builtins-test-intrinsics` still can't be built at the
same time since there isn't a straightforward way to have Cargo build
`compiler-builtins` twice with different features. This is a side effect
of us using non-additive features, but there isn't really a better
option since enabling both mangled and unmangled names would render
`builtins-test-intrinsics` useless.
2025-03-18 05:35:19 -05:00
Trevor Gross
85cd4c0660 Fix some warnings from shellcheck 2024-09-28 21:24:44 -04:00
Trevor Gross
6cd17ff4d2 Add benchmarks for floating point math
This adds comparisons among the compiler-builtins function, system
functions if available, and optionally handwritten assembly.

These also help us identify inconsistencies between this crate and
system functions, which may otherwise go unnoticed if intrinsics get
lowered to inline operations rather than library calls.
2024-05-24 02:49:41 -04:00
Henry Wang
7d60c93165 Only run --features c for verbatim test 2024-05-21 01:09:47 +02:00
theKidOfArcrania
416be726df verbatim tests only need to build 2024-05-21 01:09:47 +02:00
theKidOfArcrania
fd290b1339 Properly escape /C and fix naming 2024-05-21 01:09:47 +02:00
theKidOfArcrania
e3d86a8350 Instead have cmd.exe dump out path 2024-05-21 01:09:47 +02:00
theKidOfArcrania
0000f98d73 Fix backslash 2024-05-21 01:09:47 +02:00
theKidOfArcrania
e246ba5a46 Use cmd.exe 2024-05-21 01:09:47 +02:00
theKidOfArcrania
24cb0c2bcc Fix CI 2024-05-21 01:09:47 +02:00
theKidOfArcrania
3fdef93258 Add tests for UNC paths on windows builds 2024-05-21 01:09:47 +02:00
Trevor Gross
4509315d2f Enable no-fail-fast for more usable test output 2024-05-15 07:19:17 -05:00
beetrees
229babb1d0 Add builtins for f16/f128 float conversions 2024-05-02 13:49:24 +02:00
Trevor Gross
1b679e5cee Apply some more fixes suggested by Shellcheck 2024-04-19 11:49:23 -04:00
Trevor Gross
a55604fd8c Add a way to run tests on non-linux machines
Allow using the `rust-lang/rust:nightly` docker image to run tests in
cases where the host rust and cargo cannot be used, such as non-linux
hosts.
2024-04-19 11:49:23 -04:00