Skip to content

Update subtree/library to 2025-07-11 #414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: subtree/library
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
dcb20d7
Add support for $crate to Ident
Apr 14, 2025
22e1c2a
use `is_multiple_of` to check if an addr is aligned
folkertdev Jun 14, 2025
cdb59e3
use `extern "custom"` on naked functions with a custom calling conven…
folkertdev Jun 14, 2025
6160c94
Add minimal triagebot config
Urgau Jun 14, 2025
4337073
symcheck: Add a wrapper around an archive
tgross35 Jun 14, 2025
8c27a34
Use `asm_cfg` in `probestack`
folkertdev Jun 24, 2025
e3fb598
apply suggestions for clippy::manual_is_multiple_of in libm-test
quaternic Jun 29, 2025
9deadd6
josh-sync: Replace `#xxxx`-style links in messages
tgross35 Jun 14, 2025
5eabc59
Mention as_chunks in the docs for chunks
scottmcm Jul 1, 2025
b31092d
libm: Improved integer utilities, implement shifts and bug fixes for …
quaternic Jul 1, 2025
add7b91
Use the compiler to determine whether or not to enable `f16` and `f128`
tgross35 Jun 30, 2025
2e3f8d4
Remove the `let_chains` feature now that it is stable
tgross35 Jul 4, 2025
c59dd11
symcheck: Make `target` a positional argument
tgross35 Jul 4, 2025
d358eb3
symcheck: Improve diagnostics from spawned Cargo
tgross35 Jul 4, 2025
ac86ef8
Remove unused custom target JSON files
tgross35 Jul 5, 2025
9d4437f
Test building custom targets and resolve an issue probing `rustc`
tgross35 Jul 5, 2025
6d0d2d4
Constify `Fn*` traits
oli-obk Jul 3, 2025
1edc040
Remove `const_eval_select` hack
oli-obk Jul 8, 2025
8984877
Win: Use exceptions with empty data for SEH panic exception copies
Fulgen301 Jul 8, 2025
3dfa197
docs: document trait upcasting rules in `Unsize` trait
moulins Jul 8, 2025
b51e7ec
Disable docs for `compiler-builtins` and `sysroot`
cuviper Jul 8, 2025
27b11c8
Fix VxWorks build errors
biabbas Jul 9, 2025
a53271a
Add opaque TypeId handles for CTFE
oli-obk Mar 12, 2025
93c5858
Auto merge of #143405 - tgross35:update-builtins, r=tgross35
bors Jul 9, 2025
cd8bab4
Remove uncessary parens in closure body with unused lint
chenyukang Jun 29, 2025
17be5de
Refactor nan tests
rocurley Jul 3, 2025
afb3b9d
Auto merge of #143696 - oli-obk:constable-type-id2, r=RalfJung
bors Jul 10, 2025
96843a0
Rollup merge of #141996 - Daniel-Aaron-Bloom:dollar_crate, r=petroche…
tgross35 Jul 10, 2025
ef83ed0
Rollup merge of #143265 - scottmcm:mention-as-chunks, r=ibraheemdev
tgross35 Jul 10, 2025
0514523
Rollup merge of #143396 - rocurley:float_tests_refactor, r=tgross35
tgross35 Jul 10, 2025
374cc90
Auto merge of #143721 - tgross35:rollup-sjdfp6r, r=tgross35
bors Jul 10, 2025
a2b2f71
Rollup merge of #136906 - chenyukang:yukang-fix-136741-closure-body, …
matthiaskrgr Jul 10, 2025
74d6fac
Rollup merge of #143652 - moulins:doc-unsize-trait-upcasting, r=compi…
matthiaskrgr Jul 10, 2025
9fc39ff
Rollup merge of #143668 - biabbas:vxworks, r=Noratrieb
matthiaskrgr Jul 10, 2025
3c13061
Rollup merge of #143640 - oli-obk:const-fn-traits, r=compiler-errors
matthiaskrgr Jul 10, 2025
6a67961
Rollup merge of #143651 - Fulgen301:seh-exception-ptr, r=ChrisDenton
matthiaskrgr Jul 10, 2025
1dc1e2d
Rollup merge of #143660 - cuviper:lib-doc-false, r=tgross35
matthiaskrgr Jul 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions compiler-builtins/.github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,25 @@ jobs:
run: ./ci/update-musl.sh
- run: cargo clippy --workspace --all-targets

build-custom:
name: Build custom target
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: |
rustup update nightly --no-self-update
rustup default nightly
rustup component add rust-src
- uses: Swatinem/rust-cache@v2
- run: |
# Ensure we can build with custom target.json files (these can interact
# poorly with build scripts)
cargo build -p compiler_builtins -p libm \
--target etc/thumbv7em-none-eabi-renamed.json \
-Zbuild-std=core

benchmarks:
name: Benchmarks
timeout-minutes: 20
Expand Down Expand Up @@ -331,6 +350,7 @@ jobs:
success:
needs:
- benchmarks
- build-custom
- clippy
- extensive
- miri
Expand Down
1 change: 0 additions & 1 deletion compiler-builtins/builtins-test-intrinsics/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ fn main() {
println!("cargo::rerun-if-changed=../configure.rs");

let target = builtins_configure::Target::from_env();
builtins_configure::configure_f16_f128(&target);
builtins_configure::configure_aliases(&target);
}
2 changes: 2 additions & 0 deletions compiler-builtins/builtins-test/benches/float_cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ float_bench! {
],
}

#[cfg(f128_enabled)]
float_bench! {
name: cmp_f128_gt,
sig: (a: f128, b: f128) -> CmpResult,
Expand All @@ -189,6 +190,7 @@ float_bench! {
asm: []
}

#[cfg(f128_enabled)]
float_bench! {
name: cmp_f128_unord,
sig: (a: f128, b: f128) -> CmpResult,
Expand Down
1 change: 0 additions & 1 deletion compiler-builtins/builtins-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,4 @@ fn main() {
}

builtins_configure::configure_aliases(&target);
builtins_configure::configure_f16_f128(&target);
}
4 changes: 2 additions & 2 deletions compiler-builtins/builtins-test/tests/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ mod i_to_f {
i128, __floattidf;
}

#[cfg(not(feature = "no-f16-f128"))]
#[cfg(f128_enabled)]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
i_to_f! { f128, Quad, not(feature = "no-sys-f128-int-convert"),
u32, __floatunsitf;
Expand All @@ -129,7 +129,7 @@ mod i_to_f {
i128, __floattitf;
}

#[cfg(not(feature = "no-f16-f128"))]
#[cfg(f128_enabled)]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
i_to_f! { f128, Quad, not(feature = "no-sys-f128-int-convert"),
u32, __floatunsikf;
Expand Down
4 changes: 2 additions & 2 deletions compiler-builtins/builtins-test/tests/div_rem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mod float_div {
f64, __divdf3, Double, all();
}

#[cfg(not(feature = "no-f16-f128"))]
#[cfg(f128_enabled)]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
float! {
f128, __divtf3, Quad,
Expand All @@ -156,7 +156,7 @@ mod float_div {
not(any(feature = "no-sys-f128", all(target_arch = "aarch64", target_os = "linux")));
}

#[cfg(not(feature = "no-f16-f128"))]
#[cfg(f128_enabled)]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
float! {
f128, __divkf3, Quad, not(feature = "no-sys-f128");
Expand Down
27 changes: 12 additions & 15 deletions compiler-builtins/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,26 @@ symcheck=(cargo run -p symbol-check --release)
[[ "$target" = "wasm"* ]] && symcheck+=(--features wasm)
symcheck+=(-- build-and-check)

"${symcheck[@]}" -p compiler_builtins --target "$target"
"${symcheck[@]}" -p compiler_builtins --target "$target" --release
"${symcheck[@]}" -p compiler_builtins --target "$target" --features c
"${symcheck[@]}" -p compiler_builtins --target "$target" --features c --release
"${symcheck[@]}" -p compiler_builtins --target "$target" --features no-asm
"${symcheck[@]}" -p compiler_builtins --target "$target" --features no-asm --release
"${symcheck[@]}" -p compiler_builtins --target "$target" --features no-f16-f128
"${symcheck[@]}" -p compiler_builtins --target "$target" --features no-f16-f128 --release
"${symcheck[@]}" "$target" -- -p compiler_builtins
"${symcheck[@]}" "$target" -- -p compiler_builtins --release
"${symcheck[@]}" "$target" -- -p compiler_builtins --features c
"${symcheck[@]}" "$target" -- -p compiler_builtins --features c --release
"${symcheck[@]}" "$target" -- -p compiler_builtins --features no-asm
"${symcheck[@]}" "$target" -- -p compiler_builtins --features no-asm --release
"${symcheck[@]}" "$target" -- -p compiler_builtins --features no-f16-f128
"${symcheck[@]}" "$target" -- -p compiler_builtins --features no-f16-f128 --release

run_intrinsics_test() {
args=(
--target "$target" --verbose \
--manifest-path builtins-test-intrinsics/Cargo.toml
)
args+=( "$@" )
build_args=(--verbose --manifest-path builtins-test-intrinsics/Cargo.toml)
build_args+=("$@")

# symcheck also checks the results of builtins-test-intrinsics
"${symcheck[@]}" "${args[@]}"
"${symcheck[@]}" "$target" -- "${build_args[@]}"

# FIXME: we get access violations on Windows, our entrypoint may need to
# be tweaked.
if [ "${BUILD_ONLY:-}" != "1" ] && ! [[ "$target" = *"windows"* ]]; then
cargo run "${args[@]}"
cargo run --target "$target" "${build_args[@]}"
fi
}

Expand Down
2 changes: 2 additions & 0 deletions compiler-builtins/compiler-builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ links = "compiler-rt"
bench = false
doctest = false
test = false
# make sure this crate isn't included in public standard library docs
doc = false

[dependencies]
core = { path = "../../core", optional = true }
Expand Down
3 changes: 1 addition & 2 deletions compiler-builtins/compiler-builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod configure;

use std::env;

use configure::{Target, configure_aliases, configure_f16_f128};
use configure::{Target, configure_aliases};

fn main() {
println!("cargo::rerun-if-changed=build.rs");
Expand All @@ -12,7 +12,6 @@ fn main() {
let cwd = env::current_dir().unwrap();

configure_check_cfg();
configure_f16_f128(&target);
configure_aliases(&target);

configure_libm(&target);
Expand Down
88 changes: 37 additions & 51 deletions compiler-builtins/compiler-builtins/configure.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Configuration that is shared between `compiler_builtins` and `builtins_test`.

use std::env;
use std::process::{Command, Stdio};
use std::{env, str};

#[derive(Debug)]
#[allow(dead_code)]
Expand All @@ -16,6 +17,8 @@ pub struct Target {
pub pointer_width: u8,
pub little_endian: bool,
pub features: Vec<String>,
pub reliable_f128: bool,
pub reliable_f16: bool,
}

impl Target {
Expand All @@ -32,6 +35,26 @@ impl Target {
.map(|s| s.to_lowercase().replace("_", "-"))
.collect();

// Query rustc for options that Cargo does not provide env for. The bootstrap hack is used
// to get consistent output regardless of channel (`f16`/`f128` config options are hidden
// on stable otherwise).
let mut cmd = Command::new(env::var("RUSTC").unwrap());
cmd.args(["--print=cfg", "--target", &triple])
.env("RUSTC_BOOTSTRAP", "1")
.stderr(Stdio::inherit());
let out = cmd
.output()
.unwrap_or_else(|e| panic!("failed to run `{cmd:?}`: {e}"));
let rustc_cfg = str::from_utf8(&out.stdout).unwrap();

// If we couldn't query `rustc` (e.g. a custom JSON target was used), make the safe
// choice and leave `f16` and `f128` disabled.
let rustc_output_ok = out.status.success();
let reliable_f128 =
rustc_output_ok && rustc_cfg.lines().any(|l| l == "target_has_reliable_f128");
let reliable_f16 =
rustc_output_ok && rustc_cfg.lines().any(|l| l == "target_has_reliable_f16");

Self {
triple,
triple_split,
Expand All @@ -51,6 +74,8 @@ impl Target {
.split(",")
.map(ToOwned::to_owned)
.collect(),
reliable_f128,
reliable_f16,
}
}

Expand All @@ -74,63 +99,24 @@ pub fn configure_aliases(target: &Target) {
if target.triple_split[0] == "thumbv6m" || target.triple_split[0] == "thumbv8m.base" {
println!("cargo:rustc-cfg=thumb_1")
}
}

/// Configure whether or not `f16` and `f128` support should be enabled.
pub fn configure_f16_f128(target: &Target) {
// Set whether or not `f16` and `f128` are supported at a basic level by LLVM. This only means
// that the backend will not crash when using these types and generates code that can be called
// without crashing (no infinite recursion). This does not mean that the platform doesn't have
// ABI or other bugs.
//
// We do this here rather than in `rust-lang/rust` because configuring via cargo features is
// not straightforward.
//
// Original source of this list:
// <https://github.com/rust-lang/compiler-builtins/pull/652#issuecomment-2266151350>
let f16_enabled = match target.arch.as_str() {
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
"arm64ec" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
"s390x" => false,
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
"csky" => false,
"hexagon" => false,
"powerpc" | "powerpc64" => false,
"sparc" | "sparc64" => false,
"wasm32" | "wasm64" => false,
// Most everything else works as of LLVM 19
_ => true,
};

let f128_enabled = match target.arch.as_str() {
// Unsupported (libcall is not supported) <https://github.com/llvm/llvm-project/issues/121122>
"amdgpu" => false,
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
"arm64ec" => false,
// FIXME(llvm20): fixed by <https://github.com/llvm/llvm-project/pull/117525>
"mips64" | "mips64r6" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/95471>
"nvptx64" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/101545>
"powerpc64" if &target.os == "aix" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/41838>
"sparc" => false,
// Most everything else works as of LLVM 19
_ => true,
};
/* Not all backends support `f16` and `f128` to the same level on all architectures, so we
* need to disable things if the compiler may crash. See configuration at:
* * https://github.com/rust-lang/rust/blob/c65dccabacdfd6c8a7f7439eba13422fdd89b91e/compiler/rustc_codegen_llvm/src/llvm_util.rs#L367-L432
* * https://github.com/rust-lang/rustc_codegen_gcc/blob/4b5c44b14166083eef8d71f15f5ea1f53fc976a0/src/lib.rs#L496-L507
* * https://github.com/rust-lang/rustc_codegen_cranelift/blob/c713ffab3c6e28ab4b4dd4e392330f786ea657ad/src/lib.rs#L196-L226
*/

// If the feature is set, disable these types.
let disable_both = env::var_os("CARGO_FEATURE_NO_F16_F128").is_some();
// If the feature is set, disable both of these types.
let no_f16_f128 = target.cargo_features.iter().any(|s| s == "no-f16-f128");

println!("cargo::rustc-check-cfg=cfg(f16_enabled)");
println!("cargo::rustc-check-cfg=cfg(f128_enabled)");

if f16_enabled && !disable_both {
if target.reliable_f16 && !no_f16_f128 {
println!("cargo::rustc-cfg=f16_enabled");
}

if f128_enabled && !disable_both {
println!("cargo::rustc-check-cfg=cfg(f128_enabled)");
if target.reliable_f128 && !no_f16_f128 {
println!("cargo::rustc-cfg=f128_enabled");
}
}
2 changes: 1 addition & 1 deletion compiler-builtins/compiler-builtins/src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::intrinsics;
intrinsics! {
#[unsafe(naked)]
#[cfg(all(target_os = "uefi", not(feature = "no-asm")))]
pub unsafe extern "C" fn __chkstk() {
pub unsafe extern "custom" fn __chkstk() {
core::arch::naked_asm!(
".p2align 2",
"lsl x16, x15, #4",
Expand Down
Loading