`cfg(target_family = "...")` can be set multiple times, and thus
`CARGO_CFG_TARGET_FAMILY` can also contain comma-separated values,
similar to `CARGO_CFG_TARGET_FEATURE`.
This allows `cargo build --target wasm32-unknown-emscripten -p
musl-math-sys` to work, and will become more important if we were to add
e.g. `cfg(target_family = "darwin")` in the future as discussed in
https://github.com/rust-lang/rust/issues/100343.
Rustc commit 055e05a338 / builtins commit 2fb3a1871bc9 ("Mark float
intrinsics with no preconditions as safe") changed `fma` and other
intrinsics to not be unsafe to call. Unfortunately we can't remove the
`unsafe` just yet since the rustc we pin for benchmarks is older than
this.
Add back `unsafe` but allow it to be unused.
New utility in `libm::support`:
- `trait NarrowingDiv` for dividing `u2N / uN` when the quotient fits in
`uN`
- a reasonable implementation of that for primitives up to `u256 / u128`
This is the inverse operation of unsigned widening multiplication:
let xy: u256 = u128::widen_mul(x, y);
assert_eq!(xy.checked_narrowing_div_rem(y), Some((x, 0))); // unless y == 0
The trait API is based on x86's `div`-instruction: quotient overflow
happens exactly when the high half of the dividend is greater or equal
to the divisor, which includes division by zero.
Extend the <target>.optimized-compiler-builtins bootstrap option to accept a
path to a prebuilt compiler-rt builtins library, and update compiler-builtins
to enable optimized builtins without building compiler-rt builtins.
LLVM does not currently emit these, but it is being discussed as an
option on platforms where `f32` is not hardware supported. Glibc/libgcc
also has the comparison functions [1] already.
The generic implementations for addition, subtraction, and
multiplication work for f16 without any complications, as do
comparisons, so add them here.
[1]: https://sourceware.org/git/?p=glibc.git;a=commit;h=6ec6c77867af4ddfec7323e0ac6ede89effca852
Since [1], our object files may now contain a GDB script section. These
symbols wind up with multiple instances in the archive but are weak, so
we can safely ignore them in our duplicates check.
This resolves the current CI failures.
[1]: https://github.com/rust-lang/rust/pull/143679
Currently `SymInfo` stores a `Section`, which is just an index:
SymInfo {
section: Section(
SectionIndex(
539,
),
),
...
},
Look up and store the section name instead if possible, with a fallback
to the `Section` debug printing. This makes output more clear and will
allow us to filter by section name.
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`")
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.
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.
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`")
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.
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.
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)]`.
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.
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.