15 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
8d70be87e6 Run cargo fmt on all projects
Apply the same formatting rules to both `libm` and `compiler-builtins`.
2025-04-19 19:05:49 -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
3167cbb6d0 Temporarily disable the test call to rust_begin_unwind
Since [1] this symbol is mangled, meaning it is not easy to call
directly. A better fix will come in [2] but for now, just disable that
portion of the test.

[1]: https://github.com/rust-lang/rust/pull/127173
[2]: https://github.com/rust-lang/compiler-builtins/pull/802
2025-03-18 23:10:02 -05:00
Trevor Gross
afa3eed6f0 Mark builtins-test-intrinsics as publish = false 2025-03-18 05:45:32 -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