Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-shim/Cargo.toml +68 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-test-intrinsics/Cargo.toml +19 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-test-intrinsics/build.rs +10 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-test/Cargo.toml +96 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-test/build.rs +119 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/bench-icount.sh +79 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/bench-runtime.sh +9 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/ci-util.py +464 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/download-compiler-rt.sh +10 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/install-bench-deps.sh +11 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/miri.sh +18 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/run-docker.sh +111 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/run-extensive.sh +24 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/run.sh +213 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/update-musl.sh +15 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/CHANGELOG.md +183 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/Cargo.toml +63 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/README.md +446 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/build.rs +679 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/configure.rs +107 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/Cargo.toml +22 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/src/enums.rs +171 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/src/lib.rs +502 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/src/parse.rs +296 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/src/shared.rs +590 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/Cargo.toml +12 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/build.rs +353 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/c_patches/alias.c +40 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/c_patches/features.h +39 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/src/lib.rs +285 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/panic-handler/Cargo.toml +11 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/panic-handler/src/lib.rs +8 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/Cargo.toml +15 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/build.rs +6 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/src/main.rs +364 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/tests/all.rs +126 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/tests/input/core_symbols.rs +11 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/tests/input/duplicates.rs +12 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/tests/input/good.rs +4 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/util/Cargo.toml +19 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/util/build.rs +10 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/util/src/main.rs +350 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/function-definitions.json +1071 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/function-list.txt +164 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/thumbv6-none-eabi.json +20 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/thumbv7em-none-eabi-renamed.json +23 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/update-api-list.py +361 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/libm-test/Cargo.toml +74 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/libm-test/benches/icount.rs +415 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/libm-test/benches/random.rs +179 -0
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-shim/Cargo.toml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NOTE: Must be kept in sync with `../compiler-builtins/Cargo.toml`.
|
| 2 |
+
#
|
| 3 |
+
# The manifest at `../compiler-builtins` is what actually gets used in the
|
| 4 |
+
# rust-lang/rust tree; however, we can't build it out of tree because it
|
| 5 |
+
# depends on `core` by path, and even optional Cargo dependencies need to be
|
| 6 |
+
# available at build time. So, we work around this by having this "shim"
|
| 7 |
+
# manifest that is identical except for the `core` dependency and forwards
|
| 8 |
+
# to the same sources, which acts as the `compiler-builtins` Cargo entrypoint
|
| 9 |
+
# for out of tree testing
|
| 10 |
+
#
|
| 11 |
+
# Ideally we can eventually replace this with a patch in the workspace
|
| 12 |
+
# manifest <https://github.com/rust-lang/cargo/issues/4648>.
|
| 13 |
+
|
| 14 |
+
[package]
|
| 15 |
+
name = "compiler_builtins"
|
| 16 |
+
version = "0.1.160"
|
| 17 |
+
authors = [
|
| 18 |
+
"Alex Crichton <alex@alexcrichton.com>",
|
| 19 |
+
"Amanieu d'Antras <amanieu@gmail.com>",
|
| 20 |
+
"Jorge Aparicio <japaricious@gmail.com>",
|
| 21 |
+
"Trevor Gross <tg@trevorgross.com>",
|
| 22 |
+
]
|
| 23 |
+
description = "Compiler intrinsics used by the Rust compiler."
|
| 24 |
+
repository = "https://github.com/rust-lang/compiler-builtins"
|
| 25 |
+
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
|
| 26 |
+
edition = "2024"
|
| 27 |
+
publish = false
|
| 28 |
+
links = "compiler-rt"
|
| 29 |
+
|
| 30 |
+
build = "../compiler-builtins/build.rs"
|
| 31 |
+
|
| 32 |
+
[lib]
|
| 33 |
+
path = "../compiler-builtins/src/lib.rs"
|
| 34 |
+
bench = false
|
| 35 |
+
doctest = false
|
| 36 |
+
test = false
|
| 37 |
+
|
| 38 |
+
[build-dependencies]
|
| 39 |
+
cc = { version = "1.2", optional = true }
|
| 40 |
+
|
| 41 |
+
[features]
|
| 42 |
+
default = ["compiler-builtins"]
|
| 43 |
+
|
| 44 |
+
# Enable compilation of C code in compiler-rt, filling in some more optimized
|
| 45 |
+
# implementations and also filling in unimplemented intrinsics
|
| 46 |
+
c = ["dep:cc"]
|
| 47 |
+
|
| 48 |
+
# For implementations where there is both a generic version and a platform-
|
| 49 |
+
# specific version, use the generic version. This is meant to enable testing
|
| 50 |
+
# the generic versions on all platforms.
|
| 51 |
+
no-asm = []
|
| 52 |
+
|
| 53 |
+
# Flag this library as the unstable compiler-builtins lib
|
| 54 |
+
compiler-builtins = []
|
| 55 |
+
|
| 56 |
+
# Generate memory-related intrinsics like memcpy
|
| 57 |
+
mem = []
|
| 58 |
+
|
| 59 |
+
# Mangle all names so this can be linked in with other versions or other
|
| 60 |
+
# compiler-rt implementations. Also used for testing
|
| 61 |
+
mangled-names = []
|
| 62 |
+
|
| 63 |
+
# Only used in the compiler's build system
|
| 64 |
+
rustc-dep-of-std = ["compiler-builtins"]
|
| 65 |
+
|
| 66 |
+
# This makes certain traits and function specializations public that
|
| 67 |
+
# are not normally public but are required by the `builtins-test`
|
| 68 |
+
unstable-public-internals = []
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-test-intrinsics/Cargo.toml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "builtins-test-intrinsics"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
publish = false
|
| 6 |
+
license = "MIT OR Apache-2.0"
|
| 7 |
+
|
| 8 |
+
[dependencies]
|
| 9 |
+
compiler_builtins = { path = "../builtins-shim", features = ["compiler-builtins"] }
|
| 10 |
+
panic-handler = { path = "../crates/panic-handler" }
|
| 11 |
+
|
| 12 |
+
[features]
|
| 13 |
+
c = ["compiler_builtins/c"]
|
| 14 |
+
|
| 15 |
+
[profile.release]
|
| 16 |
+
panic = "abort"
|
| 17 |
+
|
| 18 |
+
[profile.dev]
|
| 19 |
+
panic = "abort"
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-test-intrinsics/build.rs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mod builtins_configure {
|
| 2 |
+
include!("../compiler-builtins/configure.rs");
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
fn main() {
|
| 6 |
+
println!("cargo::rerun-if-changed=../configure.rs");
|
| 7 |
+
|
| 8 |
+
let target = builtins_configure::Target::from_env();
|
| 9 |
+
builtins_configure::configure_aliases(&target);
|
| 10 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-test/Cargo.toml
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "builtins-test"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
publish = false
|
| 6 |
+
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
|
| 7 |
+
|
| 8 |
+
[dependencies]
|
| 9 |
+
compiler_builtins = { workspace = true, features = ["unstable-public-internals"] }
|
| 10 |
+
|
| 11 |
+
# For fuzzing tests we want a deterministic seedable RNG. We also eliminate potential
|
| 12 |
+
# problems with system RNGs on the variety of platforms this crate is tested on.
|
| 13 |
+
# `xoshiro128**` is used for its quality, size, and speed at generating `u32` shift amounts.
|
| 14 |
+
rand_xoshiro.workspace = true
|
| 15 |
+
|
| 16 |
+
# To compare float builtins against
|
| 17 |
+
rustc_apfloat.workspace = true
|
| 18 |
+
|
| 19 |
+
# Really a dev dependency, but dev dependencies can't be optional
|
| 20 |
+
gungraun = { workspace = true, optional = true }
|
| 21 |
+
|
| 22 |
+
[dev-dependencies]
|
| 23 |
+
criterion.workspace = true
|
| 24 |
+
paste.workspace = true
|
| 25 |
+
|
| 26 |
+
[target.'cfg(all(target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux"))'.dev-dependencies]
|
| 27 |
+
test = { git = "https://github.com/japaric/utest" }
|
| 28 |
+
utest-cortex-m-qemu = { default-features = false, git = "https://github.com/japaric/utest" }
|
| 29 |
+
utest-macros = { git = "https://github.com/japaric/utest" }
|
| 30 |
+
|
| 31 |
+
[features]
|
| 32 |
+
default = ["mangled-names"]
|
| 33 |
+
c = ["compiler_builtins/c"]
|
| 34 |
+
no-asm = ["compiler_builtins/no-asm"]
|
| 35 |
+
mem = ["compiler_builtins/mem"]
|
| 36 |
+
mangled-names = ["compiler_builtins/mangled-names"]
|
| 37 |
+
# Skip tests that rely on f128 symbols being available on the system
|
| 38 |
+
no-sys-f128 = ["no-sys-f128-int-convert", "no-sys-f16-f128-convert"]
|
| 39 |
+
# Some platforms have some f128 functions but everything except integer conversions
|
| 40 |
+
no-sys-f128-int-convert = []
|
| 41 |
+
no-sys-f16-f128-convert = []
|
| 42 |
+
no-sys-f16-f64-convert = []
|
| 43 |
+
# Skip tests that rely on f16 symbols being available on the system
|
| 44 |
+
no-sys-f16 = ["no-sys-f16-f64-convert"]
|
| 45 |
+
|
| 46 |
+
# Enable icount benchmarks (requires gungraun-runner and valgrind locally)
|
| 47 |
+
icount = ["dep:gungraun"]
|
| 48 |
+
|
| 49 |
+
# Enable report generation without bringing in more dependencies by default
|
| 50 |
+
benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]
|
| 51 |
+
|
| 52 |
+
# NOTE: benchmarks must be run with `--no-default-features` or with
|
| 53 |
+
# `-p builtins-test`, otherwise the default `compiler-builtins` feature
|
| 54 |
+
# of the `compiler_builtins` crate gets activated, resulting in linker
|
| 55 |
+
# errors.
|
| 56 |
+
|
| 57 |
+
[[bench]]
|
| 58 |
+
name = "float_add"
|
| 59 |
+
harness = false
|
| 60 |
+
|
| 61 |
+
[[bench]]
|
| 62 |
+
name = "float_sub"
|
| 63 |
+
harness = false
|
| 64 |
+
|
| 65 |
+
[[bench]]
|
| 66 |
+
name = "float_mul"
|
| 67 |
+
harness = false
|
| 68 |
+
|
| 69 |
+
[[bench]]
|
| 70 |
+
name = "float_div"
|
| 71 |
+
harness = false
|
| 72 |
+
|
| 73 |
+
[[bench]]
|
| 74 |
+
name = "float_cmp"
|
| 75 |
+
harness = false
|
| 76 |
+
|
| 77 |
+
[[bench]]
|
| 78 |
+
name = "float_conv"
|
| 79 |
+
harness = false
|
| 80 |
+
|
| 81 |
+
[[bench]]
|
| 82 |
+
name = "float_extend"
|
| 83 |
+
harness = false
|
| 84 |
+
|
| 85 |
+
[[bench]]
|
| 86 |
+
name = "float_trunc"
|
| 87 |
+
harness = false
|
| 88 |
+
|
| 89 |
+
[[bench]]
|
| 90 |
+
name = "float_pow"
|
| 91 |
+
harness = false
|
| 92 |
+
|
| 93 |
+
[[bench]]
|
| 94 |
+
name = "mem_icount"
|
| 95 |
+
harness = false
|
| 96 |
+
required-features = ["icount"]
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/builtins-test/build.rs
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use std::collections::HashSet;
|
| 2 |
+
|
| 3 |
+
mod builtins_configure {
|
| 4 |
+
include!("../compiler-builtins/configure.rs");
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
/// Features to enable
|
| 8 |
+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
| 9 |
+
enum Feature {
|
| 10 |
+
NoSysF128,
|
| 11 |
+
NoSysF128IntConvert,
|
| 12 |
+
NoSysF16,
|
| 13 |
+
NoSysF16F64Convert,
|
| 14 |
+
NoSysF16F128Convert,
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
impl Feature {
|
| 18 |
+
fn implies(self) -> &'static [Self] {
|
| 19 |
+
match self {
|
| 20 |
+
Self::NoSysF128 => [Self::NoSysF128IntConvert, Self::NoSysF16F128Convert].as_slice(),
|
| 21 |
+
Self::NoSysF128IntConvert => [].as_slice(),
|
| 22 |
+
Self::NoSysF16 => [Self::NoSysF16F64Convert, Self::NoSysF16F128Convert].as_slice(),
|
| 23 |
+
Self::NoSysF16F64Convert => [].as_slice(),
|
| 24 |
+
Self::NoSysF16F128Convert => [].as_slice(),
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
fn main() {
|
| 30 |
+
println!("cargo::rerun-if-changed=../configure.rs");
|
| 31 |
+
|
| 32 |
+
let target = builtins_configure::Target::from_env();
|
| 33 |
+
let mut features = HashSet::new();
|
| 34 |
+
|
| 35 |
+
// These platforms do not have f128 symbols available in their system libraries, so
|
| 36 |
+
// skip related tests.
|
| 37 |
+
if target.arch == "arm"
|
| 38 |
+
|| target.vendor == "apple"
|
| 39 |
+
|| target.env == "msvc"
|
| 40 |
+
// GCC and LLVM disagree on the ABI of `f16` and `f128` with MinGW. See
|
| 41 |
+
// <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>.
|
| 42 |
+
|| (target.os == "windows" && target.env == "gnu")
|
| 43 |
+
// FIXME(llvm): There is an ABI incompatibility between GCC and Clang on 32-bit x86.
|
| 44 |
+
// See <https://github.com/llvm/llvm-project/issues/77401>.
|
| 45 |
+
|| target.arch == "x86"
|
| 46 |
+
// 32-bit PowerPC and 64-bit LE gets code generated that Qemu cannot handle. See
|
| 47 |
+
// <https://github.com/rust-lang/compiler-builtins/pull/606#issuecomment-2105635926>.
|
| 48 |
+
|| target.arch == "powerpc"
|
| 49 |
+
|| target.arch == "powerpc64le"
|
| 50 |
+
// FIXME: We get different results from the builtin functions. See
|
| 51 |
+
// <https://github.com/rust-lang/compiler-builtins/pull/606#issuecomment-2105657287>.
|
| 52 |
+
|| target.arch == "powerpc64"
|
| 53 |
+
{
|
| 54 |
+
features.insert(Feature::NoSysF128);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
if target.arch == "x86" {
|
| 58 |
+
// 32-bit x86 does not have `__fixunstfti`/`__fixtfti` but does have everything else
|
| 59 |
+
features.insert(Feature::NoSysF128IntConvert);
|
| 60 |
+
// FIXME: 32-bit x86 has a bug in `f128 -> f16` system libraries
|
| 61 |
+
features.insert(Feature::NoSysF16F128Convert);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// These platforms do not have f16 symbols available in their system libraries, so
|
| 65 |
+
// skip related tests. Most of these are missing `f16 <-> f32` conversion routines.
|
| 66 |
+
if (target.arch == "aarch64" && target.os == "linux")
|
| 67 |
+
|| target.arch.starts_with("arm")
|
| 68 |
+
|| target.arch == "powerpc"
|
| 69 |
+
|| target.arch == "powerpc64"
|
| 70 |
+
|| target.arch == "powerpc64le"
|
| 71 |
+
|| target.arch == "loongarch64"
|
| 72 |
+
|| (target.arch == "x86" && !target.has_feature("sse"))
|
| 73 |
+
|| target.os == "windows"
|
| 74 |
+
// Linking says "error: function signature mismatch: __extendhfsf2" and seems to
|
| 75 |
+
// think the signature is either `(i32) -> f32` or `(f32) -> f32`. See
|
| 76 |
+
// <https://github.com/llvm/llvm-project/issues/96438>.
|
| 77 |
+
|| target.arch == "wasm32"
|
| 78 |
+
|| target.arch == "wasm64"
|
| 79 |
+
{
|
| 80 |
+
features.insert(Feature::NoSysF16);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
// These platforms are missing either `__extendhfdf2` or `__truncdfhf2`.
|
| 84 |
+
if target.vendor == "apple" || target.os == "windows" {
|
| 85 |
+
features.insert(Feature::NoSysF16F64Convert);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
// Add implied features. Collection is required for borrows.
|
| 89 |
+
features.extend(
|
| 90 |
+
features
|
| 91 |
+
.iter()
|
| 92 |
+
.flat_map(|x| x.implies())
|
| 93 |
+
.copied()
|
| 94 |
+
.collect::<Vec<_>>(),
|
| 95 |
+
);
|
| 96 |
+
|
| 97 |
+
for feature in features {
|
| 98 |
+
let (name, warning) = match feature {
|
| 99 |
+
Feature::NoSysF128 => ("no-sys-f128", "using apfloat fallback for f128"),
|
| 100 |
+
Feature::NoSysF128IntConvert => (
|
| 101 |
+
"no-sys-f128-int-convert",
|
| 102 |
+
"using apfloat fallback for f128 <-> int conversions",
|
| 103 |
+
),
|
| 104 |
+
Feature::NoSysF16F64Convert => (
|
| 105 |
+
"no-sys-f16-f64-convert",
|
| 106 |
+
"using apfloat fallback for f16 <-> f64 conversions",
|
| 107 |
+
),
|
| 108 |
+
Feature::NoSysF16F128Convert => (
|
| 109 |
+
"no-sys-f16-f128-convert",
|
| 110 |
+
"using apfloat fallback for f16 <-> f128 conversions",
|
| 111 |
+
),
|
| 112 |
+
Feature::NoSysF16 => ("no-sys-f16", "using apfloat fallback for f16"),
|
| 113 |
+
};
|
| 114 |
+
println!("cargo:warning={warning}");
|
| 115 |
+
println!("cargo:rustc-cfg=feature=\"{name}\"");
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
builtins_configure::configure_aliases(&target);
|
| 119 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/bench-icount.sh
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
set -eux
|
| 4 |
+
|
| 5 |
+
target="${1:-}"
|
| 6 |
+
|
| 7 |
+
if [ -z "$target" ]; then
|
| 8 |
+
host_target=$(rustc -vV | awk '/^host/ { print $2 }')
|
| 9 |
+
echo "Defaulted to host target $host_target"
|
| 10 |
+
target="$host_target"
|
| 11 |
+
fi
|
| 12 |
+
|
| 13 |
+
# Print machine information
|
| 14 |
+
uname -a
|
| 15 |
+
lscpu || true
|
| 16 |
+
|
| 17 |
+
gungraun_home="gungraun-home"
|
| 18 |
+
|
| 19 |
+
# Use the arch as a tag to disambiguate artifacts
|
| 20 |
+
tag="$(echo "$target" | cut -d'-' -f1)"
|
| 21 |
+
|
| 22 |
+
# Download the baseline from main
|
| 23 |
+
./ci/ci-util.py locate-baseline --download --extract --tag "$tag"
|
| 24 |
+
|
| 25 |
+
# FIXME: migration from iai-named baselines to gungraun, can be dropped
|
| 26 |
+
# after the first run with gungraun.
|
| 27 |
+
[ -d "iai-home" ] && mv "iai-home" "$gungraun_home"
|
| 28 |
+
|
| 29 |
+
# Run benchmarks once
|
| 30 |
+
function run_icount_benchmarks() {
|
| 31 |
+
cargo_args=(
|
| 32 |
+
"--bench" "*icount*"
|
| 33 |
+
"--no-default-features"
|
| 34 |
+
"--features" "unstable,unstable-float,icount"
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
gungraun_args=(
|
| 38 |
+
"--home" "$(pwd)/$gungraun_home"
|
| 39 |
+
"--callgrind-limits=ir=5.0%"
|
| 40 |
+
"--save-summary"
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
# Parse `cargo_arg0 cargo_arg1 -- gungraun_arg0 gungraun_arg1` syntax
|
| 44 |
+
parsing_gungraun_args=0
|
| 45 |
+
while [ "$#" -gt 0 ]; do
|
| 46 |
+
if [ "$parsing_gungraun_args" == "1" ]; then
|
| 47 |
+
gungraun_args+=("$1")
|
| 48 |
+
elif [ "$1" == "--" ]; then
|
| 49 |
+
parsing_gungraun_args=1
|
| 50 |
+
else
|
| 51 |
+
cargo_args+=("$1")
|
| 52 |
+
fi
|
| 53 |
+
|
| 54 |
+
shift
|
| 55 |
+
done
|
| 56 |
+
|
| 57 |
+
# Run gungraun benchmarks. Do this in a subshell with `&& true` to capture
|
| 58 |
+
# rather than exit on error.
|
| 59 |
+
(cargo bench "${cargo_args[@]}" -- "${gungraun_args[@]}") && true
|
| 60 |
+
exit_code="$?"
|
| 61 |
+
|
| 62 |
+
if [ "$exit_code" -eq 0 ]; then
|
| 63 |
+
echo "Benchmarks completed with no regressions"
|
| 64 |
+
elif [ -z "${PR_NUMBER:-}" ]; then
|
| 65 |
+
# Disregard regressions after merge
|
| 66 |
+
echo "Benchmarks completed with regressions; ignoring (not in a PR)"
|
| 67 |
+
else
|
| 68 |
+
./ci/ci-util.py handle-bench-regressions "$PR_NUMBER"
|
| 69 |
+
fi
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
# Run once with softfloats, once with arch instructions enabled
|
| 73 |
+
run_icount_benchmarks --features force-soft-floats -- --save-baseline=softfloat
|
| 74 |
+
run_icount_benchmarks -- --save-baseline=hardfloat
|
| 75 |
+
|
| 76 |
+
# Name and tar the new baseline
|
| 77 |
+
name="baseline-icount-$tag-$(date -u +'%Y%m%d%H%M')-${GITHUB_SHA:0:12}"
|
| 78 |
+
echo "BASELINE_NAME=$name" >>"$GITHUB_ENV"
|
| 79 |
+
tar cJf "$name.tar.xz" "$gungraun_home"
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/bench-runtime.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# Run wall time benchmarks as we do on CI.
|
| 3 |
+
|
| 4 |
+
# Always use the same seed for benchmarks. Ideally we should switch to a
|
| 5 |
+
# non-random generator.
|
| 6 |
+
export LIBM_SEED=benchesbenchesbenchesbencheswoo!
|
| 7 |
+
cargo bench --package libm-test \
|
| 8 |
+
--no-default-features \
|
| 9 |
+
--features short-benchmarks,build-musl,libm/force-soft-floats
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/ci-util.py
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Utilities for CI.
|
| 3 |
+
|
| 4 |
+
This dynamically prepares a list of routines that had a source file change based on
|
| 5 |
+
git history.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import json
|
| 9 |
+
import os
|
| 10 |
+
import pprint
|
| 11 |
+
import re
|
| 12 |
+
import subprocess as sp
|
| 13 |
+
import sys
|
| 14 |
+
from dataclasses import dataclass
|
| 15 |
+
from functools import cache
|
| 16 |
+
from glob import glob
|
| 17 |
+
from inspect import cleandoc
|
| 18 |
+
from os import getenv
|
| 19 |
+
from pathlib import Path
|
| 20 |
+
from typing import TypedDict, Self
|
| 21 |
+
|
| 22 |
+
USAGE = cleandoc(
|
| 23 |
+
"""
|
| 24 |
+
usage:
|
| 25 |
+
|
| 26 |
+
./ci/ci-util.py <COMMAND> [flags]
|
| 27 |
+
|
| 28 |
+
COMMAND:
|
| 29 |
+
generate-matrix
|
| 30 |
+
Calculate a matrix of which functions had source change, print that as
|
| 31 |
+
a JSON object.
|
| 32 |
+
|
| 33 |
+
locate-baseline [--download] [--extract] [--tag TAG]
|
| 34 |
+
Locate the most recent benchmark baseline available in CI and, if flags
|
| 35 |
+
specify, download and extract it. Never exits with nonzero status if
|
| 36 |
+
downloading fails.
|
| 37 |
+
|
| 38 |
+
`--tag` can be specified to look for artifacts with a specific tag, such as
|
| 39 |
+
for a specific architecture.
|
| 40 |
+
|
| 41 |
+
Note that `--extract` will overwrite files in `gungraun-home`.
|
| 42 |
+
|
| 43 |
+
handle-bench-regressions PR_NUMBER
|
| 44 |
+
Exit with success if the pull request contains a line starting with
|
| 45 |
+
`ci: allow-regressions`, indicating that regressions in benchmarks should
|
| 46 |
+
be accepted. Otherwise, exit 1.
|
| 47 |
+
"""
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
REPO_ROOT = Path(__file__).parent.parent
|
| 51 |
+
GIT = ["git", "-C", REPO_ROOT]
|
| 52 |
+
DEFAULT_BRANCH = "main"
|
| 53 |
+
WORKFLOW_NAME = "CI" # Workflow that generates the benchmark artifacts
|
| 54 |
+
ARTIFACT_PREFIX = "baseline-icount*"
|
| 55 |
+
|
| 56 |
+
# Don't run exhaustive tests if these files change, even if they contaiin a function
|
| 57 |
+
# definition.
|
| 58 |
+
IGNORE_FILES = [
|
| 59 |
+
"libm/src/math/support/",
|
| 60 |
+
"libm/src/libm_helper.rs",
|
| 61 |
+
"libm/src/math/arch/intrinsics.rs",
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
# libm PR CI takes a long time and doesn't need to run unless relevant files have been
|
| 65 |
+
# changed. Anything matching this regex pattern will trigger a run.
|
| 66 |
+
TRIGGER_LIBM_CI_FILE_PAT = ".*(libm|musl).*"
|
| 67 |
+
|
| 68 |
+
TYPES = ["f16", "f32", "f64", "f128"]
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def eprint(*args, **kwargs):
|
| 72 |
+
"""Print to stderr."""
|
| 73 |
+
print(*args, file=sys.stderr, **kwargs)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@dataclass(init=False)
|
| 77 |
+
class PrCfg:
|
| 78 |
+
"""Directives that we allow in the commit body to control test behavior.
|
| 79 |
+
|
| 80 |
+
These are of the form `ci: foo`, at the start of a line.
|
| 81 |
+
"""
|
| 82 |
+
|
| 83 |
+
# Skip regression checks (must be at the start of a line).
|
| 84 |
+
allow_regressions: bool = False
|
| 85 |
+
# Don't run extensive tests
|
| 86 |
+
skip_extensive: bool = False
|
| 87 |
+
|
| 88 |
+
# Allow running a large number of extensive tests. If not set, this script
|
| 89 |
+
# will error out if a threshold is exceeded in order to avoid accidentally
|
| 90 |
+
# spending huge amounts of CI time.
|
| 91 |
+
allow_many_extensive: bool = False
|
| 92 |
+
|
| 93 |
+
# Max number of extensive tests to run by default
|
| 94 |
+
MANY_EXTENSIVE_THRESHOLD: int = 20
|
| 95 |
+
|
| 96 |
+
# Run tests for `libm` that may otherwise be skipped due to no changed files.
|
| 97 |
+
always_test_libm: bool = False
|
| 98 |
+
|
| 99 |
+
# String values of directive names
|
| 100 |
+
DIR_ALLOW_REGRESSIONS: str = "allow-regressions"
|
| 101 |
+
DIR_SKIP_EXTENSIVE: str = "skip-extensive"
|
| 102 |
+
DIR_ALLOW_MANY_EXTENSIVE: str = "allow-many-extensive"
|
| 103 |
+
DIR_TEST_LIBM: str = "test-libm"
|
| 104 |
+
|
| 105 |
+
def __init__(self, body: str):
|
| 106 |
+
directives = re.finditer(r"^\s*ci:\s*(?P<dir_name>\S*)", body, re.MULTILINE)
|
| 107 |
+
for dir in directives:
|
| 108 |
+
name = dir.group("dir_name")
|
| 109 |
+
if name == self.DIR_ALLOW_REGRESSIONS:
|
| 110 |
+
self.allow_regressions = True
|
| 111 |
+
elif name == self.DIR_SKIP_EXTENSIVE:
|
| 112 |
+
self.skip_extensive = True
|
| 113 |
+
elif name == self.DIR_ALLOW_MANY_EXTENSIVE:
|
| 114 |
+
self.allow_many_extensive = True
|
| 115 |
+
elif name == self.DIR_TEST_LIBM:
|
| 116 |
+
self.always_test_libm = True
|
| 117 |
+
else:
|
| 118 |
+
eprint(f"Found unexpected directive `{name}`")
|
| 119 |
+
exit(1)
|
| 120 |
+
|
| 121 |
+
pprint.pp(self)
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
@dataclass
|
| 125 |
+
class PrInfo:
|
| 126 |
+
"""GitHub response for PR query"""
|
| 127 |
+
|
| 128 |
+
body: str
|
| 129 |
+
commits: list[str]
|
| 130 |
+
created_at: str
|
| 131 |
+
number: int
|
| 132 |
+
cfg: PrCfg
|
| 133 |
+
|
| 134 |
+
@classmethod
|
| 135 |
+
def from_env(cls) -> Self | None:
|
| 136 |
+
"""Create a PR object from the PR_NUMBER environment if set, `None` otherwise."""
|
| 137 |
+
pr_env = os.environ.get("PR_NUMBER")
|
| 138 |
+
if pr_env is not None and len(pr_env) > 0:
|
| 139 |
+
return cls.from_pr(pr_env)
|
| 140 |
+
|
| 141 |
+
return None
|
| 142 |
+
|
| 143 |
+
@classmethod
|
| 144 |
+
@cache # Cache so we don't print info messages multiple times
|
| 145 |
+
def from_pr(cls, pr_number: int | str) -> Self:
|
| 146 |
+
"""For a given PR number, query the body and commit list."""
|
| 147 |
+
pr_info = sp.check_output(
|
| 148 |
+
[
|
| 149 |
+
"gh",
|
| 150 |
+
"pr",
|
| 151 |
+
"view",
|
| 152 |
+
str(pr_number),
|
| 153 |
+
"--json=number,commits,body,createdAt",
|
| 154 |
+
# Flatten the commit list to only hashes, change a key to snake naming
|
| 155 |
+
"--jq=.commits |= map(.oid) | .created_at = .createdAt | del(.createdAt)",
|
| 156 |
+
],
|
| 157 |
+
text=True,
|
| 158 |
+
)
|
| 159 |
+
pr_json = json.loads(pr_info)
|
| 160 |
+
eprint("PR info:", json.dumps(pr_json, indent=4))
|
| 161 |
+
return cls(**json.loads(pr_info), cfg=PrCfg(pr_json["body"]))
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
class FunctionDef(TypedDict):
|
| 165 |
+
"""Type for an entry in `function-definitions.json`"""
|
| 166 |
+
|
| 167 |
+
sources: list[str]
|
| 168 |
+
type: str
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
class Context:
|
| 172 |
+
gh_ref: str | None
|
| 173 |
+
changed: list[Path]
|
| 174 |
+
defs: dict[str, FunctionDef]
|
| 175 |
+
|
| 176 |
+
def __init__(self) -> None:
|
| 177 |
+
self.gh_ref = getenv("GITHUB_REF")
|
| 178 |
+
self.changed = []
|
| 179 |
+
self._init_change_list()
|
| 180 |
+
|
| 181 |
+
with open(REPO_ROOT.joinpath("etc/function-definitions.json")) as f:
|
| 182 |
+
defs = json.load(f)
|
| 183 |
+
|
| 184 |
+
defs.pop("__comment", None)
|
| 185 |
+
self.defs = defs
|
| 186 |
+
|
| 187 |
+
def _init_change_list(self):
|
| 188 |
+
"""Create a list of files that have been changed. This uses GITHUB_REF if
|
| 189 |
+
available, otherwise a diff between `HEAD` and `main`.
|
| 190 |
+
"""
|
| 191 |
+
|
| 192 |
+
# For pull requests, GitHub creates a ref `refs/pull/1234/merge` (1234 being
|
| 193 |
+
# the PR number), and sets this as `GITHUB_REF`.
|
| 194 |
+
ref = self.gh_ref
|
| 195 |
+
eprint(f"using ref `{ref}`")
|
| 196 |
+
if not self.is_pr():
|
| 197 |
+
# If the ref is not for `merge` then we are not in PR CI
|
| 198 |
+
eprint("No diff available for ref")
|
| 199 |
+
return
|
| 200 |
+
|
| 201 |
+
# The ref is for a dummy merge commit. We can extract the merge base by
|
| 202 |
+
# inspecting all parents (`^@`).
|
| 203 |
+
merge_sha = sp.check_output(
|
| 204 |
+
GIT + ["show-ref", "--hash", ref], text=True
|
| 205 |
+
).strip()
|
| 206 |
+
merge_log = sp.check_output(GIT + ["log", "-1", merge_sha], text=True)
|
| 207 |
+
eprint(f"Merge:\n{merge_log}\n")
|
| 208 |
+
|
| 209 |
+
parents = (
|
| 210 |
+
sp.check_output(GIT + ["rev-parse", f"{merge_sha}^@"], text=True)
|
| 211 |
+
.strip()
|
| 212 |
+
.splitlines()
|
| 213 |
+
)
|
| 214 |
+
assert len(parents) == 2, f"expected two-parent merge but got:\n{parents}"
|
| 215 |
+
base = parents[0].strip()
|
| 216 |
+
incoming = parents[1].strip()
|
| 217 |
+
|
| 218 |
+
eprint(f"base: {base}, incoming: {incoming}")
|
| 219 |
+
textlist = sp.check_output(
|
| 220 |
+
GIT + ["diff", base, incoming, "--name-only"], text=True
|
| 221 |
+
)
|
| 222 |
+
self.changed = [Path(p) for p in textlist.splitlines()]
|
| 223 |
+
|
| 224 |
+
def is_pr(self) -> bool:
|
| 225 |
+
"""Check if we are looking at a PR rather than a push."""
|
| 226 |
+
return self.gh_ref is not None and "merge" in self.gh_ref
|
| 227 |
+
|
| 228 |
+
@staticmethod
|
| 229 |
+
def _ignore_file(fname: str) -> bool:
|
| 230 |
+
return any(fname.startswith(pfx) for pfx in IGNORE_FILES)
|
| 231 |
+
|
| 232 |
+
def changed_routines(self) -> dict[str, list[str]]:
|
| 233 |
+
"""Create a list of routines for which one or more files have been updated,
|
| 234 |
+
separated by type.
|
| 235 |
+
"""
|
| 236 |
+
routines = set()
|
| 237 |
+
for name, meta in self.defs.items():
|
| 238 |
+
# Don't update if changes to the file should be ignored
|
| 239 |
+
sources = (f for f in meta["sources"] if not self._ignore_file(f))
|
| 240 |
+
|
| 241 |
+
# Select changed files
|
| 242 |
+
changed = [f for f in sources if Path(f) in self.changed]
|
| 243 |
+
|
| 244 |
+
if len(changed) > 0:
|
| 245 |
+
eprint(f"changed files for {name}: {changed}")
|
| 246 |
+
routines.add(name)
|
| 247 |
+
|
| 248 |
+
ret: dict[str, list[str]] = {}
|
| 249 |
+
for r in sorted(routines):
|
| 250 |
+
ret.setdefault(self.defs[r]["type"], []).append(r)
|
| 251 |
+
|
| 252 |
+
return ret
|
| 253 |
+
|
| 254 |
+
def may_skip_libm_ci(self) -> bool:
|
| 255 |
+
"""If this is a PR and no libm files were changed, allow skipping libm
|
| 256 |
+
jobs."""
|
| 257 |
+
|
| 258 |
+
# Always run on merge CI
|
| 259 |
+
if not self.is_pr():
|
| 260 |
+
return False
|
| 261 |
+
|
| 262 |
+
pr = PrInfo.from_env()
|
| 263 |
+
assert pr is not None, "Is a PR but couldn't load PrInfo"
|
| 264 |
+
|
| 265 |
+
# Allow opting in to libm tests
|
| 266 |
+
if pr.cfg.always_test_libm:
|
| 267 |
+
return False
|
| 268 |
+
|
| 269 |
+
# By default, run if there are any changed files matching the pattern
|
| 270 |
+
return all(not re.match(TRIGGER_LIBM_CI_FILE_PAT, str(f)) for f in self.changed)
|
| 271 |
+
|
| 272 |
+
def emit_workflow_output(self):
|
| 273 |
+
"""Create a JSON object a list items for each type's changed files, if any
|
| 274 |
+
did change, and the routines that were affected by the change.
|
| 275 |
+
"""
|
| 276 |
+
|
| 277 |
+
skip_tests = False
|
| 278 |
+
error_on_many_tests = False
|
| 279 |
+
|
| 280 |
+
pr = PrInfo.from_env()
|
| 281 |
+
if pr is not None:
|
| 282 |
+
skip_tests = pr.cfg.skip_extensive
|
| 283 |
+
error_on_many_tests = not pr.cfg.allow_many_extensive
|
| 284 |
+
|
| 285 |
+
if skip_tests:
|
| 286 |
+
eprint("Skipping all extensive tests")
|
| 287 |
+
|
| 288 |
+
changed = self.changed_routines()
|
| 289 |
+
matrix = []
|
| 290 |
+
total_to_test = 0
|
| 291 |
+
|
| 292 |
+
# Figure out which extensive tests need to run
|
| 293 |
+
for ty in TYPES:
|
| 294 |
+
ty_changed = changed.get(ty, [])
|
| 295 |
+
ty_to_test = [] if skip_tests else ty_changed
|
| 296 |
+
total_to_test += len(ty_to_test)
|
| 297 |
+
|
| 298 |
+
item = {
|
| 299 |
+
"ty": ty,
|
| 300 |
+
"changed": ",".join(ty_changed),
|
| 301 |
+
"to_test": ",".join(ty_to_test),
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
matrix.append(item)
|
| 305 |
+
|
| 306 |
+
ext_matrix = json.dumps({"extensive_matrix": matrix}, separators=(",", ":"))
|
| 307 |
+
may_skip = str(self.may_skip_libm_ci()).lower()
|
| 308 |
+
print(f"extensive_matrix={ext_matrix}")
|
| 309 |
+
print(f"may_skip_libm_ci={may_skip}")
|
| 310 |
+
eprint(f"total extensive tests: {total_to_test}")
|
| 311 |
+
|
| 312 |
+
if error_on_many_tests and total_to_test > PrCfg.MANY_EXTENSIVE_THRESHOLD:
|
| 313 |
+
eprint(
|
| 314 |
+
f"More than {PrCfg.MANY_EXTENSIVE_THRESHOLD} tests would be run; add"
|
| 315 |
+
f" `{PrCfg.DIR_ALLOW_MANY_EXTENSIVE}` to the PR body if this is"
|
| 316 |
+
" intentional. If this is refactoring that happens to touch a lot of"
|
| 317 |
+
f" files, `{PrCfg.DIR_SKIP_EXTENSIVE}` can be used instead."
|
| 318 |
+
)
|
| 319 |
+
exit(1)
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
def locate_baseline(flags: list[str]) -> None:
|
| 323 |
+
"""Find the most recent baseline from CI, download it if specified.
|
| 324 |
+
|
| 325 |
+
This returns rather than erroring, even if the `gh` commands fail. This is to avoid
|
| 326 |
+
erroring in CI if the baseline is unavailable (artifact time limit exceeded, first
|
| 327 |
+
run on the branch, etc).
|
| 328 |
+
"""
|
| 329 |
+
|
| 330 |
+
download = False
|
| 331 |
+
extract = False
|
| 332 |
+
tag = ""
|
| 333 |
+
|
| 334 |
+
while len(flags) > 0:
|
| 335 |
+
match flags[0]:
|
| 336 |
+
case "--download":
|
| 337 |
+
download = True
|
| 338 |
+
case "--extract":
|
| 339 |
+
extract = True
|
| 340 |
+
case "--tag":
|
| 341 |
+
tag = flags[1]
|
| 342 |
+
flags = flags[1:]
|
| 343 |
+
case _:
|
| 344 |
+
eprint(USAGE)
|
| 345 |
+
exit(1)
|
| 346 |
+
flags = flags[1:]
|
| 347 |
+
|
| 348 |
+
if extract and not download:
|
| 349 |
+
eprint("cannot extract without downloading")
|
| 350 |
+
exit(1)
|
| 351 |
+
|
| 352 |
+
try:
|
| 353 |
+
# Locate the most recent job to complete with success on our branch
|
| 354 |
+
latest_job = sp.check_output(
|
| 355 |
+
[
|
| 356 |
+
"gh",
|
| 357 |
+
"run",
|
| 358 |
+
"list",
|
| 359 |
+
"--status=success",
|
| 360 |
+
f"--branch={DEFAULT_BRANCH}",
|
| 361 |
+
"--json=databaseId,url,headSha,conclusion,createdAt,"
|
| 362 |
+
"status,workflowDatabaseId,workflowName",
|
| 363 |
+
# Return the first array element matching our workflow name. NB: cannot
|
| 364 |
+
# just use `--limit=1`, jq filtering happens after limiting. We also
|
| 365 |
+
# cannot just use `--workflow` because GH gets confused from
|
| 366 |
+
# different file names in history.
|
| 367 |
+
f'--jq=[.[] | select(.workflowName == "{WORKFLOW_NAME}")][0]',
|
| 368 |
+
],
|
| 369 |
+
text=True,
|
| 370 |
+
)
|
| 371 |
+
except sp.CalledProcessError as e:
|
| 372 |
+
eprint(f"failed to run github command: {e}")
|
| 373 |
+
return
|
| 374 |
+
|
| 375 |
+
try:
|
| 376 |
+
latest = json.loads(latest_job)
|
| 377 |
+
eprint("latest job: ", json.dumps(latest, indent=4))
|
| 378 |
+
except json.JSONDecodeError as e:
|
| 379 |
+
eprint(f"failed to decode json '{latest_job}', {e}")
|
| 380 |
+
return
|
| 381 |
+
|
| 382 |
+
if not download:
|
| 383 |
+
eprint("--download not specified, returning")
|
| 384 |
+
return
|
| 385 |
+
|
| 386 |
+
job_id = latest.get("databaseId")
|
| 387 |
+
if job_id is None:
|
| 388 |
+
eprint("skipping download step")
|
| 389 |
+
return
|
| 390 |
+
|
| 391 |
+
artifact_glob = f"{ARTIFACT_PREFIX}{f"-{tag}" if tag else ""}*"
|
| 392 |
+
|
| 393 |
+
# Skip checking because this will fail if the file already exists, which is fine.
|
| 394 |
+
sp.run(
|
| 395 |
+
["gh", "run", "download", str(job_id), f"--pattern={artifact_glob}"],
|
| 396 |
+
check=False,
|
| 397 |
+
)
|
| 398 |
+
|
| 399 |
+
if not extract:
|
| 400 |
+
eprint("skipping extraction step")
|
| 401 |
+
return
|
| 402 |
+
|
| 403 |
+
# Find the baseline with the most recent timestamp. GH downloads the files to e.g.
|
| 404 |
+
# `some-dirname/some-dirname.tar.xz`, so just glob the whole thing together.
|
| 405 |
+
candidate_baselines = glob(f"{artifact_glob}/{artifact_glob}")
|
| 406 |
+
if len(candidate_baselines) == 0:
|
| 407 |
+
eprint("no possible baseline directories found")
|
| 408 |
+
return
|
| 409 |
+
|
| 410 |
+
candidate_baselines.sort(reverse=True)
|
| 411 |
+
baseline_archive = candidate_baselines[0]
|
| 412 |
+
eprint(f"extracting {baseline_archive}")
|
| 413 |
+
|
| 414 |
+
all_paths = sp.check_output(["tar", "tJf", baseline_archive], encoding="utf8")
|
| 415 |
+
sp.run(["tar", "xJf", baseline_archive], check=True)
|
| 416 |
+
|
| 417 |
+
# Print a short summary of paths, we don't use `tar v` since the list is huge
|
| 418 |
+
short_paths = re.findall(r"^(?:[^/\n]+/?){1,3}", all_paths, re.MULTILINE)
|
| 419 |
+
|
| 420 |
+
print("Extracted:")
|
| 421 |
+
for path in sorted(set(short_paths)):
|
| 422 |
+
print(f"* {path}")
|
| 423 |
+
|
| 424 |
+
eprint("baseline extracted successfully")
|
| 425 |
+
|
| 426 |
+
|
| 427 |
+
def handle_bench_regressions(args: list[str]):
|
| 428 |
+
"""Exit with error unless the PR message contains an ignore directive."""
|
| 429 |
+
|
| 430 |
+
match args:
|
| 431 |
+
case [pr_number]:
|
| 432 |
+
pr_number = pr_number
|
| 433 |
+
case _:
|
| 434 |
+
eprint(USAGE)
|
| 435 |
+
exit(1)
|
| 436 |
+
|
| 437 |
+
pr = PrInfo.from_pr(pr_number)
|
| 438 |
+
if pr.cfg.allow_regressions:
|
| 439 |
+
eprint("PR allows regressions")
|
| 440 |
+
return
|
| 441 |
+
|
| 442 |
+
eprint("Regressions were found; benchmark failed")
|
| 443 |
+
exit(1)
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
def main():
|
| 447 |
+
match sys.argv[1:]:
|
| 448 |
+
case ["generate-matrix"]:
|
| 449 |
+
ctx = Context()
|
| 450 |
+
ctx.emit_workflow_output()
|
| 451 |
+
case ["locate-baseline", *flags]:
|
| 452 |
+
locate_baseline(flags)
|
| 453 |
+
case ["handle-bench-regressions", *args]:
|
| 454 |
+
handle_bench_regressions(args)
|
| 455 |
+
case ["--help" | "-h"]:
|
| 456 |
+
print(USAGE)
|
| 457 |
+
exit()
|
| 458 |
+
case _:
|
| 459 |
+
eprint(USAGE)
|
| 460 |
+
exit(1)
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
if __name__ == "__main__":
|
| 464 |
+
main()
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/download-compiler-rt.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# Download sources to build C versions of intrinsics. Once being run,
|
| 3 |
+
# `RUST_COMPILER_RT_ROOT` must be set.
|
| 4 |
+
|
| 5 |
+
set -eux
|
| 6 |
+
|
| 7 |
+
rust_llvm_version=20.1-2025-02-13
|
| 8 |
+
|
| 9 |
+
curl -L -o code.tar.gz "https://github.com/rust-lang/llvm-project/archive/rustc/${rust_llvm_version}.tar.gz"
|
| 10 |
+
tar xzf code.tar.gz --strip-components 1 llvm-project-rustc-${rust_llvm_version}/compiler-rt
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/install-bench-deps.sh
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# Install needed dependencies for gungraun.
|
| 3 |
+
|
| 4 |
+
sudo apt-get update
|
| 5 |
+
sudo apt-get install -y valgrind gdb libc6-dbg # Needed for gungraun
|
| 6 |
+
rustup update "$BENCHMARK_RUSTC" --no-self-update
|
| 7 |
+
rustup default "$BENCHMARK_RUSTC"
|
| 8 |
+
# Install the version of gungraun-runner that is specified in Cargo.toml
|
| 9 |
+
gungraun_version="$(cargo metadata --format-version=1 --features icount |
|
| 10 |
+
jq -r '.packages[] | select(.name == "gungraun").version')"
|
| 11 |
+
cargo binstall -y gungraun-runner --version "$gungraun_version"
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/miri.sh
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -eux
|
| 3 |
+
|
| 4 |
+
# We need Tree Borrows as some of our raw pointer patterns are not
|
| 5 |
+
# compatible with Stacked Borrows.
|
| 6 |
+
export MIRIFLAGS="-Zmiri-tree-borrows"
|
| 7 |
+
|
| 8 |
+
# One target that sets `mem-unaligned` and one that does not,
|
| 9 |
+
# and a big-endian target.
|
| 10 |
+
targets=(
|
| 11 |
+
x86_64-unknown-linux-gnu
|
| 12 |
+
armv7-unknown-linux-gnueabihf
|
| 13 |
+
s390x-unknown-linux-gnu
|
| 14 |
+
)
|
| 15 |
+
for target in "${targets[@]}"; do
|
| 16 |
+
# Only run the `mem` tests to avoid this taking too long.
|
| 17 |
+
cargo miri test --manifest-path builtins-test/Cargo.toml --features no-asm --target "$target" -- mem
|
| 18 |
+
done
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/run-docker.sh
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Small script to run tests for a target (or all targets) inside all the
|
| 4 |
+
# respective docker images.
|
| 5 |
+
|
| 6 |
+
set -euxo pipefail
|
| 7 |
+
|
| 8 |
+
host_arch="$(uname -m | sed 's/arm64/aarch64/')"
|
| 9 |
+
|
| 10 |
+
# Directories and files that do not yet exist need to be created before
|
| 11 |
+
# calling docker, otherwise docker will create them but they will be owned
|
| 12 |
+
# by root.
|
| 13 |
+
mkdir -p target
|
| 14 |
+
cargo generate-lockfile
|
| 15 |
+
cargo generate-lockfile --manifest-path builtins-test-intrinsics/Cargo.toml
|
| 16 |
+
|
| 17 |
+
run() {
|
| 18 |
+
local target="$1"
|
| 19 |
+
|
| 20 |
+
echo "testing target: $target"
|
| 21 |
+
|
| 22 |
+
emulated=""
|
| 23 |
+
target_arch="$(echo "$target" | cut -d'-' -f1)"
|
| 24 |
+
if [ "$target_arch" != "$host_arch" ]; then
|
| 25 |
+
emulated=1
|
| 26 |
+
echo "target is emulated"
|
| 27 |
+
fi
|
| 28 |
+
|
| 29 |
+
run_cmd="HOME=/tmp"
|
| 30 |
+
|
| 31 |
+
if [ "${GITHUB_ACTIONS:-}" = "true" ]; then
|
| 32 |
+
# Enable Docker image caching on GHA
|
| 33 |
+
build_cmd=("buildx" "build")
|
| 34 |
+
build_args=(
|
| 35 |
+
"--cache-from" "type=local,src=/tmp/.buildx-cache"
|
| 36 |
+
"--cache-to" "type=local,dest=/tmp/.buildx-cache-new"
|
| 37 |
+
# This is the beautiful bash syntax for expanding an array but neither
|
| 38 |
+
# raising an error nor returning an empty string if the array is empty.
|
| 39 |
+
"${build_args[@]:+"${build_args[@]}"}"
|
| 40 |
+
"--load"
|
| 41 |
+
)
|
| 42 |
+
fi
|
| 43 |
+
|
| 44 |
+
if [ "$(uname -s)" = "Linux" ] && [ -z "${DOCKER_BASE_IMAGE:-}" ]; then
|
| 45 |
+
# Share the host rustc and target. Do this only on Linux and if the image
|
| 46 |
+
# isn't overridden
|
| 47 |
+
run_args=(
|
| 48 |
+
--user "$(id -u):$(id -g)"
|
| 49 |
+
-e "CARGO_HOME=/cargo"
|
| 50 |
+
-v "${HOME}/.cargo:/cargo"
|
| 51 |
+
-v "$(pwd)/target:/builtins-target"
|
| 52 |
+
-v "$(rustc --print sysroot):/rust:ro"
|
| 53 |
+
)
|
| 54 |
+
run_cmd="$run_cmd PATH=\$PATH:/rust/bin:/cargo/bin"
|
| 55 |
+
else
|
| 56 |
+
# Use rustc provided by a docker image
|
| 57 |
+
docker volume create compiler-builtins-cache
|
| 58 |
+
build_args=(
|
| 59 |
+
"--build-arg"
|
| 60 |
+
"IMAGE=${DOCKER_BASE_IMAGE:-rustlang/rust:nightly}"
|
| 61 |
+
)
|
| 62 |
+
run_args=(-v "compiler-builtins-cache:/builtins-target")
|
| 63 |
+
run_cmd="$run_cmd HOME=/tmp" "USING_CONTAINER_RUSTC=1"
|
| 64 |
+
fi
|
| 65 |
+
|
| 66 |
+
if [ -d compiler-rt ]; then
|
| 67 |
+
export RUST_COMPILER_RT_ROOT="/checkout/compiler-rt"
|
| 68 |
+
fi
|
| 69 |
+
|
| 70 |
+
run_cmd="$run_cmd ci/run.sh $target"
|
| 71 |
+
|
| 72 |
+
docker "${build_cmd[@]:-build}" \
|
| 73 |
+
-t "builtins-$target" \
|
| 74 |
+
"${build_args[@]:-}" \
|
| 75 |
+
"ci/docker/$target"
|
| 76 |
+
docker run \
|
| 77 |
+
--rm \
|
| 78 |
+
-e CI \
|
| 79 |
+
-e CARGO_TARGET_DIR=/builtins-target \
|
| 80 |
+
-e CARGO_TERM_COLOR \
|
| 81 |
+
-e MAY_SKIP_LIBM_CI \
|
| 82 |
+
-e RUSTFLAGS \
|
| 83 |
+
-e RUST_BACKTRACE \
|
| 84 |
+
-e RUST_COMPILER_RT_ROOT \
|
| 85 |
+
-e "EMULATED=$emulated" \
|
| 86 |
+
-v "$(pwd):/checkout:ro" \
|
| 87 |
+
-w /checkout \
|
| 88 |
+
"${run_args[@]:-}" \
|
| 89 |
+
--init \
|
| 90 |
+
"builtins-$target" \
|
| 91 |
+
sh -c "$run_cmd"
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
if [ "${1:-}" = "--help" ] || [ "$#" -gt 1 ]; then
|
| 95 |
+
set +x
|
| 96 |
+
echo "\
|
| 97 |
+
usage: ./ci/run-docker.sh [target]
|
| 98 |
+
|
| 99 |
+
you can also set DOCKER_BASE_IMAGE to use something other than the default
|
| 100 |
+
ubuntu:25.10 (or rustlang/rust:nightly).
|
| 101 |
+
"
|
| 102 |
+
exit
|
| 103 |
+
fi
|
| 104 |
+
|
| 105 |
+
if [ -z "${1:-}" ]; then
|
| 106 |
+
for d in ci/docker/*; do
|
| 107 |
+
run $(basename "$d")
|
| 108 |
+
done
|
| 109 |
+
else
|
| 110 |
+
run "$1"
|
| 111 |
+
fi
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/run-extensive.sh
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
set -euo pipefail
|
| 4 |
+
|
| 5 |
+
echo "Tests to run: '$TO_TEST'"
|
| 6 |
+
|
| 7 |
+
if [ -z "$TO_TEST" ]; then
|
| 8 |
+
echo "No tests to run, exiting."
|
| 9 |
+
exit
|
| 10 |
+
fi
|
| 11 |
+
|
| 12 |
+
set -x
|
| 13 |
+
|
| 14 |
+
test_cmd=(
|
| 15 |
+
cargo test
|
| 16 |
+
--package libm-test
|
| 17 |
+
--features "build-mpfr,libm/unstable,libm/force-soft-floats"
|
| 18 |
+
--profile release-checked
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Run the non-extensive tests first to catch any easy failures
|
| 22 |
+
"${test_cmd[@]}" -- "$TO_TEST"
|
| 23 |
+
|
| 24 |
+
LIBM_EXTENSIVE_TESTS="$TO_TEST" "${test_cmd[@]}" -- extensive
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/run.sh
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
set -eux
|
| 4 |
+
|
| 5 |
+
export RUST_BACKTRACE="${RUST_BACKTRACE:-full}"
|
| 6 |
+
export NEXTEST_STATUS_LEVEL=all
|
| 7 |
+
|
| 8 |
+
target="${1:-}"
|
| 9 |
+
|
| 10 |
+
if [ -z "$target" ]; then
|
| 11 |
+
host_target=$(rustc -vV | awk '/^host/ { print $2 }')
|
| 12 |
+
echo "Defaulted to host target $host_target"
|
| 13 |
+
target="$host_target"
|
| 14 |
+
fi
|
| 15 |
+
|
| 16 |
+
if [ "${USING_CONTAINER_RUSTC:-}" = 1 ]; then
|
| 17 |
+
# Install nonstandard components if we have control of the environment
|
| 18 |
+
rustup target list --installed |
|
| 19 |
+
grep -E "^$target\$" ||
|
| 20 |
+
rustup target add "$target"
|
| 21 |
+
fi
|
| 22 |
+
|
| 23 |
+
# Test our implementation
|
| 24 |
+
if [ "${BUILD_ONLY:-}" = "1" ]; then
|
| 25 |
+
echo "no tests to run for build-only targets"
|
| 26 |
+
else
|
| 27 |
+
test_builtins=(cargo test --package builtins-test --no-fail-fast --target "$target")
|
| 28 |
+
"${test_builtins[@]}"
|
| 29 |
+
"${test_builtins[@]}" --release
|
| 30 |
+
"${test_builtins[@]}" --features c
|
| 31 |
+
"${test_builtins[@]}" --features c --release
|
| 32 |
+
"${test_builtins[@]}" --features no-asm
|
| 33 |
+
"${test_builtins[@]}" --features no-asm --release
|
| 34 |
+
"${test_builtins[@]}" --benches
|
| 35 |
+
"${test_builtins[@]}" --benches --release
|
| 36 |
+
|
| 37 |
+
# Validate that having a verbatim path for the target directory works
|
| 38 |
+
# (trivial to regress using `/` in paths to build artifacts rather than
|
| 39 |
+
# `Path::join`). MinGW does not currently support these paths.
|
| 40 |
+
if [[ "$target" = *"windows"* ]] && [[ "$target" != *"gnu"* ]]; then
|
| 41 |
+
verb_path=$(cmd.exe //C echo \\\\?\\%cd%\\builtins-test\\target2)
|
| 42 |
+
"${test_builtins[@]}" --target-dir "$verb_path" --features c
|
| 43 |
+
fi
|
| 44 |
+
fi
|
| 45 |
+
|
| 46 |
+
# Ensure there are no duplicate symbols or references to `core` when
|
| 47 |
+
# `compiler-builtins` is built with various features. Symcheck invokes Cargo to
|
| 48 |
+
# build with the arguments we provide it, then validates the built artifacts.
|
| 49 |
+
SYMCHECK_TEST_TARGET="$target" cargo test -p symbol-check --release
|
| 50 |
+
symcheck=(cargo run -p symbol-check --release)
|
| 51 |
+
symcheck+=(-- build-and-check)
|
| 52 |
+
|
| 53 |
+
"${symcheck[@]}" "$target" -- -p compiler_builtins
|
| 54 |
+
"${symcheck[@]}" "$target" -- -p compiler_builtins --release
|
| 55 |
+
"${symcheck[@]}" "$target" -- -p compiler_builtins --features c
|
| 56 |
+
"${symcheck[@]}" "$target" -- -p compiler_builtins --features c --release
|
| 57 |
+
"${symcheck[@]}" "$target" -- -p compiler_builtins --features no-asm
|
| 58 |
+
"${symcheck[@]}" "$target" -- -p compiler_builtins --features no-asm --release
|
| 59 |
+
|
| 60 |
+
run_intrinsics_test() {
|
| 61 |
+
build_args=(--verbose --manifest-path builtins-test-intrinsics/Cargo.toml)
|
| 62 |
+
build_args+=("$@")
|
| 63 |
+
|
| 64 |
+
# symcheck also checks the results of builtins-test-intrinsics
|
| 65 |
+
"${symcheck[@]}" "$target" -- "${build_args[@]}"
|
| 66 |
+
|
| 67 |
+
# FIXME: we get access violations on Windows, our entrypoint may need to
|
| 68 |
+
# be tweaked.
|
| 69 |
+
if [ "${BUILD_ONLY:-}" != "1" ] && ! [[ "$target" = *"windows"* ]]; then
|
| 70 |
+
cargo run --target "$target" "${build_args[@]}"
|
| 71 |
+
fi
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
# Verify that we haven't dropped any intrinsics/symbols
|
| 75 |
+
run_intrinsics_test
|
| 76 |
+
run_intrinsics_test --release
|
| 77 |
+
run_intrinsics_test --features c
|
| 78 |
+
run_intrinsics_test --features c --release
|
| 79 |
+
|
| 80 |
+
# Verify that there are no undefined symbols to `panic` within our
|
| 81 |
+
# implementations
|
| 82 |
+
CARGO_PROFILE_DEV_LTO=true run_intrinsics_test
|
| 83 |
+
CARGO_PROFILE_RELEASE_LTO=true run_intrinsics_test --release
|
| 84 |
+
|
| 85 |
+
# Test libm
|
| 86 |
+
|
| 87 |
+
# Make sure a simple build works
|
| 88 |
+
cargo check -p libm --no-default-features --target "$target"
|
| 89 |
+
|
| 90 |
+
if [ "${MAY_SKIP_LIBM_CI:-}" = "true" ]; then
|
| 91 |
+
echo "skipping libm PR CI"
|
| 92 |
+
exit
|
| 93 |
+
fi
|
| 94 |
+
|
| 95 |
+
mflags=()
|
| 96 |
+
|
| 97 |
+
# We enumerate features manually.
|
| 98 |
+
mflags+=(--no-default-features)
|
| 99 |
+
|
| 100 |
+
# Enable arch-specific routines when available.
|
| 101 |
+
mflags+=(--features arch)
|
| 102 |
+
|
| 103 |
+
# Always enable `unstable-float` since it expands available API but does not
|
| 104 |
+
# change any implementations.
|
| 105 |
+
mflags+=(--features unstable-float)
|
| 106 |
+
|
| 107 |
+
# We need to specifically skip tests for musl-math-sys on systems that can't
|
| 108 |
+
# build musl since otherwise `--all` will activate it.
|
| 109 |
+
case "$target" in
|
| 110 |
+
# Can't build at all on MSVC, WASM, or thumb
|
| 111 |
+
*windows-msvc*) mflags+=(--exclude musl-math-sys) ;;
|
| 112 |
+
*wasm*) mflags+=(--exclude musl-math-sys) ;;
|
| 113 |
+
*thumb*) mflags+=(--exclude musl-math-sys) ;;
|
| 114 |
+
|
| 115 |
+
# We can build musl on MinGW but running tests gets a stack overflow
|
| 116 |
+
*windows-gnu*) ;;
|
| 117 |
+
# FIXME(#309): LE PPC crashes calling the musl version of some functions. It
|
| 118 |
+
# seems like a qemu bug but should be investigated further at some point.
|
| 119 |
+
# See <https://github.com/rust-lang/libm/issues/309>.
|
| 120 |
+
*powerpc64le*) ;;
|
| 121 |
+
|
| 122 |
+
# Everything else gets musl enabled
|
| 123 |
+
*) mflags+=(--features libm-test/build-musl) ;;
|
| 124 |
+
esac
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
# Configure which targets test against MPFR
|
| 128 |
+
case "$target" in
|
| 129 |
+
# MSVC cannot link MPFR
|
| 130 |
+
*windows-msvc*) ;;
|
| 131 |
+
# FIXME: MinGW should be able to build MPFR, but setup in CI is nontrivial.
|
| 132 |
+
*windows-gnu*) ;;
|
| 133 |
+
# Targets that aren't cross compiled in CI work fine
|
| 134 |
+
aarch64*apple*) mflags+=(--features libm-test/build-mpfr) ;;
|
| 135 |
+
aarch64*linux*) mflags+=(--features libm-test/build-mpfr) ;;
|
| 136 |
+
i586*) mflags+=(--features libm-test/build-mpfr --features gmp-mpfr-sys/force-cross) ;;
|
| 137 |
+
i686*) mflags+=(--features libm-test/build-mpfr) ;;
|
| 138 |
+
x86_64*) mflags+=(--features libm-test/build-mpfr) ;;
|
| 139 |
+
esac
|
| 140 |
+
|
| 141 |
+
# FIXME: `STATUS_DLL_NOT_FOUND` testing macros on CI.
|
| 142 |
+
# <https://github.com/rust-lang/rust/issues/128944>
|
| 143 |
+
case "$target" in
|
| 144 |
+
*windows-gnu) mflags+=(--exclude libm-macros) ;;
|
| 145 |
+
esac
|
| 146 |
+
|
| 147 |
+
if [ "${BUILD_ONLY:-}" = "1" ]; then
|
| 148 |
+
# If we are on targets that can't run tests, verify that we can build.
|
| 149 |
+
cmd=(cargo build --target "$target" --package libm)
|
| 150 |
+
"${cmd[@]}"
|
| 151 |
+
"${cmd[@]}" --features unstable-intrinsics
|
| 152 |
+
|
| 153 |
+
echo "can't run tests on $target; skipping"
|
| 154 |
+
else
|
| 155 |
+
# symcheck tests need specific env setup, and is already tested above
|
| 156 |
+
mflags+=(--workspace --exclude symbol-check --target "$target")
|
| 157 |
+
cmd=(cargo test "${mflags[@]}")
|
| 158 |
+
profile_flag="--profile"
|
| 159 |
+
|
| 160 |
+
# If nextest is available, use that
|
| 161 |
+
command -v cargo-nextest && nextest=1 || nextest=0
|
| 162 |
+
if [ "$nextest" = "1" ]; then
|
| 163 |
+
cmd=(cargo nextest run --max-fail=10)
|
| 164 |
+
|
| 165 |
+
# Workaround for https://github.com/nextest-rs/nextest/issues/2066
|
| 166 |
+
if [ -f /.dockerenv ]; then
|
| 167 |
+
cfg_file="/tmp/nextest-config.toml"
|
| 168 |
+
echo "[store]" >> "$cfg_file"
|
| 169 |
+
echo "dir = \"$CARGO_TARGET_DIR/nextest\"" >> "$cfg_file"
|
| 170 |
+
cmd+=(--config-file "$cfg_file")
|
| 171 |
+
fi
|
| 172 |
+
|
| 173 |
+
# Not all configurations have tests to run on wasm
|
| 174 |
+
[[ "$target" = *"wasm"* ]] && cmd+=(--no-tests=warn)
|
| 175 |
+
|
| 176 |
+
cmd+=("${mflags[@]}")
|
| 177 |
+
profile_flag="--cargo-profile"
|
| 178 |
+
fi
|
| 179 |
+
|
| 180 |
+
# Test once without intrinsics
|
| 181 |
+
"${cmd[@]}"
|
| 182 |
+
|
| 183 |
+
# Run doctests if they were excluded by nextest
|
| 184 |
+
[ "$nextest" = "1" ] && cargo test --doc --exclude compiler_builtins "${mflags[@]}"
|
| 185 |
+
|
| 186 |
+
# Exclude the macros and utile crates from the rest of the tests to save CI
|
| 187 |
+
# runtime, they shouldn't have anything feature- or opt-level-dependent.
|
| 188 |
+
cmd+=(--exclude util --exclude libm-macros)
|
| 189 |
+
|
| 190 |
+
# Test once with intrinsics enabled
|
| 191 |
+
"${cmd[@]}" --features unstable-intrinsics
|
| 192 |
+
"${cmd[@]}" --features unstable-intrinsics --benches
|
| 193 |
+
|
| 194 |
+
# Test the same in release mode, which also increases coverage. Also ensure
|
| 195 |
+
# the soft float routines are checked.
|
| 196 |
+
"${cmd[@]}" "$profile_flag" release-checked
|
| 197 |
+
"${cmd[@]}" "$profile_flag" release-checked --features force-soft-floats
|
| 198 |
+
"${cmd[@]}" "$profile_flag" release-checked --features unstable-intrinsics
|
| 199 |
+
"${cmd[@]}" "$profile_flag" release-checked --features unstable-intrinsics --benches
|
| 200 |
+
|
| 201 |
+
# Ensure that the routines do not panic.
|
| 202 |
+
#
|
| 203 |
+
# `--tests` must be passed because no-panic is only enabled as a dev
|
| 204 |
+
# dependency. The `release-opt` profile must be used to enable LTO and a
|
| 205 |
+
# single CGU.
|
| 206 |
+
ENSURE_NO_PANIC=1 cargo build \
|
| 207 |
+
-p libm \
|
| 208 |
+
--target "$target" \
|
| 209 |
+
--no-default-features \
|
| 210 |
+
--features unstable-float \
|
| 211 |
+
--tests \
|
| 212 |
+
--profile release-opt
|
| 213 |
+
fi
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/ci/update-musl.sh
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# Download musl to a repository for `musl-math-sys`
|
| 3 |
+
|
| 4 |
+
set -eux
|
| 5 |
+
|
| 6 |
+
url=https://github.com/kraj/musl.git
|
| 7 |
+
ref=c47ad25ea3b484e10326f933e927c0bc8cded3da
|
| 8 |
+
dst=crates/musl-math-sys/musl
|
| 9 |
+
|
| 10 |
+
if ! [ -d "$dst" ]; then
|
| 11 |
+
git clone "$url" "$dst" --single-branch --depth=1000
|
| 12 |
+
fi
|
| 13 |
+
|
| 14 |
+
git -C "$dst" fetch "$url" --depth=1
|
| 15 |
+
git -C "$dst" checkout "$ref"
|
rust/.rustup/toolchains/stable-x86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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
All notable changes to this project will be documented in this file.
|
| 4 |
+
|
| 5 |
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
| 6 |
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
| 7 |
+
|
| 8 |
+
## [Unreleased]
|
| 9 |
+
|
| 10 |
+
## [0.1.160](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.159...compiler_builtins-v0.1.160) - 2025-05-29
|
| 11 |
+
|
| 12 |
+
### Other
|
| 13 |
+
|
| 14 |
+
- Change `compiler-builtins` to edition 2024
|
| 15 |
+
- Remove unneeded C symbols
|
| 16 |
+
- Reuse `libm`'s `Caat` and `CastFrom` in `compiler-builtins`
|
| 17 |
+
- Reuse `MinInt` and `Int` from `libm` in `compiler-builtins`
|
| 18 |
+
- Update `CmpResult` to use a pointer-sized return type
|
| 19 |
+
- Enable `__powitf2` on MSVC
|
| 20 |
+
- Fix `i256::MAX`
|
| 21 |
+
- Add a note saying why we use `frintx` rather than `frintn`
|
| 22 |
+
- Typo in README.md
|
| 23 |
+
- Clean up unused files
|
| 24 |
+
|
| 25 |
+
## [0.1.159](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.158...compiler_builtins-v0.1.159) - 2025-05-12
|
| 26 |
+
|
| 27 |
+
### Other
|
| 28 |
+
|
| 29 |
+
- Remove cfg(bootstrap)
|
| 30 |
+
|
| 31 |
+
## [0.1.158](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.157...compiler_builtins-v0.1.158) - 2025-05-06
|
| 32 |
+
|
| 33 |
+
### Other
|
| 34 |
+
|
| 35 |
+
- Require `target_has_atomic = "ptr"` for runtime feature detection
|
| 36 |
+
|
| 37 |
+
## [0.1.157](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.156...compiler_builtins-v0.1.157) - 2025-05-03
|
| 38 |
+
|
| 39 |
+
### Other
|
| 40 |
+
|
| 41 |
+
- Use runtime feature detection for fma routines on x86
|
| 42 |
+
|
| 43 |
+
## [0.1.156](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.155...compiler_builtins-v0.1.156) - 2025-04-21
|
| 44 |
+
|
| 45 |
+
### Other
|
| 46 |
+
|
| 47 |
+
- avr: Provide `abort()`
|
| 48 |
+
- Remove `unsafe` from `naked_asm!` blocks
|
| 49 |
+
- Enable icount benchmarks in CI
|
| 50 |
+
- Move builtins-test-intrinsics out of the workspace
|
| 51 |
+
- Run `cargo fmt` on all projects
|
| 52 |
+
- Flatten the `libm/libm` directory
|
| 53 |
+
- Update path to libm after the merge
|
| 54 |
+
|
| 55 |
+
## [0.1.155](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.154...compiler_builtins-v0.1.155) - 2025-04-17
|
| 56 |
+
|
| 57 |
+
### Other
|
| 58 |
+
|
| 59 |
+
- use `#[cfg(bootstrap)]` for rustc sync
|
| 60 |
+
- Replace the `bl!` macro with `asm_sym`
|
| 61 |
+
- __udivmod(h|q)i4
|
| 62 |
+
|
| 63 |
+
## [0.1.154](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.153...compiler_builtins-v0.1.154) - 2025-04-16
|
| 64 |
+
|
| 65 |
+
### Other
|
| 66 |
+
|
| 67 |
+
- turn #[naked] into an unsafe attribute
|
| 68 |
+
|
| 69 |
+
## [0.1.153](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.152...compiler_builtins-v0.1.153) - 2025-04-09
|
| 70 |
+
|
| 71 |
+
### Other
|
| 72 |
+
|
| 73 |
+
- Remove a mention of `force-soft-float` in `build.rs`
|
| 74 |
+
- Revert "Disable `f16` on AArch64 without the `neon` feature"
|
| 75 |
+
- Skip No More!
|
| 76 |
+
- avoid out-of-bounds accesses ([#799](https://github.com/rust-lang/compiler-builtins/pull/799))
|
| 77 |
+
|
| 78 |
+
## [0.1.152](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.151...compiler_builtins-v0.1.152) - 2025-03-20
|
| 79 |
+
|
| 80 |
+
### Other
|
| 81 |
+
|
| 82 |
+
- Remove use of `atomic_load_unordered` and undefined behaviour from `arm_linux.rs`
|
| 83 |
+
- Switch repository layout to use a virtual manifest
|
| 84 |
+
|
| 85 |
+
## [0.1.151](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.150...compiler_builtins-v0.1.151) - 2025-03-05
|
| 86 |
+
|
| 87 |
+
### Other
|
| 88 |
+
|
| 89 |
+
- Add cygwin support
|
| 90 |
+
- Enable `f16` for LoongArch ([#770](https://github.com/rust-lang/compiler-builtins/pull/770))
|
| 91 |
+
- Add __extendhfdf2 and add __truncdfhf2 test
|
| 92 |
+
- Remove outdated information from the readme
|
| 93 |
+
|
| 94 |
+
## [0.1.150](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.149...compiler_builtins-v0.1.150) - 2025-03-01
|
| 95 |
+
|
| 96 |
+
### Other
|
| 97 |
+
|
| 98 |
+
- Disable `f16` on AArch64 without the `neon` feature
|
| 99 |
+
- Update LLVM downloads to 20.1-2025-02-13
|
| 100 |
+
|
| 101 |
+
## [0.1.149](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.148...compiler_builtins-v0.1.149) - 2025-02-25
|
| 102 |
+
|
| 103 |
+
### Other
|
| 104 |
+
|
| 105 |
+
- Make a subset of `libm` symbols weakly available on all platforms
|
| 106 |
+
|
| 107 |
+
## [0.1.148](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.147...compiler_builtins-v0.1.148) - 2025-02-24
|
| 108 |
+
|
| 109 |
+
### Other
|
| 110 |
+
|
| 111 |
+
- Update the `libm` submodule
|
| 112 |
+
- Enable `f16` for MIPS
|
| 113 |
+
- Eliminate the use of `public_test_dep!` for a third time
|
| 114 |
+
|
| 115 |
+
## [0.1.147](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.146...compiler_builtins-v0.1.147) - 2025-02-19
|
| 116 |
+
|
| 117 |
+
### Other
|
| 118 |
+
|
| 119 |
+
- remove win64_128bit_abi_hack
|
| 120 |
+
|
| 121 |
+
## [0.1.146](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.145...compiler_builtins-v0.1.146) - 2025-02-06
|
| 122 |
+
|
| 123 |
+
### Other
|
| 124 |
+
|
| 125 |
+
- Expose erf{,c}{,f} from libm
|
| 126 |
+
|
| 127 |
+
## [0.1.145](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.144...compiler_builtins-v0.1.145) - 2025-02-04
|
| 128 |
+
|
| 129 |
+
### Other
|
| 130 |
+
|
| 131 |
+
- Revert "Eliminate the use of `public_test_dep!`"
|
| 132 |
+
- Indentation fix to please clippy
|
| 133 |
+
- Don't build out of line atomics support code for uefi
|
| 134 |
+
- Add a version to some FIXMEs that will be resolved in LLVM 20
|
| 135 |
+
- Remove use of the `start` feature
|
| 136 |
+
|
| 137 |
+
## [0.1.144](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.143...compiler_builtins-v0.1.144) - 2025-01-15
|
| 138 |
+
|
| 139 |
+
### Other
|
| 140 |
+
|
| 141 |
+
- Eliminate the use of `public_test_dep!`
|
| 142 |
+
|
| 143 |
+
## [0.1.143](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.142...compiler_builtins-v0.1.143) - 2025-01-15
|
| 144 |
+
|
| 145 |
+
### Other
|
| 146 |
+
|
| 147 |
+
- Use a C-safe return type for `__rust_[ui]128_*` overflowing intrinsics
|
| 148 |
+
|
| 149 |
+
## [0.1.142](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.141...compiler_builtins-v0.1.142) - 2025-01-07
|
| 150 |
+
|
| 151 |
+
### Other
|
| 152 |
+
|
| 153 |
+
- Account for optimization levels other than numbers
|
| 154 |
+
|
| 155 |
+
## [0.1.141](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.140...compiler_builtins-v0.1.141) - 2025-01-07
|
| 156 |
+
|
| 157 |
+
### Other
|
| 158 |
+
|
| 159 |
+
- Update the `libm` submodule
|
| 160 |
+
- Fix new `clippy::precedence` errors
|
| 161 |
+
- Rename `EXP_MAX` to `EXP_SAT`
|
| 162 |
+
- Shorten prefixes for float constants
|
| 163 |
+
|
| 164 |
+
## [0.1.140](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.139...compiler_builtins-v0.1.140) - 2024-12-26
|
| 165 |
+
|
| 166 |
+
### Other
|
| 167 |
+
|
| 168 |
+
- Disable f128 for amdgpu ([#737](https://github.com/rust-lang/compiler-builtins/pull/737))
|
| 169 |
+
- Fix a bug in `abs_diff`
|
| 170 |
+
- Disable `f16` on platforms that have recursion problems
|
| 171 |
+
|
| 172 |
+
## [0.1.139](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.138...compiler_builtins-v0.1.139) - 2024-11-03
|
| 173 |
+
|
| 174 |
+
### Other
|
| 175 |
+
|
| 176 |
+
- Remove incorrect `sparcv9` match pattern from `configure_f16_f128`
|
| 177 |
+
|
| 178 |
+
## [0.1.138](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.137...compiler_builtins-v0.1.138) - 2024-11-01
|
| 179 |
+
|
| 180 |
+
### Other
|
| 181 |
+
|
| 182 |
+
- Use `f16_enabled`/`f128_enabled` in `examples/intrinsics.rs` ([#724](https://github.com/rust-lang/compiler-builtins/pull/724))
|
| 183 |
+
- Disable `f16` for LoongArch64 ([#722](https://github.com/rust-lang/compiler-builtins/pull/722))
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/Cargo.toml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NOTE: Must be kept in sync with `../builtins-shim/Cargo.toml`.
|
| 2 |
+
#
|
| 3 |
+
# This manifest is actually used in-tree by rust-lang/rust,
|
| 4 |
+
# `../builtins-shim/Cargo.toml` is used by out-of-tree testing. See the other
|
| 5 |
+
# manifest for further details.
|
| 6 |
+
|
| 7 |
+
[package]
|
| 8 |
+
name = "compiler_builtins"
|
| 9 |
+
version = "0.1.160"
|
| 10 |
+
authors = [
|
| 11 |
+
"Alex Crichton <alex@alexcrichton.com>",
|
| 12 |
+
"Amanieu d'Antras <amanieu@gmail.com>",
|
| 13 |
+
"Jorge Aparicio <japaricious@gmail.com>",
|
| 14 |
+
"Trevor Gross <tg@trevorgross.com>",
|
| 15 |
+
]
|
| 16 |
+
description = "Compiler intrinsics used by the Rust compiler."
|
| 17 |
+
repository = "https://github.com/rust-lang/compiler-builtins"
|
| 18 |
+
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
|
| 19 |
+
edition = "2024"
|
| 20 |
+
publish = false
|
| 21 |
+
links = "compiler-rt"
|
| 22 |
+
|
| 23 |
+
[lib]
|
| 24 |
+
bench = false
|
| 25 |
+
doctest = false
|
| 26 |
+
test = false
|
| 27 |
+
# make sure this crate isn't included in public standard library docs
|
| 28 |
+
doc = false
|
| 29 |
+
|
| 30 |
+
[dependencies]
|
| 31 |
+
core = { path = "../../core", optional = true }
|
| 32 |
+
|
| 33 |
+
[build-dependencies]
|
| 34 |
+
cc = { version = "1.2", optional = true }
|
| 35 |
+
|
| 36 |
+
[features]
|
| 37 |
+
default = ["compiler-builtins"]
|
| 38 |
+
|
| 39 |
+
# Enable compilation of C code in compiler-rt, filling in some more optimized
|
| 40 |
+
# implementations and also filling in unimplemented intrinsics
|
| 41 |
+
c = ["dep:cc"]
|
| 42 |
+
|
| 43 |
+
# For implementations where there is both a generic version and a platform-
|
| 44 |
+
# specific version, use the generic version. This is meant to enable testing
|
| 45 |
+
# the generic versions on all platforms.
|
| 46 |
+
no-asm = []
|
| 47 |
+
|
| 48 |
+
# Flag this library as the unstable compiler-builtins lib
|
| 49 |
+
compiler-builtins = []
|
| 50 |
+
|
| 51 |
+
# Generate memory-related intrinsics like memcpy
|
| 52 |
+
mem = []
|
| 53 |
+
|
| 54 |
+
# Mangle all names so this can be linked in with other versions or other
|
| 55 |
+
# compiler-rt implementations. Also used for testing
|
| 56 |
+
mangled-names = []
|
| 57 |
+
|
| 58 |
+
# Only used in the compiler's build system
|
| 59 |
+
rustc-dep-of-std = ["compiler-builtins", "dep:core"]
|
| 60 |
+
|
| 61 |
+
# This makes certain traits and function specializations public that
|
| 62 |
+
# are not normally public but are required by the `builtins-test`
|
| 63 |
+
unstable-public-internals = []
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/README.md
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# `compiler-builtins`
|
| 2 |
+
|
| 3 |
+
This crate provides external symbols that the compiler expects to be available
|
| 4 |
+
when building Rust projects, typically software routines for basic operations
|
| 5 |
+
that do not have hardware support. It is largely a port of LLVM's
|
| 6 |
+
[`compiler-rt`].
|
| 7 |
+
|
| 8 |
+
It is distributed as part of Rust's sysroot. `compiler-builtins` does not need
|
| 9 |
+
to be added as an explicit dependency in `Cargo.toml`.
|
| 10 |
+
|
| 11 |
+
[`compiler-rt`]: https://github.com/llvm/llvm-project/tree/1b1dc505057322f4fa1110ef4f53c44347f52986/compiler-rt
|
| 12 |
+
|
| 13 |
+
## Configuration
|
| 14 |
+
|
| 15 |
+
`compiler-builtins` can be configured with the following environment variables when the `c` feature
|
| 16 |
+
is enabled:
|
| 17 |
+
|
| 18 |
+
- `LLVM_COMPILER_RT_LIB`
|
| 19 |
+
- `RUST_COMPILER_RT_ROOT`
|
| 20 |
+
|
| 21 |
+
See `build.rs` for details.
|
| 22 |
+
|
| 23 |
+
## Contributing
|
| 24 |
+
|
| 25 |
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
| 26 |
+
|
| 27 |
+
## Progress
|
| 28 |
+
|
| 29 |
+
- [x] aarch64/chkstk.S
|
| 30 |
+
- [x] adddf3.c
|
| 31 |
+
- [x] addsf3.c
|
| 32 |
+
- [x] arm/addsf3.S
|
| 33 |
+
- [x] arm/aeabi_dcmp.S
|
| 34 |
+
- [x] arm/aeabi_fcmp.S
|
| 35 |
+
- [x] arm/aeabi_idivmod.S
|
| 36 |
+
- [x] arm/aeabi_ldivmod.S
|
| 37 |
+
- [x] arm/aeabi_memcpy.S
|
| 38 |
+
- [x] arm/aeabi_memmove.S
|
| 39 |
+
- [x] arm/aeabi_memset.S
|
| 40 |
+
- [x] arm/aeabi_uidivmod.S
|
| 41 |
+
- [x] arm/aeabi_uldivmod.S
|
| 42 |
+
- [ ] arm/chkstk.S
|
| 43 |
+
- [ ] arm/divmodsi4.S (generic version is done)
|
| 44 |
+
- [ ] arm/divsi3.S (generic version is done)
|
| 45 |
+
- [ ] arm/modsi3.S (generic version is done)
|
| 46 |
+
- [x] arm/softfloat-alias.list
|
| 47 |
+
- [ ] arm/udivmodsi4.S (generic version is done)
|
| 48 |
+
- [ ] arm/udivsi3.S (generic version is done)
|
| 49 |
+
- [ ] arm/umodsi3.S (generic version is done)
|
| 50 |
+
- [x] ashldi3.c
|
| 51 |
+
- [x] ashrdi3.c
|
| 52 |
+
- [ ] avr/divmodhi4.S
|
| 53 |
+
- [ ] avr/divmodqi4.S
|
| 54 |
+
- [ ] avr/mulhi3.S
|
| 55 |
+
- [ ] avr/mulqi3.S
|
| 56 |
+
- [ ] avr/udivmodhi4.S
|
| 57 |
+
- [ ] avr/udivmodqi4.S
|
| 58 |
+
- [x] bswapdi2.c
|
| 59 |
+
- [x] bswapsi2.c
|
| 60 |
+
- [x] bswapti2.c
|
| 61 |
+
- [x] clzdi2.c
|
| 62 |
+
- [x] clzsi2.c
|
| 63 |
+
- [x] clzti2.c
|
| 64 |
+
- [x] comparedf2.c
|
| 65 |
+
- [x] comparesf2.c
|
| 66 |
+
- [x] ctzdi2.c
|
| 67 |
+
- [x] ctzsi2.c
|
| 68 |
+
- [x] ctzti2.c
|
| 69 |
+
- [x] divdf3.c
|
| 70 |
+
- [x] divdi3.c
|
| 71 |
+
- [x] divmoddi4.c
|
| 72 |
+
- [x] divmodsi4.c
|
| 73 |
+
- [x] divmodti4.c
|
| 74 |
+
- [x] divsf3.c
|
| 75 |
+
- [x] divsi3.c
|
| 76 |
+
- [x] extendsfdf2.c
|
| 77 |
+
- [x] fixdfdi.c
|
| 78 |
+
- [x] fixdfsi.c
|
| 79 |
+
- [x] fixsfdi.c
|
| 80 |
+
- [x] fixsfsi.c
|
| 81 |
+
- [x] fixunsdfdi.c
|
| 82 |
+
- [x] fixunsdfsi.c
|
| 83 |
+
- [x] fixunssfdi.c
|
| 84 |
+
- [x] fixunssfsi.c
|
| 85 |
+
- [x] floatdidf.c
|
| 86 |
+
- [x] floatdisf.c
|
| 87 |
+
- [x] floatsidf.c
|
| 88 |
+
- [x] floatsisf.c
|
| 89 |
+
- [x] floatundidf.c
|
| 90 |
+
- [x] floatundisf.c
|
| 91 |
+
- [x] floatunsidf.c
|
| 92 |
+
- [x] floatunsisf.c
|
| 93 |
+
- [ ] i386/ashldi3.S
|
| 94 |
+
- [ ] i386/ashrdi3.S
|
| 95 |
+
- [x] i386/chkstk.S
|
| 96 |
+
- [ ] i386/divdi3.S
|
| 97 |
+
- [ ] i386/lshrdi3.S
|
| 98 |
+
- [ ] i386/moddi3.S
|
| 99 |
+
- [ ] i386/muldi3.S
|
| 100 |
+
- [ ] i386/udivdi3.S
|
| 101 |
+
- [ ] i386/umoddi3.S
|
| 102 |
+
- [x] lshrdi3.c
|
| 103 |
+
- [x] moddi3.c
|
| 104 |
+
- [x] modsi3.c
|
| 105 |
+
- [x] muldf3.c
|
| 106 |
+
- [x] muldi3.c
|
| 107 |
+
- [x] mulodi4.c
|
| 108 |
+
- [x] mulosi4.c
|
| 109 |
+
- [x] mulsf3.c
|
| 110 |
+
- [x] powidf2.c
|
| 111 |
+
- [x] powisf2.c
|
| 112 |
+
- [ ] riscv/muldi3.S
|
| 113 |
+
- [ ] riscv/mulsi3.S
|
| 114 |
+
- [x] subdf3.c
|
| 115 |
+
- [x] subsf3.c
|
| 116 |
+
- [x] truncdfsf2.c
|
| 117 |
+
- [x] udivdi3.c
|
| 118 |
+
- [x] udivmoddi4.c
|
| 119 |
+
- [x] udivmodsi4.c
|
| 120 |
+
- [x] udivsi3.c
|
| 121 |
+
- [x] umoddi3.c
|
| 122 |
+
- [x] umodsi3.c
|
| 123 |
+
- [x] x86_64/chkstk.S
|
| 124 |
+
|
| 125 |
+
These builtins are needed to support 128-bit integers.
|
| 126 |
+
|
| 127 |
+
- [x] ashlti3.c
|
| 128 |
+
- [x] ashrti3.c
|
| 129 |
+
- [x] divti3.c
|
| 130 |
+
- [x] fixdfti.c
|
| 131 |
+
- [x] fixsfti.c
|
| 132 |
+
- [x] fixunsdfti.c
|
| 133 |
+
- [x] fixunssfti.c
|
| 134 |
+
- [x] floattidf.c
|
| 135 |
+
- [x] floattisf.c
|
| 136 |
+
- [x] floatuntidf.c
|
| 137 |
+
- [x] floatuntisf.c
|
| 138 |
+
- [x] lshrti3.c
|
| 139 |
+
- [x] modti3.c
|
| 140 |
+
- [x] muloti4.c
|
| 141 |
+
- [x] multi3.c
|
| 142 |
+
- [x] udivmodti4.c
|
| 143 |
+
- [x] udivti3.c
|
| 144 |
+
- [x] umodti3.c
|
| 145 |
+
|
| 146 |
+
These builtins are needed to support `f16` and `f128`, which are in the process
|
| 147 |
+
of being added to Rust.
|
| 148 |
+
|
| 149 |
+
- [x] addtf3.c
|
| 150 |
+
- [x] comparetf2.c
|
| 151 |
+
- [x] divtf3.c
|
| 152 |
+
- [x] extenddftf2.c
|
| 153 |
+
- [x] extendhfsf2.c
|
| 154 |
+
- [x] extendhftf2.c
|
| 155 |
+
- [x] extendsftf2.c
|
| 156 |
+
- [x] fixtfdi.c
|
| 157 |
+
- [x] fixtfsi.c
|
| 158 |
+
- [x] fixtfti.c
|
| 159 |
+
- [x] fixunstfdi.c
|
| 160 |
+
- [x] fixunstfsi.c
|
| 161 |
+
- [x] fixunstfti.c
|
| 162 |
+
- [x] floatditf.c
|
| 163 |
+
- [x] floatsitf.c
|
| 164 |
+
- [x] floattitf.c
|
| 165 |
+
- [x] floatunditf.c
|
| 166 |
+
- [x] floatunsitf.c
|
| 167 |
+
- [x] floatuntitf.c
|
| 168 |
+
- [x] multf3.c
|
| 169 |
+
- [x] powitf2.c
|
| 170 |
+
- [x] subtf3.c
|
| 171 |
+
- [x] truncdfhf2.c
|
| 172 |
+
- [x] truncsfhf2.c
|
| 173 |
+
- [x] trunctfdf2.c
|
| 174 |
+
- [x] trunctfhf2.c
|
| 175 |
+
- [x] trunctfsf2.c
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
These builtins are used by the Hexagon DSP
|
| 179 |
+
|
| 180 |
+
- [ ] hexagon/common_entry_exit_abi1.S
|
| 181 |
+
- [ ] hexagon/common_entry_exit_abi2.S
|
| 182 |
+
- [ ] hexagon/common_entry_exit_legacy.S
|
| 183 |
+
- [x] hexagon/dfaddsub.S~~
|
| 184 |
+
- [x] hexagon/dfdiv.S~~
|
| 185 |
+
- [x] hexagon/dffma.S~~
|
| 186 |
+
- [x] hexagon/dfminmax.S~~
|
| 187 |
+
- [x] hexagon/dfmul.S~~
|
| 188 |
+
- [x] hexagon/dfsqrt.S~~
|
| 189 |
+
- [x] hexagon/divdi3.S~~
|
| 190 |
+
- [x] hexagon/divsi3.S~~
|
| 191 |
+
- [x] hexagon/fastmath2_dlib_asm.S~~
|
| 192 |
+
- [x] hexagon/fastmath2_ldlib_asm.S~~
|
| 193 |
+
- [x] hexagon/fastmath_dlib_asm.S~~
|
| 194 |
+
- [x] hexagon/memcpy_forward_vp4cp4n2.S~~
|
| 195 |
+
- [x] hexagon/memcpy_likely_aligned.S~~
|
| 196 |
+
- [x] hexagon/moddi3.S~~
|
| 197 |
+
- [x] hexagon/modsi3.S~~
|
| 198 |
+
- [x] hexagon/sfdiv_opt.S~~
|
| 199 |
+
- [x] hexagon/sfsqrt_opt.S~~
|
| 200 |
+
- [x] hexagon/udivdi3.S~~
|
| 201 |
+
- [x] hexagon/udivmoddi4.S~~
|
| 202 |
+
- [x] hexagon/udivmodsi4.S~~
|
| 203 |
+
- [x] hexagon/udivsi3.S~~
|
| 204 |
+
- [x] hexagon/umoddi3.S~~
|
| 205 |
+
- [x] hexagon/umodsi3.S~~
|
| 206 |
+
|
| 207 |
+
## Unimplemented functions
|
| 208 |
+
|
| 209 |
+
These builtins are for x87 `f80` floating-point numbers that are not supported
|
| 210 |
+
by Rust.
|
| 211 |
+
|
| 212 |
+
- ~~extendxftf2.c~~
|
| 213 |
+
- ~~fixunsxfdi.c~~
|
| 214 |
+
- ~~fixunsxfsi.c~~
|
| 215 |
+
- ~~fixunsxfti.c~~
|
| 216 |
+
- ~~fixxfdi.c~~
|
| 217 |
+
- ~~fixxfti.c~~
|
| 218 |
+
- ~~floatdixf.c~~
|
| 219 |
+
- ~~floattixf.c~~
|
| 220 |
+
- ~~floatundixf.c~~
|
| 221 |
+
- ~~floatuntixf.c~~
|
| 222 |
+
- ~~i386/floatdixf.S~~
|
| 223 |
+
- ~~i386/floatundixf.S~~
|
| 224 |
+
- ~~x86_64/floatdixf.c~~
|
| 225 |
+
- ~~x86_64/floatundixf.S~~
|
| 226 |
+
|
| 227 |
+
These builtins are for IBM "extended double" non-IEEE 128-bit floating-point
|
| 228 |
+
numbers.
|
| 229 |
+
|
| 230 |
+
- ~~ppc/divtc3.c~~
|
| 231 |
+
- ~~ppc/fixtfdi.c~~
|
| 232 |
+
- ~~ppc/fixtfti.c~~
|
| 233 |
+
- ~~ppc/fixunstfdi.c~~
|
| 234 |
+
- ~~ppc/fixunstfti.c~~
|
| 235 |
+
- ~~ppc/floatditf.c~~
|
| 236 |
+
- ~~ppc/floattitf.c~~
|
| 237 |
+
- ~~ppc/floatunditf.c~~
|
| 238 |
+
- ~~ppc/gcc_qadd.c~~
|
| 239 |
+
- ~~ppc/gcc_qdiv.c~~
|
| 240 |
+
- ~~ppc/gcc_qmul.c~~
|
| 241 |
+
- ~~ppc/gcc_qsub.c~~
|
| 242 |
+
- ~~ppc/multc3.c~~
|
| 243 |
+
|
| 244 |
+
These builtins are for 16-bit brain floating-point numbers that are not
|
| 245 |
+
supported by Rust.
|
| 246 |
+
|
| 247 |
+
- ~~truncdfbf2.c~~
|
| 248 |
+
- ~~truncsfbf2.c~~
|
| 249 |
+
- ~~trunctfxf2.c~~
|
| 250 |
+
|
| 251 |
+
These builtins involve complex floating-point types that are not supported by
|
| 252 |
+
Rust.
|
| 253 |
+
|
| 254 |
+
- ~~divdc3.c~~
|
| 255 |
+
- ~~divsc3.c~~
|
| 256 |
+
- ~~divtc3.c~~
|
| 257 |
+
- ~~divxc3.c~~
|
| 258 |
+
- ~~muldc3.c~~
|
| 259 |
+
- ~~mulsc3.c~~
|
| 260 |
+
- ~~multc3.c~~
|
| 261 |
+
- ~~mulxc3.c~~
|
| 262 |
+
- ~~powixf2.c~~
|
| 263 |
+
|
| 264 |
+
These builtins are never called by LLVM.
|
| 265 |
+
|
| 266 |
+
- ~~absvdi2.c~~
|
| 267 |
+
- ~~absvsi2.c~~
|
| 268 |
+
- ~~absvti2.c~~
|
| 269 |
+
- ~~addvdi3.c~~
|
| 270 |
+
- ~~addvsi3.c~~
|
| 271 |
+
- ~~addvti3.c~~
|
| 272 |
+
- ~~arm/aeabi_cdcmp.S~~
|
| 273 |
+
- ~~arm/aeabi_cdcmpeq_check_nan.c~~
|
| 274 |
+
- ~~arm/aeabi_cfcmp.S~~
|
| 275 |
+
- ~~arm/aeabi_cfcmpeq_check_nan.c~~
|
| 276 |
+
- ~~arm/aeabi_div0.c~~
|
| 277 |
+
- ~~arm/aeabi_drsub.c~~
|
| 278 |
+
- ~~arm/aeabi_frsub.c~~
|
| 279 |
+
- ~~arm/aeabi_memcmp.S~~
|
| 280 |
+
- ~~arm/bswapdi2.S~~
|
| 281 |
+
- ~~arm/bswapsi2.S~~
|
| 282 |
+
- ~~arm/clzdi2.S~~
|
| 283 |
+
- ~~arm/clzsi2.S~~
|
| 284 |
+
- ~~arm/comparesf2.S~~
|
| 285 |
+
- ~~arm/restore_vfp_d8_d15_regs.S~~
|
| 286 |
+
- ~~arm/save_vfp_d8_d15_regs.S~~
|
| 287 |
+
- ~~arm/switch16.S~~
|
| 288 |
+
- ~~arm/switch32.S~~
|
| 289 |
+
- ~~arm/switch8.S~~
|
| 290 |
+
- ~~arm/switchu8.S~~
|
| 291 |
+
- ~~cmpdi2.c~~
|
| 292 |
+
- ~~cmpti2.c~~
|
| 293 |
+
- ~~ffssi2.c~~
|
| 294 |
+
- ~~ffsdi2.c~~ - this is [called by gcc][jemalloc-fail] though!
|
| 295 |
+
- ~~ffsti2.c~~
|
| 296 |
+
- ~~mulvdi3.c~~
|
| 297 |
+
- ~~mulvsi3.c~~
|
| 298 |
+
- ~~mulvti3.c~~
|
| 299 |
+
- ~~negdf2.c~~
|
| 300 |
+
- ~~negdi2.c~~
|
| 301 |
+
- ~~negsf2.c~~
|
| 302 |
+
- ~~negti2.c~~
|
| 303 |
+
- ~~negvdi2.c~~
|
| 304 |
+
- ~~negvsi2.c~~
|
| 305 |
+
- ~~negvti2.c~~
|
| 306 |
+
- ~~paritydi2.c~~
|
| 307 |
+
- ~~paritysi2.c~~
|
| 308 |
+
- ~~parityti2.c~~
|
| 309 |
+
- ~~popcountdi2.c~~
|
| 310 |
+
- ~~popcountsi2.c~~
|
| 311 |
+
- ~~popcountti2.c~~
|
| 312 |
+
- ~~ppc/restFP.S~~
|
| 313 |
+
- ~~ppc/saveFP.S~~
|
| 314 |
+
- ~~subvdi3.c~~
|
| 315 |
+
- ~~subvsi3.c~~
|
| 316 |
+
- ~~subvti3.c~~
|
| 317 |
+
- ~~ucmpdi2.c~~
|
| 318 |
+
- ~~ucmpti2.c~~
|
| 319 |
+
- ~~udivmodti4.c~~
|
| 320 |
+
|
| 321 |
+
[jemalloc-fail]: https://travis-ci.org/rust-lang/rust/jobs/249772758
|
| 322 |
+
|
| 323 |
+
Rust only exposes atomic types on platforms that support them, and therefore does not need to fall back to software implementations.
|
| 324 |
+
|
| 325 |
+
- ~~arm/sync_fetch_and_add_4.S~~
|
| 326 |
+
- ~~arm/sync_fetch_and_add_8.S~~
|
| 327 |
+
- ~~arm/sync_fetch_and_and_4.S~~
|
| 328 |
+
- ~~arm/sync_fetch_and_and_8.S~~
|
| 329 |
+
- ~~arm/sync_fetch_and_max_4.S~~
|
| 330 |
+
- ~~arm/sync_fetch_and_max_8.S~~
|
| 331 |
+
- ~~arm/sync_fetch_and_min_4.S~~
|
| 332 |
+
- ~~arm/sync_fetch_and_min_8.S~~
|
| 333 |
+
- ~~arm/sync_fetch_and_nand_4.S~~
|
| 334 |
+
- ~~arm/sync_fetch_and_nand_8.S~~
|
| 335 |
+
- ~~arm/sync_fetch_and_or_4.S~~
|
| 336 |
+
- ~~arm/sync_fetch_and_or_8.S~~
|
| 337 |
+
- ~~arm/sync_fetch_and_sub_4.S~~
|
| 338 |
+
- ~~arm/sync_fetch_and_sub_8.S~~
|
| 339 |
+
- ~~arm/sync_fetch_and_umax_4.S~~
|
| 340 |
+
- ~~arm/sync_fetch_and_umax_8.S~~
|
| 341 |
+
- ~~arm/sync_fetch_and_umin_4.S~~
|
| 342 |
+
- ~~arm/sync_fetch_and_umin_8.S~~
|
| 343 |
+
- ~~arm/sync_fetch_and_xor_4.S~~
|
| 344 |
+
- ~~arm/sync_fetch_and_xor_8.S~~
|
| 345 |
+
- ~~arm/sync_synchronize.S~~
|
| 346 |
+
- ~~atomic.c~~
|
| 347 |
+
- ~~atomic_flag_clear.c~~
|
| 348 |
+
- ~~atomic_flag_clear_explicit.c~~
|
| 349 |
+
- ~~atomic_flag_test_and_set.c~~
|
| 350 |
+
- ~~atomic_flag_test_and_set_explicit.c~~
|
| 351 |
+
- ~~atomic_signal_fence.c~~
|
| 352 |
+
- ~~atomic_thread_fence.c~~
|
| 353 |
+
|
| 354 |
+
Miscellaneous functionality that is not used by Rust.
|
| 355 |
+
|
| 356 |
+
- ~~aarch64/fp_mode.c~~
|
| 357 |
+
- ~~aarch64/lse.S~~ (LSE atomics)
|
| 358 |
+
- ~~aarch64/sme-abi-init.c~~ (matrix extension)
|
| 359 |
+
- ~~aarch64/sme-abi.S~~ (matrix extension)
|
| 360 |
+
- ~~aarch64/sme-libc-routines.c~~ (matrix extension)
|
| 361 |
+
- ~~apple_versioning.c~~
|
| 362 |
+
- ~~arm/fp_mode.c~~
|
| 363 |
+
- ~~avr/exit.S~~
|
| 364 |
+
- ~~clear_cache.c~~
|
| 365 |
+
- ~~cpu_model/aarch64.c~~
|
| 366 |
+
- ~~cpu_model/x86.c~~
|
| 367 |
+
- ~~crtbegin.c~~
|
| 368 |
+
- ~~crtend.c~~
|
| 369 |
+
- ~~emutls.c~~
|
| 370 |
+
- ~~enable_execute_stack.c~~
|
| 371 |
+
- ~~eprintf.c~~
|
| 372 |
+
- ~~fp_mode.c~~ (float exception handling)
|
| 373 |
+
- ~~gcc_personality_v0.c~~
|
| 374 |
+
- ~~i386/fp_mode.c~~
|
| 375 |
+
- ~~int_util.c~~
|
| 376 |
+
- ~~loongarch/fp_mode.c~~
|
| 377 |
+
- ~~os_version_check.c~~ (implemented in `std` instead)
|
| 378 |
+
- ~~riscv/fp_mode.c~~
|
| 379 |
+
- ~~riscv/restore.S~~ (callee-saved registers)
|
| 380 |
+
- ~~riscv/save.S~~ (callee-saved registers)
|
| 381 |
+
- ~~trampoline_setup.c~~
|
| 382 |
+
- ~~ve/grow_stack.S~~
|
| 383 |
+
- ~~ve/grow_stack_align.S~~
|
| 384 |
+
|
| 385 |
+
Floating-point implementations of builtins that are only called from soft-float code. It would be better to simply use the generic soft-float versions in this case.
|
| 386 |
+
|
| 387 |
+
- ~~i386/floatdidf.S~~
|
| 388 |
+
- ~~i386/floatdisf.S~~
|
| 389 |
+
- ~~i386/floatundidf.S~~
|
| 390 |
+
- ~~i386/floatundisf.S~~
|
| 391 |
+
- ~~x86_64/floatundidf.S~~
|
| 392 |
+
- ~~x86_64/floatundisf.S~~
|
| 393 |
+
- ~~x86_64/floatdidf.c~~
|
| 394 |
+
- ~~x86_64/floatdisf.c~~
|
| 395 |
+
|
| 396 |
+
Unsupported in any current target: used on old versions of 32-bit iOS with ARMv5.
|
| 397 |
+
|
| 398 |
+
- ~~arm/adddf3vfp.S~~
|
| 399 |
+
- ~~arm/addsf3vfp.S~~
|
| 400 |
+
- ~~arm/divdf3vfp.S~~
|
| 401 |
+
- ~~arm/divsf3vfp.S~~
|
| 402 |
+
- ~~arm/eqdf2vfp.S~~
|
| 403 |
+
- ~~arm/eqsf2vfp.S~~
|
| 404 |
+
- ~~arm/extendsfdf2vfp.S~~
|
| 405 |
+
- ~~arm/fixdfsivfp.S~~
|
| 406 |
+
- ~~arm/fixsfsivfp.S~~
|
| 407 |
+
- ~~arm/fixunsdfsivfp.S~~
|
| 408 |
+
- ~~arm/fixunssfsivfp.S~~
|
| 409 |
+
- ~~arm/floatsidfvfp.S~~
|
| 410 |
+
- ~~arm/floatsisfvfp.S~~
|
| 411 |
+
- ~~arm/floatunssidfvfp.S~~
|
| 412 |
+
- ~~arm/floatunssisfvfp.S~~
|
| 413 |
+
- ~~arm/gedf2vfp.S~~
|
| 414 |
+
- ~~arm/gesf2vfp.S~~
|
| 415 |
+
- ~~arm/gtdf2vfp.S~~
|
| 416 |
+
- ~~arm/gtsf2vfp.S~~
|
| 417 |
+
- ~~arm/ledf2vfp.S~~
|
| 418 |
+
- ~~arm/lesf2vfp.S~~
|
| 419 |
+
- ~~arm/ltdf2vfp.S~~
|
| 420 |
+
- ~~arm/ltsf2vfp.S~~
|
| 421 |
+
- ~~arm/muldf3vfp.S~~
|
| 422 |
+
- ~~arm/mulsf3vfp.S~~
|
| 423 |
+
- ~~arm/nedf2vfp.S~~
|
| 424 |
+
- ~~arm/negdf2vfp.S~~
|
| 425 |
+
- ~~arm/negsf2vfp.S~~
|
| 426 |
+
- ~~arm/nesf2vfp.S~~
|
| 427 |
+
- ~~arm/subdf3vfp.S~~
|
| 428 |
+
- ~~arm/subsf3vfp.S~~
|
| 429 |
+
- ~~arm/truncdfsf2vfp.S~~
|
| 430 |
+
- ~~arm/unorddf2vfp.S~~
|
| 431 |
+
- ~~arm/unordsf2vfp.S~~
|
| 432 |
+
|
| 433 |
+
## License
|
| 434 |
+
|
| 435 |
+
Usage is allowed under the [MIT License] and the [Apache License, Version 2.0]
|
| 436 |
+
with the LLVM exception.
|
| 437 |
+
|
| 438 |
+
[MIT License]: https://opensource.org/license/mit
|
| 439 |
+
[Apache License, Version 2.0]: htps://www.apache.org/licenses/LICENSE-2.0
|
| 440 |
+
|
| 441 |
+
### Contribution
|
| 442 |
+
|
| 443 |
+
Contributions are licensed under the MIT License, the Apache License,
|
| 444 |
+
Version 2.0, and the Apache-2.0 license with the LLVM exception.
|
| 445 |
+
|
| 446 |
+
See [LICENSE.txt](../LICENSE.txt) for full details.
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/build.rs
ADDED
|
@@ -0,0 +1,679 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mod configure;
|
| 2 |
+
|
| 3 |
+
use std::env;
|
| 4 |
+
|
| 5 |
+
use configure::{Target, configure_aliases};
|
| 6 |
+
|
| 7 |
+
fn main() {
|
| 8 |
+
println!("cargo::rerun-if-changed=build.rs");
|
| 9 |
+
println!("cargo::rerun-if-changed=configure.rs");
|
| 10 |
+
|
| 11 |
+
let target = Target::from_env();
|
| 12 |
+
let cwd = env::current_dir().unwrap();
|
| 13 |
+
|
| 14 |
+
configure_check_cfg();
|
| 15 |
+
configure_aliases(&target);
|
| 16 |
+
|
| 17 |
+
configure_libm(&target);
|
| 18 |
+
|
| 19 |
+
println!("cargo:compiler-rt={}", cwd.join("compiler-rt").display());
|
| 20 |
+
|
| 21 |
+
println!("cargo::rustc-check-cfg=cfg(kernel_user_helpers)");
|
| 22 |
+
println!("cargo::rustc-check-cfg=cfg(feature, values(\"mem-unaligned\"))");
|
| 23 |
+
|
| 24 |
+
// Emscripten's runtime includes all the builtins
|
| 25 |
+
if target.os == "emscripten" {
|
| 26 |
+
return;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
// OpenBSD provides compiler_rt by default, use it instead of rebuilding it from source
|
| 30 |
+
if target.os == "openbsd" {
|
| 31 |
+
println!("cargo:rustc-link-search=native=/usr/lib");
|
| 32 |
+
println!("cargo:rustc-link-lib=compiler_rt");
|
| 33 |
+
return;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
// Forcibly enable memory intrinsics on wasm & SGX as we don't have a libc to
|
| 37 |
+
// provide them.
|
| 38 |
+
if (target.triple.contains("wasm") && !target.triple.contains("wasi"))
|
| 39 |
+
|| (target.triple.contains("sgx") && target.triple.contains("fortanix"))
|
| 40 |
+
|| target.triple.contains("-none")
|
| 41 |
+
|| target.triple.contains("nvptx")
|
| 42 |
+
|| target.triple.contains("uefi")
|
| 43 |
+
|| target.triple.contains("xous")
|
| 44 |
+
{
|
| 45 |
+
println!("cargo:rustc-cfg=feature=\"mem\"");
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// These targets have hardware unaligned access support.
|
| 49 |
+
if target.arch.contains("x86_64")
|
| 50 |
+
|| target.arch.contains("x86")
|
| 51 |
+
|| target.arch.contains("aarch64")
|
| 52 |
+
|| target.arch.contains("bpf")
|
| 53 |
+
{
|
| 54 |
+
println!("cargo:rustc-cfg=feature=\"mem-unaligned\"");
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// NOTE we are going to assume that llvm-target, what determines our codegen option, matches the
|
| 58 |
+
// target triple. This is usually correct for our built-in targets but can break in presence of
|
| 59 |
+
// custom targets, which can have arbitrary names.
|
| 60 |
+
let llvm_target = target.triple.split('-').collect::<Vec<_>>();
|
| 61 |
+
|
| 62 |
+
// Build missing intrinsics from compiler-rt C source code. If we're
|
| 63 |
+
// mangling names though we assume that we're also in test mode so we don't
|
| 64 |
+
// build anything and we rely on the upstream implementation of compiler-rt
|
| 65 |
+
// functions
|
| 66 |
+
if !cfg!(feature = "mangled-names") && cfg!(feature = "c") {
|
| 67 |
+
// Don't use a C compiler for these targets:
|
| 68 |
+
//
|
| 69 |
+
// * nvptx - everything is bitcode, not compatible with mixed C/Rust
|
| 70 |
+
if !target.arch.contains("nvptx") {
|
| 71 |
+
#[cfg(feature = "c")]
|
| 72 |
+
c::compile(&llvm_target, &target);
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
// Only emit the ARM Linux atomic emulation on pre-ARMv6 architectures. This
|
| 77 |
+
// includes the old androideabi. It is deprecated but it is available as a
|
| 78 |
+
// rustc target (arm-linux-androideabi).
|
| 79 |
+
if llvm_target[0] == "armv4t"
|
| 80 |
+
|| llvm_target[0] == "armv5te"
|
| 81 |
+
|| target.triple == "arm-linux-androideabi"
|
| 82 |
+
{
|
| 83 |
+
println!("cargo:rustc-cfg=kernel_user_helpers")
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/// Run configuration for `libm` since it is included directly.
|
| 88 |
+
///
|
| 89 |
+
/// Much of this is copied from `libm/configure.rs`.
|
| 90 |
+
fn configure_libm(target: &Target) {
|
| 91 |
+
println!("cargo:rustc-check-cfg=cfg(intrinsics_enabled)");
|
| 92 |
+
println!("cargo:rustc-check-cfg=cfg(arch_enabled)");
|
| 93 |
+
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
|
| 94 |
+
println!("cargo:rustc-check-cfg=cfg(feature, values(\"unstable-public-internals\"))");
|
| 95 |
+
|
| 96 |
+
// Always use intrinsics
|
| 97 |
+
println!("cargo:rustc-cfg=intrinsics_enabled");
|
| 98 |
+
|
| 99 |
+
// The arch module may contain assembly.
|
| 100 |
+
if !cfg!(feature = "no-asm") {
|
| 101 |
+
println!("cargo:rustc-cfg=arch_enabled");
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
|
| 105 |
+
if !matches!(target.opt_level.as_str(), "0" | "1") {
|
| 106 |
+
println!("cargo:rustc-cfg=optimizations_enabled");
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
println!(
|
| 110 |
+
"cargo:rustc-env=CFG_CARGO_FEATURES={:?}",
|
| 111 |
+
target.cargo_features
|
| 112 |
+
);
|
| 113 |
+
println!("cargo:rustc-env=CFG_OPT_LEVEL={}", target.opt_level);
|
| 114 |
+
println!("cargo:rustc-env=CFG_TARGET_FEATURES={:?}", target.features);
|
| 115 |
+
|
| 116 |
+
// Activate libm's unstable features to make full use of Nightly.
|
| 117 |
+
println!("cargo:rustc-cfg=feature=\"unstable-intrinsics\"");
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/// Emit directives for features we expect to support that aren't in `Cargo.toml`.
|
| 121 |
+
///
|
| 122 |
+
/// These are mostly cfg elements emitted by this `build.rs`.
|
| 123 |
+
fn configure_check_cfg() {
|
| 124 |
+
// Functions where we can set the "optimized-c" flag
|
| 125 |
+
const HAS_OPTIMIZED_C: &[&str] = &[
|
| 126 |
+
"__ashldi3",
|
| 127 |
+
"__ashlsi3",
|
| 128 |
+
"__ashrdi3",
|
| 129 |
+
"__ashrsi3",
|
| 130 |
+
"__bswapsi2",
|
| 131 |
+
"__bswapdi2",
|
| 132 |
+
"__bswapti2",
|
| 133 |
+
"__divdi3",
|
| 134 |
+
"__divsi3",
|
| 135 |
+
"__divmoddi4",
|
| 136 |
+
"__divmodsi4",
|
| 137 |
+
"__divmodsi4",
|
| 138 |
+
"__divmodti4",
|
| 139 |
+
"__lshrdi3",
|
| 140 |
+
"__lshrsi3",
|
| 141 |
+
"__moddi3",
|
| 142 |
+
"__modsi3",
|
| 143 |
+
"__muldi3",
|
| 144 |
+
"__udivdi3",
|
| 145 |
+
"__udivmoddi4",
|
| 146 |
+
"__udivmodsi4",
|
| 147 |
+
"__udivsi3",
|
| 148 |
+
"__umoddi3",
|
| 149 |
+
"__umodsi3",
|
| 150 |
+
];
|
| 151 |
+
|
| 152 |
+
// Build a list of all aarch64 atomic operation functions
|
| 153 |
+
let mut aarch_atomic = Vec::new();
|
| 154 |
+
for aarch_op in ["cas", "ldadd", "ldclr", "ldeor", "ldset", "swp"] {
|
| 155 |
+
let op_sizes = if aarch_op == "cas" {
|
| 156 |
+
[1, 2, 4, 8, 16].as_slice()
|
| 157 |
+
} else {
|
| 158 |
+
[1, 2, 4, 8].as_slice()
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
for op_size in op_sizes {
|
| 162 |
+
for ordering in ["relax", "acq", "rel", "acq_rel"] {
|
| 163 |
+
aarch_atomic.push(format!("__aarch64_{aarch_op}{op_size}_{ordering}"));
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
for fn_name in HAS_OPTIMIZED_C
|
| 169 |
+
.iter()
|
| 170 |
+
.copied()
|
| 171 |
+
.chain(aarch_atomic.iter().map(|s| s.as_str()))
|
| 172 |
+
{
|
| 173 |
+
println!("cargo::rustc-check-cfg=cfg({fn_name}, values(\"optimized-c\"))",);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
// Rustc is unaware of sparc target features, but this does show up from
|
| 177 |
+
// `rustc --print target-features --target sparc64-unknown-linux-gnu`.
|
| 178 |
+
println!("cargo::rustc-check-cfg=cfg(target_feature, values(\"vis3\"))");
|
| 179 |
+
|
| 180 |
+
// FIXME: these come from libm and should be changed there
|
| 181 |
+
println!("cargo::rustc-check-cfg=cfg(feature, values(\"checked\"))");
|
| 182 |
+
println!("cargo::rustc-check-cfg=cfg(assert_no_panic)");
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
#[cfg(feature = "c")]
|
| 186 |
+
mod c {
|
| 187 |
+
use std::collections::{BTreeMap, HashSet};
|
| 188 |
+
use std::env;
|
| 189 |
+
use std::fs::{self, File};
|
| 190 |
+
use std::io::Write;
|
| 191 |
+
use std::path::{Path, PathBuf};
|
| 192 |
+
|
| 193 |
+
use super::Target;
|
| 194 |
+
|
| 195 |
+
struct Sources {
|
| 196 |
+
// SYMBOL -> PATH TO SOURCE
|
| 197 |
+
map: BTreeMap<&'static str, &'static str>,
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
impl Sources {
|
| 201 |
+
fn new() -> Sources {
|
| 202 |
+
Sources {
|
| 203 |
+
map: BTreeMap::new(),
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
fn extend(&mut self, sources: &[(&'static str, &'static str)]) {
|
| 208 |
+
// NOTE Some intrinsics have both a generic implementation (e.g.
|
| 209 |
+
// `floatdidf.c`) and an arch optimized implementation
|
| 210 |
+
// (`x86_64/floatdidf.c`). In those cases, we keep the arch optimized
|
| 211 |
+
// implementation and discard the generic implementation. If we don't
|
| 212 |
+
// and keep both implementations, the linker will yell at us about
|
| 213 |
+
// duplicate symbols!
|
| 214 |
+
for (symbol, src) in sources {
|
| 215 |
+
if src.contains("/") {
|
| 216 |
+
// Arch-optimized implementation (preferred)
|
| 217 |
+
self.map.insert(symbol, src);
|
| 218 |
+
} else {
|
| 219 |
+
// Generic implementation
|
| 220 |
+
if !self.map.contains_key(symbol) {
|
| 221 |
+
self.map.insert(symbol, src);
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
fn remove(&mut self, symbols: &[&str]) {
|
| 228 |
+
for symbol in symbols {
|
| 229 |
+
self.map.remove(*symbol).unwrap();
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
/// Compile intrinsics from the compiler-rt C source code
|
| 235 |
+
pub fn compile(llvm_target: &[&str], target: &Target) {
|
| 236 |
+
let mut consider_float_intrinsics = true;
|
| 237 |
+
let cfg = &mut cc::Build::new();
|
| 238 |
+
|
| 239 |
+
// AArch64 GCCs exit with an error condition when they encounter any kind of floating point
|
| 240 |
+
// code if the `nofp` and/or `nosimd` compiler flags have been set.
|
| 241 |
+
//
|
| 242 |
+
// Therefore, evaluate if those flags are present and set a boolean that causes any
|
| 243 |
+
// compiler-rt intrinsics that contain floating point source to be excluded for this target.
|
| 244 |
+
if target.arch == "aarch64" {
|
| 245 |
+
let cflags_key = String::from("CFLAGS_") + &(target.triple.replace("-", "_"));
|
| 246 |
+
if let Ok(cflags_value) = env::var(cflags_key) {
|
| 247 |
+
if cflags_value.contains("+nofp") || cflags_value.contains("+nosimd") {
|
| 248 |
+
consider_float_intrinsics = false;
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
// `compiler-rt` requires `COMPILER_RT_HAS_FLOAT16` to be defined to make it use the
|
| 254 |
+
// `_Float16` type for `f16` intrinsics. This shouldn't matter as all existing `f16`
|
| 255 |
+
// intrinsics have been ported to Rust in `compiler-builtins` as C compilers don't
|
| 256 |
+
// support `_Float16` on all targets (whereas Rust does). However, define the macro
|
| 257 |
+
// anyway to prevent issues like rust#118813 and rust#123885 silently reoccuring if more
|
| 258 |
+
// `f16` intrinsics get accidentally added here in the future.
|
| 259 |
+
cfg.define("COMPILER_RT_HAS_FLOAT16", None);
|
| 260 |
+
|
| 261 |
+
cfg.warnings(false);
|
| 262 |
+
|
| 263 |
+
if target.env == "msvc" {
|
| 264 |
+
// Don't pull in extra libraries on MSVC
|
| 265 |
+
cfg.flag("/Zl");
|
| 266 |
+
|
| 267 |
+
// Emulate C99 and C++11's __func__ for MSVC prior to 2013 CTP
|
| 268 |
+
cfg.define("__func__", Some("__FUNCTION__"));
|
| 269 |
+
} else {
|
| 270 |
+
// Turn off various features of gcc and such, mostly copying
|
| 271 |
+
// compiler-rt's build system already
|
| 272 |
+
cfg.flag("-fno-builtin");
|
| 273 |
+
cfg.flag("-fvisibility=hidden");
|
| 274 |
+
cfg.flag("-ffreestanding");
|
| 275 |
+
// Avoid the following warning appearing once **per file**:
|
| 276 |
+
// clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7' [-Wignored-optimization-argument]
|
| 277 |
+
//
|
| 278 |
+
// Note that compiler-rt's build system also checks
|
| 279 |
+
//
|
| 280 |
+
// `check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG)`
|
| 281 |
+
//
|
| 282 |
+
// in https://github.com/rust-lang/compiler-rt/blob/c8fbcb3/cmake/config-ix.cmake#L19.
|
| 283 |
+
cfg.flag_if_supported("-fomit-frame-pointer");
|
| 284 |
+
cfg.define("VISIBILITY_HIDDEN", None);
|
| 285 |
+
|
| 286 |
+
if let "aarch64" | "arm64ec" = target.arch.as_str() {
|
| 287 |
+
// FIXME(llvm20): Older GCCs on A64 fail to build with
|
| 288 |
+
// -Werror=implicit-function-declaration due to a compiler-rt bug.
|
| 289 |
+
// With a newer LLVM we should be able to enable the flag everywhere.
|
| 290 |
+
// https://github.com/llvm/llvm-project/commit/8aa9d6206ce55bdaaf422839c351fbd63f033b89
|
| 291 |
+
} else {
|
| 292 |
+
// Avoid implicitly creating references to undefined functions
|
| 293 |
+
cfg.flag("-Werror=implicit-function-declaration");
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
// int_util.c tries to include stdlib.h if `_WIN32` is defined,
|
| 298 |
+
// which it is when compiling UEFI targets with clang. This is
|
| 299 |
+
// at odds with compiling with `-ffreestanding`, as the header
|
| 300 |
+
// may be incompatible or not present. Create a minimal stub
|
| 301 |
+
// header to use instead.
|
| 302 |
+
if target.os == "uefi" {
|
| 303 |
+
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
| 304 |
+
let include_dir = out_dir.join("include");
|
| 305 |
+
if !include_dir.exists() {
|
| 306 |
+
fs::create_dir(&include_dir).unwrap();
|
| 307 |
+
}
|
| 308 |
+
fs::write(include_dir.join("stdlib.h"), "#include <stddef.h>").unwrap();
|
| 309 |
+
cfg.flag(&format!("-I{}", include_dir.to_str().unwrap()));
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
let mut sources = Sources::new();
|
| 313 |
+
sources.extend(&[
|
| 314 |
+
("__absvdi2", "absvdi2.c"),
|
| 315 |
+
("__absvsi2", "absvsi2.c"),
|
| 316 |
+
("__addvdi3", "addvdi3.c"),
|
| 317 |
+
("__addvsi3", "addvsi3.c"),
|
| 318 |
+
("__cmpdi2", "cmpdi2.c"),
|
| 319 |
+
("__int_util", "int_util.c"),
|
| 320 |
+
("__mulvdi3", "mulvdi3.c"),
|
| 321 |
+
("__mulvsi3", "mulvsi3.c"),
|
| 322 |
+
("__negdi2", "negdi2.c"),
|
| 323 |
+
("__negvdi2", "negvdi2.c"),
|
| 324 |
+
("__negvsi2", "negvsi2.c"),
|
| 325 |
+
("__paritydi2", "paritydi2.c"),
|
| 326 |
+
("__paritysi2", "paritysi2.c"),
|
| 327 |
+
("__popcountdi2", "popcountdi2.c"),
|
| 328 |
+
("__popcountsi2", "popcountsi2.c"),
|
| 329 |
+
("__subvdi3", "subvdi3.c"),
|
| 330 |
+
("__subvsi3", "subvsi3.c"),
|
| 331 |
+
("__ucmpdi2", "ucmpdi2.c"),
|
| 332 |
+
]);
|
| 333 |
+
|
| 334 |
+
if consider_float_intrinsics {
|
| 335 |
+
sources.extend(&[
|
| 336 |
+
("__divdc3", "divdc3.c"),
|
| 337 |
+
("__divsc3", "divsc3.c"),
|
| 338 |
+
("__muldc3", "muldc3.c"),
|
| 339 |
+
("__mulsc3", "mulsc3.c"),
|
| 340 |
+
("__negdf2", "negdf2.c"),
|
| 341 |
+
("__negsf2", "negsf2.c"),
|
| 342 |
+
]);
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
// On iOS and 32-bit OSX these are all just empty intrinsics, no need to
|
| 346 |
+
// include them.
|
| 347 |
+
if target.vendor != "apple" || target.arch != "x86" {
|
| 348 |
+
sources.extend(&[
|
| 349 |
+
("__absvti2", "absvti2.c"),
|
| 350 |
+
("__addvti3", "addvti3.c"),
|
| 351 |
+
("__cmpti2", "cmpti2.c"),
|
| 352 |
+
("__ffsti2", "ffsti2.c"),
|
| 353 |
+
("__mulvti3", "mulvti3.c"),
|
| 354 |
+
("__negti2", "negti2.c"),
|
| 355 |
+
("__parityti2", "parityti2.c"),
|
| 356 |
+
("__popcountti2", "popcountti2.c"),
|
| 357 |
+
("__subvti3", "subvti3.c"),
|
| 358 |
+
("__ucmpti2", "ucmpti2.c"),
|
| 359 |
+
]);
|
| 360 |
+
|
| 361 |
+
if consider_float_intrinsics {
|
| 362 |
+
sources.extend(&[("__negvti2", "negvti2.c")]);
|
| 363 |
+
}
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
if target.vendor == "apple" {
|
| 367 |
+
sources.extend(&[
|
| 368 |
+
("atomic_flag_clear", "atomic_flag_clear.c"),
|
| 369 |
+
("atomic_flag_clear_explicit", "atomic_flag_clear_explicit.c"),
|
| 370 |
+
("atomic_flag_test_and_set", "atomic_flag_test_and_set.c"),
|
| 371 |
+
(
|
| 372 |
+
"atomic_flag_test_and_set_explicit",
|
| 373 |
+
"atomic_flag_test_and_set_explicit.c",
|
| 374 |
+
),
|
| 375 |
+
("atomic_signal_fence", "atomic_signal_fence.c"),
|
| 376 |
+
("atomic_thread_fence", "atomic_thread_fence.c"),
|
| 377 |
+
]);
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
if target.env != "msvc" {
|
| 381 |
+
if target.arch == "x86" {
|
| 382 |
+
sources.extend(&[
|
| 383 |
+
("__ashldi3", "i386/ashldi3.S"),
|
| 384 |
+
("__ashrdi3", "i386/ashrdi3.S"),
|
| 385 |
+
("__divdi3", "i386/divdi3.S"),
|
| 386 |
+
("__lshrdi3", "i386/lshrdi3.S"),
|
| 387 |
+
("__moddi3", "i386/moddi3.S"),
|
| 388 |
+
("__muldi3", "i386/muldi3.S"),
|
| 389 |
+
("__udivdi3", "i386/udivdi3.S"),
|
| 390 |
+
("__umoddi3", "i386/umoddi3.S"),
|
| 391 |
+
]);
|
| 392 |
+
}
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
if target.arch == "arm" && target.vendor != "apple" && target.env != "msvc" {
|
| 396 |
+
sources.extend(&[
|
| 397 |
+
("__aeabi_div0", "arm/aeabi_div0.c"),
|
| 398 |
+
("__aeabi_drsub", "arm/aeabi_drsub.c"),
|
| 399 |
+
("__aeabi_frsub", "arm/aeabi_frsub.c"),
|
| 400 |
+
("__bswapdi2", "arm/bswapdi2.S"),
|
| 401 |
+
("__bswapsi2", "arm/bswapsi2.S"),
|
| 402 |
+
("__divmodsi4", "arm/divmodsi4.S"),
|
| 403 |
+
("__divsi3", "arm/divsi3.S"),
|
| 404 |
+
("__modsi3", "arm/modsi3.S"),
|
| 405 |
+
("__switch16", "arm/switch16.S"),
|
| 406 |
+
("__switch32", "arm/switch32.S"),
|
| 407 |
+
("__switch8", "arm/switch8.S"),
|
| 408 |
+
("__switchu8", "arm/switchu8.S"),
|
| 409 |
+
("__sync_synchronize", "arm/sync_synchronize.S"),
|
| 410 |
+
("__udivmodsi4", "arm/udivmodsi4.S"),
|
| 411 |
+
("__udivsi3", "arm/udivsi3.S"),
|
| 412 |
+
("__umodsi3", "arm/umodsi3.S"),
|
| 413 |
+
]);
|
| 414 |
+
|
| 415 |
+
if target.os == "freebsd" {
|
| 416 |
+
sources.extend(&[("__clear_cache", "clear_cache.c")]);
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
// First of all aeabi_cdcmp and aeabi_cfcmp are never called by LLVM.
|
| 420 |
+
// Second are little-endian only, so build fail on big-endian targets.
|
| 421 |
+
// Temporally workaround: exclude these files for big-endian targets.
|
| 422 |
+
if !llvm_target[0].starts_with("thumbeb") && !llvm_target[0].starts_with("armeb") {
|
| 423 |
+
sources.extend(&[
|
| 424 |
+
("__aeabi_cdcmp", "arm/aeabi_cdcmp.S"),
|
| 425 |
+
("__aeabi_cdcmpeq_check_nan", "arm/aeabi_cdcmpeq_check_nan.c"),
|
| 426 |
+
("__aeabi_cfcmp", "arm/aeabi_cfcmp.S"),
|
| 427 |
+
("__aeabi_cfcmpeq_check_nan", "arm/aeabi_cfcmpeq_check_nan.c"),
|
| 428 |
+
]);
|
| 429 |
+
}
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
if llvm_target[0] == "armv7" {
|
| 433 |
+
sources.extend(&[
|
| 434 |
+
("__sync_fetch_and_add_4", "arm/sync_fetch_and_add_4.S"),
|
| 435 |
+
("__sync_fetch_and_add_8", "arm/sync_fetch_and_add_8.S"),
|
| 436 |
+
("__sync_fetch_and_and_4", "arm/sync_fetch_and_and_4.S"),
|
| 437 |
+
("__sync_fetch_and_and_8", "arm/sync_fetch_and_and_8.S"),
|
| 438 |
+
("__sync_fetch_and_max_4", "arm/sync_fetch_and_max_4.S"),
|
| 439 |
+
("__sync_fetch_and_max_8", "arm/sync_fetch_and_max_8.S"),
|
| 440 |
+
("__sync_fetch_and_min_4", "arm/sync_fetch_and_min_4.S"),
|
| 441 |
+
("__sync_fetch_and_min_8", "arm/sync_fetch_and_min_8.S"),
|
| 442 |
+
("__sync_fetch_and_nand_4", "arm/sync_fetch_and_nand_4.S"),
|
| 443 |
+
("__sync_fetch_and_nand_8", "arm/sync_fetch_and_nand_8.S"),
|
| 444 |
+
("__sync_fetch_and_or_4", "arm/sync_fetch_and_or_4.S"),
|
| 445 |
+
("__sync_fetch_and_or_8", "arm/sync_fetch_and_or_8.S"),
|
| 446 |
+
("__sync_fetch_and_sub_4", "arm/sync_fetch_and_sub_4.S"),
|
| 447 |
+
("__sync_fetch_and_sub_8", "arm/sync_fetch_and_sub_8.S"),
|
| 448 |
+
("__sync_fetch_and_umax_4", "arm/sync_fetch_and_umax_4.S"),
|
| 449 |
+
("__sync_fetch_and_umax_8", "arm/sync_fetch_and_umax_8.S"),
|
| 450 |
+
("__sync_fetch_and_umin_4", "arm/sync_fetch_and_umin_4.S"),
|
| 451 |
+
("__sync_fetch_and_umin_8", "arm/sync_fetch_and_umin_8.S"),
|
| 452 |
+
("__sync_fetch_and_xor_4", "arm/sync_fetch_and_xor_4.S"),
|
| 453 |
+
("__sync_fetch_and_xor_8", "arm/sync_fetch_and_xor_8.S"),
|
| 454 |
+
]);
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
if llvm_target.last().unwrap().ends_with("eabihf") {
|
| 458 |
+
if !llvm_target[0].starts_with("thumbv7em")
|
| 459 |
+
&& !llvm_target[0].starts_with("thumbv8m.main")
|
| 460 |
+
{
|
| 461 |
+
// The FPU option chosen for these architectures in cc-rs, ie:
|
| 462 |
+
// -mfpu=fpv4-sp-d16 for thumbv7em
|
| 463 |
+
// -mfpu=fpv5-sp-d16 for thumbv8m.main
|
| 464 |
+
// do not support double precision floating points conversions so the files
|
| 465 |
+
// that include such instructions are not included for these targets.
|
| 466 |
+
sources.extend(&[
|
| 467 |
+
("__fixdfsivfp", "arm/fixdfsivfp.S"),
|
| 468 |
+
("__fixunsdfsivfp", "arm/fixunsdfsivfp.S"),
|
| 469 |
+
("__floatsidfvfp", "arm/floatsidfvfp.S"),
|
| 470 |
+
("__floatunssidfvfp", "arm/floatunssidfvfp.S"),
|
| 471 |
+
]);
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
sources.extend(&[
|
| 475 |
+
("__fixsfsivfp", "arm/fixsfsivfp.S"),
|
| 476 |
+
("__fixunssfsivfp", "arm/fixunssfsivfp.S"),
|
| 477 |
+
("__floatsisfvfp", "arm/floatsisfvfp.S"),
|
| 478 |
+
("__floatunssisfvfp", "arm/floatunssisfvfp.S"),
|
| 479 |
+
("__floatunssisfvfp", "arm/floatunssisfvfp.S"),
|
| 480 |
+
("__restore_vfp_d8_d15_regs", "arm/restore_vfp_d8_d15_regs.S"),
|
| 481 |
+
("__save_vfp_d8_d15_regs", "arm/save_vfp_d8_d15_regs.S"),
|
| 482 |
+
("__negdf2vfp", "arm/negdf2vfp.S"),
|
| 483 |
+
("__negsf2vfp", "arm/negsf2vfp.S"),
|
| 484 |
+
]);
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
if (target.arch == "aarch64" || target.arch == "arm64ec") && consider_float_intrinsics {
|
| 488 |
+
sources.extend(&[
|
| 489 |
+
("__fe_getround", "fp_mode.c"),
|
| 490 |
+
("__fe_raise_inexact", "fp_mode.c"),
|
| 491 |
+
]);
|
| 492 |
+
|
| 493 |
+
if target.os != "windows" && target.os != "cygwin" {
|
| 494 |
+
sources.extend(&[("__multc3", "multc3.c")]);
|
| 495 |
+
}
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
if target.arch == "mips" || target.arch == "riscv32" || target.arch == "riscv64" {
|
| 499 |
+
sources.extend(&[("__bswapsi2", "bswapsi2.c")]);
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
if target.arch == "mips64" {
|
| 503 |
+
sources.extend(&[("__fe_getround", "fp_mode.c")]);
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
if target.arch == "loongarch64" {
|
| 507 |
+
sources.extend(&[("__fe_getround", "fp_mode.c")]);
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
// Remove the assembly implementations that won't compile for the target
|
| 511 |
+
if llvm_target[0] == "thumbv6m" || llvm_target[0] == "thumbv8m.base" || target.os == "uefi"
|
| 512 |
+
{
|
| 513 |
+
let mut to_remove = Vec::new();
|
| 514 |
+
for (k, v) in sources.map.iter() {
|
| 515 |
+
if v.ends_with(".S") {
|
| 516 |
+
to_remove.push(*k);
|
| 517 |
+
}
|
| 518 |
+
}
|
| 519 |
+
sources.remove(&to_remove);
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
if llvm_target[0] == "thumbv7m" || llvm_target[0] == "thumbv7em" {
|
| 523 |
+
sources.remove(&["__aeabi_cdcmp", "__aeabi_cfcmp"]);
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
// Android and Cygwin uses emulated TLS so we need a runtime support function.
|
| 527 |
+
if target.os == "android" || target.os == "cygwin" {
|
| 528 |
+
sources.extend(&[("__emutls_get_address", "emutls.c")]);
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
// Work around a bug in the NDK headers (fixed in
|
| 532 |
+
// https://r.android.com/2038949 which will be released in a future
|
| 533 |
+
// NDK version) by providing a definition of LONG_BIT.
|
| 534 |
+
if target.os == "android" {
|
| 535 |
+
cfg.define("LONG_BIT", "(8 * sizeof(long))");
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
// OpenHarmony also uses emulated TLS.
|
| 539 |
+
if target.env == "ohos" {
|
| 540 |
+
sources.extend(&[("__emutls_get_address", "emutls.c")]);
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
// Optionally, link against a prebuilt llvm compiler-rt containing the builtins
|
| 544 |
+
// library. Only the builtins library is required. On many platforms, this is
|
| 545 |
+
// available as a library named libclang_rt.builtins.a.
|
| 546 |
+
let link_against_prebuilt_rt = env::var_os("LLVM_COMPILER_RT_LIB").is_some();
|
| 547 |
+
|
| 548 |
+
// When compiling the C code we require the user to tell us where the
|
| 549 |
+
// source code is, and this is largely done so when we're compiling as
|
| 550 |
+
// part of rust-lang/rust we can use the same llvm-project repository as
|
| 551 |
+
// rust-lang/rust.
|
| 552 |
+
let root = match env::var_os("RUST_COMPILER_RT_ROOT") {
|
| 553 |
+
Some(s) => PathBuf::from(s),
|
| 554 |
+
// If a prebuild libcompiler-rt is provided, set a valid
|
| 555 |
+
// path to simplify later logic. Nothing should be compiled.
|
| 556 |
+
None if link_against_prebuilt_rt => PathBuf::new(),
|
| 557 |
+
None => {
|
| 558 |
+
panic!(
|
| 559 |
+
"RUST_COMPILER_RT_ROOT is not set. You may need to run \
|
| 560 |
+
`ci/download-compiler-rt.sh`."
|
| 561 |
+
);
|
| 562 |
+
}
|
| 563 |
+
};
|
| 564 |
+
if !link_against_prebuilt_rt && !root.exists() {
|
| 565 |
+
panic!("RUST_COMPILER_RT_ROOT={} does not exist", root.display());
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
// Support deterministic builds by remapping the __FILE__ prefix if the
|
| 569 |
+
// compiler supports it. This fixes the nondeterminism caused by the
|
| 570 |
+
// use of that macro in lib/builtins/int_util.h in compiler-rt.
|
| 571 |
+
cfg.flag_if_supported(&format!("-ffile-prefix-map={}=.", root.display()));
|
| 572 |
+
|
| 573 |
+
// Include out-of-line atomics for aarch64, which are all generated by supplying different
|
| 574 |
+
// sets of flags to the same source file.
|
| 575 |
+
// Note: Out-of-line aarch64 atomics are not supported by the msvc toolchain (#430) and
|
| 576 |
+
// on uefi.
|
| 577 |
+
let src_dir = root.join("lib/builtins");
|
| 578 |
+
if target.arch == "aarch64" && target.env != "msvc" && target.os != "uefi" {
|
| 579 |
+
// See below for why we're building these as separate libraries.
|
| 580 |
+
build_aarch64_out_of_line_atomics_libraries(&src_dir, cfg, link_against_prebuilt_rt);
|
| 581 |
+
|
| 582 |
+
// Some run-time CPU feature detection is necessary, as well.
|
| 583 |
+
let cpu_model_src = if src_dir.join("cpu_model.c").exists() {
|
| 584 |
+
"cpu_model.c"
|
| 585 |
+
} else {
|
| 586 |
+
"cpu_model/aarch64.c"
|
| 587 |
+
};
|
| 588 |
+
sources.extend(&[("__aarch64_have_lse_atomics", cpu_model_src)]);
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
let mut added_sources = HashSet::new();
|
| 592 |
+
for (sym, src) in sources.map.iter() {
|
| 593 |
+
let src = src_dir.join(src);
|
| 594 |
+
if !link_against_prebuilt_rt && added_sources.insert(src.clone()) {
|
| 595 |
+
cfg.file(&src);
|
| 596 |
+
println!("cargo:rerun-if-changed={}", src.display());
|
| 597 |
+
}
|
| 598 |
+
println!("cargo:rustc-cfg={}=\"optimized-c\"", sym);
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
if link_against_prebuilt_rt {
|
| 602 |
+
let rt_builtins_ext = PathBuf::from(env::var_os("LLVM_COMPILER_RT_LIB").unwrap());
|
| 603 |
+
if !rt_builtins_ext.exists() {
|
| 604 |
+
panic!(
|
| 605 |
+
"LLVM_COMPILER_RT_LIB={} does not exist",
|
| 606 |
+
rt_builtins_ext.display()
|
| 607 |
+
);
|
| 608 |
+
}
|
| 609 |
+
if let Some(dir) = rt_builtins_ext.parent() {
|
| 610 |
+
println!("cargo::rustc-link-search=native={}", dir.display());
|
| 611 |
+
}
|
| 612 |
+
if let Some(lib) = rt_builtins_ext.file_name() {
|
| 613 |
+
println!(
|
| 614 |
+
"cargo::rustc-link-lib=static:+verbatim={}",
|
| 615 |
+
lib.to_str().unwrap()
|
| 616 |
+
);
|
| 617 |
+
}
|
| 618 |
+
} else {
|
| 619 |
+
cfg.compile("libcompiler-rt.a");
|
| 620 |
+
}
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
fn build_aarch64_out_of_line_atomics_libraries(
|
| 624 |
+
builtins_dir: &Path,
|
| 625 |
+
cfg: &mut cc::Build,
|
| 626 |
+
link_against_prebuilt_rt: bool,
|
| 627 |
+
) {
|
| 628 |
+
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
| 629 |
+
let outlined_atomics_file = builtins_dir.join("aarch64").join("lse.S");
|
| 630 |
+
if !link_against_prebuilt_rt {
|
| 631 |
+
println!("cargo:rerun-if-changed={}", outlined_atomics_file.display());
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
cfg.include(&builtins_dir);
|
| 635 |
+
|
| 636 |
+
for instruction_type in &["cas", "swp", "ldadd", "ldclr", "ldeor", "ldset"] {
|
| 637 |
+
for size in &[1, 2, 4, 8, 16] {
|
| 638 |
+
if *size == 16 && *instruction_type != "cas" {
|
| 639 |
+
continue;
|
| 640 |
+
}
|
| 641 |
+
|
| 642 |
+
for (model_number, model_name) in
|
| 643 |
+
&[(1, "relax"), (2, "acq"), (3, "rel"), (4, "acq_rel")]
|
| 644 |
+
{
|
| 645 |
+
let sym = format!("__aarch64_{}{}_{}", instruction_type, size, model_name);
|
| 646 |
+
println!("cargo:rustc-cfg={}=\"optimized-c\"", sym);
|
| 647 |
+
|
| 648 |
+
if link_against_prebuilt_rt {
|
| 649 |
+
continue;
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
// The original compiler-rt build system compiles the same
|
| 653 |
+
// source file multiple times with different compiler
|
| 654 |
+
// options. Here we do something slightly different: we
|
| 655 |
+
// create multiple .S files with the proper #defines and
|
| 656 |
+
// then include the original file.
|
| 657 |
+
//
|
| 658 |
+
// This is needed because the cc crate doesn't allow us to
|
| 659 |
+
// override the name of object files and libtool requires
|
| 660 |
+
// all objects in an archive to have unique names.
|
| 661 |
+
let path =
|
| 662 |
+
out_dir.join(format!("lse_{}{}_{}.S", instruction_type, size, model_name));
|
| 663 |
+
let mut file = File::create(&path).unwrap();
|
| 664 |
+
writeln!(file, "#define L_{}", instruction_type).unwrap();
|
| 665 |
+
writeln!(file, "#define SIZE {}", size).unwrap();
|
| 666 |
+
writeln!(file, "#define MODEL {}", model_number).unwrap();
|
| 667 |
+
writeln!(
|
| 668 |
+
file,
|
| 669 |
+
"#include \"{}\"",
|
| 670 |
+
outlined_atomics_file.canonicalize().unwrap().display()
|
| 671 |
+
)
|
| 672 |
+
.unwrap();
|
| 673 |
+
drop(file);
|
| 674 |
+
cfg.file(path);
|
| 675 |
+
}
|
| 676 |
+
}
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/configure.rs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Configuration that is shared between `compiler_builtins` and `builtins_test`.
|
| 2 |
+
|
| 3 |
+
use std::{env, str};
|
| 4 |
+
|
| 5 |
+
#[derive(Debug)]
|
| 6 |
+
#[allow(dead_code)]
|
| 7 |
+
pub struct Target {
|
| 8 |
+
pub triple: String,
|
| 9 |
+
pub triple_split: Vec<String>,
|
| 10 |
+
pub opt_level: String,
|
| 11 |
+
pub cargo_features: Vec<String>,
|
| 12 |
+
pub os: String,
|
| 13 |
+
pub arch: String,
|
| 14 |
+
pub vendor: String,
|
| 15 |
+
pub env: String,
|
| 16 |
+
pub pointer_width: u8,
|
| 17 |
+
pub little_endian: bool,
|
| 18 |
+
pub features: Vec<String>,
|
| 19 |
+
pub reliable_f128: bool,
|
| 20 |
+
pub reliable_f16: bool,
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
impl Target {
|
| 24 |
+
pub fn from_env() -> Self {
|
| 25 |
+
let triple = env::var("TARGET").unwrap();
|
| 26 |
+
let triple_split = triple.split('-').map(ToOwned::to_owned).collect();
|
| 27 |
+
let little_endian = match env::var("CARGO_CFG_TARGET_ENDIAN").unwrap().as_str() {
|
| 28 |
+
"little" => true,
|
| 29 |
+
"big" => false,
|
| 30 |
+
x => panic!("unknown endian {x}"),
|
| 31 |
+
};
|
| 32 |
+
let cargo_features = env::vars()
|
| 33 |
+
.filter_map(|(name, _value)| name.strip_prefix("CARGO_FEATURE_").map(ToOwned::to_owned))
|
| 34 |
+
.map(|s| s.to_lowercase().replace("_", "-"))
|
| 35 |
+
.collect();
|
| 36 |
+
|
| 37 |
+
Self {
|
| 38 |
+
triple,
|
| 39 |
+
triple_split,
|
| 40 |
+
os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
|
| 41 |
+
opt_level: env::var("OPT_LEVEL").unwrap(),
|
| 42 |
+
cargo_features,
|
| 43 |
+
arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
|
| 44 |
+
vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),
|
| 45 |
+
env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),
|
| 46 |
+
pointer_width: env::var("CARGO_CFG_TARGET_POINTER_WIDTH")
|
| 47 |
+
.unwrap()
|
| 48 |
+
.parse()
|
| 49 |
+
.unwrap(),
|
| 50 |
+
little_endian,
|
| 51 |
+
features: env::var("CARGO_CFG_TARGET_FEATURE")
|
| 52 |
+
.unwrap_or_default()
|
| 53 |
+
.split(",")
|
| 54 |
+
.map(ToOwned::to_owned)
|
| 55 |
+
.collect(),
|
| 56 |
+
// Note that these are unstable options, so only show up with the nightly compiler or
|
| 57 |
+
// with `RUSTC_BOOTSTRAP=1` (which is required to use the types anyway).
|
| 58 |
+
reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some(),
|
| 59 |
+
reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(),
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
#[allow(dead_code)]
|
| 64 |
+
pub fn has_feature(&self, feature: &str) -> bool {
|
| 65 |
+
self.features.iter().any(|f| f == feature)
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
pub fn configure_aliases(target: &Target) {
|
| 70 |
+
// To compile builtins-test-intrinsics for thumb targets, where there is no libc
|
| 71 |
+
println!("cargo::rustc-check-cfg=cfg(thumb)");
|
| 72 |
+
if target.triple_split[0].starts_with("thumb") {
|
| 73 |
+
println!("cargo:rustc-cfg=thumb")
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
// compiler-rt `cfg`s away some intrinsics for thumbv6m and thumbv8m.base because
|
| 77 |
+
// these targets do not have full Thumb-2 support but only original Thumb-1.
|
| 78 |
+
// We have to cfg our code accordingly.
|
| 79 |
+
println!("cargo::rustc-check-cfg=cfg(thumb_1)");
|
| 80 |
+
if target.triple_split[0] == "thumbv6m" || target.triple_split[0] == "thumbv8m.base" {
|
| 81 |
+
println!("cargo:rustc-cfg=thumb_1")
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
// Config shorthands
|
| 85 |
+
println!("cargo:rustc-check-cfg=cfg(x86_no_sse)");
|
| 86 |
+
if target.arch == "x86" && !target.features.iter().any(|f| f == "sse") {
|
| 87 |
+
// Shorthand to detect i586 targets
|
| 88 |
+
println!("cargo:rustc-cfg=x86_no_sse");
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/* Not all backends support `f16` and `f128` to the same level on all architectures, so we
|
| 92 |
+
* need to disable things if the compiler may crash. See configuration at:
|
| 93 |
+
* * https://github.com/rust-lang/rust/blob/c65dccabacdfd6c8a7f7439eba13422fdd89b91e/compiler/rustc_codegen_llvm/src/llvm_util.rs#L367-L432
|
| 94 |
+
* * https://github.com/rust-lang/rustc_codegen_gcc/blob/4b5c44b14166083eef8d71f15f5ea1f53fc976a0/src/lib.rs#L496-L507
|
| 95 |
+
* * https://github.com/rust-lang/rustc_codegen_cranelift/blob/c713ffab3c6e28ab4b4dd4e392330f786ea657ad/src/lib.rs#L196-L226
|
| 96 |
+
*/
|
| 97 |
+
|
| 98 |
+
println!("cargo::rustc-check-cfg=cfg(f16_enabled)");
|
| 99 |
+
if target.reliable_f16 {
|
| 100 |
+
println!("cargo::rustc-cfg=f16_enabled");
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
println!("cargo::rustc-check-cfg=cfg(f128_enabled)");
|
| 104 |
+
if target.reliable_f128 {
|
| 105 |
+
println!("cargo::rustc-cfg=f128_enabled");
|
| 106 |
+
}
|
| 107 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/Cargo.toml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "libm-macros"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
publish = false
|
| 6 |
+
license = "MIT OR Apache-2.0"
|
| 7 |
+
|
| 8 |
+
[lib]
|
| 9 |
+
proc-macro = true
|
| 10 |
+
|
| 11 |
+
[dependencies]
|
| 12 |
+
heck.workspace = true
|
| 13 |
+
proc-macro2.workspace = true
|
| 14 |
+
quote.workspace = true
|
| 15 |
+
syn = { workspace = true, features = ["full", "extra-traits", "visit-mut"] }
|
| 16 |
+
|
| 17 |
+
[lints.rust]
|
| 18 |
+
# Values used during testing
|
| 19 |
+
unexpected_cfgs = { level = "warn", check-cfg = [
|
| 20 |
+
'cfg(f16_enabled)',
|
| 21 |
+
'cfg(f128_enabled)',
|
| 22 |
+
] }
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/src/enums.r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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use heck::ToUpperCamelCase;
|
| 2 |
+
use proc_macro2 as pm2;
|
| 3 |
+
use proc_macro2::{Ident, Span};
|
| 4 |
+
use quote::quote;
|
| 5 |
+
use syn::spanned::Spanned;
|
| 6 |
+
use syn::{Fields, ItemEnum, Variant};
|
| 7 |
+
|
| 8 |
+
use crate::{ALL_OPERATIONS, base_name};
|
| 9 |
+
|
| 10 |
+
/// Implement `#[function_enum]`, see documentation in `lib.rs`.
|
| 11 |
+
pub fn function_enum(
|
| 12 |
+
mut item: ItemEnum,
|
| 13 |
+
attributes: pm2::TokenStream,
|
| 14 |
+
) -> syn::Result<pm2::TokenStream> {
|
| 15 |
+
expect_empty_enum(&item)?;
|
| 16 |
+
let attr_span = attributes.span();
|
| 17 |
+
let mut attr = attributes.into_iter();
|
| 18 |
+
|
| 19 |
+
// Attribute should be the identifier of the `BaseName` enum.
|
| 20 |
+
let Some(tt) = attr.next() else {
|
| 21 |
+
return Err(syn::Error::new(attr_span, "expected one attribute"));
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
let pm2::TokenTree::Ident(base_enum) = tt else {
|
| 25 |
+
return Err(syn::Error::new(tt.span(), "expected an identifier"));
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
if let Some(tt) = attr.next() {
|
| 29 |
+
return Err(syn::Error::new(
|
| 30 |
+
tt.span(),
|
| 31 |
+
"unexpected token after identifier",
|
| 32 |
+
));
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
let enum_name = &item.ident;
|
| 36 |
+
let mut as_str_arms = Vec::new();
|
| 37 |
+
let mut from_str_arms = Vec::new();
|
| 38 |
+
let mut base_arms = Vec::new();
|
| 39 |
+
|
| 40 |
+
for func in ALL_OPERATIONS.iter() {
|
| 41 |
+
let fn_name = func.name;
|
| 42 |
+
let ident = Ident::new(&fn_name.to_upper_camel_case(), Span::call_site());
|
| 43 |
+
let bname_ident = Ident::new(&base_name(fn_name).to_upper_camel_case(), Span::call_site());
|
| 44 |
+
|
| 45 |
+
// Match arm for `fn as_str(self)` matcher
|
| 46 |
+
as_str_arms.push(quote! { Self::#ident => #fn_name });
|
| 47 |
+
from_str_arms.push(quote! { #fn_name => Self::#ident });
|
| 48 |
+
|
| 49 |
+
// Match arm for `fn base_name(self)` matcher
|
| 50 |
+
base_arms.push(quote! { Self::#ident => #base_enum::#bname_ident });
|
| 51 |
+
|
| 52 |
+
let variant = Variant {
|
| 53 |
+
attrs: Vec::new(),
|
| 54 |
+
ident,
|
| 55 |
+
fields: Fields::Unit,
|
| 56 |
+
discriminant: None,
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
item.variants.push(variant);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
let variants = item.variants.iter();
|
| 63 |
+
|
| 64 |
+
let res = quote! {
|
| 65 |
+
// Instantiate the enum
|
| 66 |
+
#item
|
| 67 |
+
|
| 68 |
+
impl #enum_name {
|
| 69 |
+
/// All variants of this enum.
|
| 70 |
+
pub const ALL: &[Self] = &[
|
| 71 |
+
#( Self::#variants, )*
|
| 72 |
+
];
|
| 73 |
+
|
| 74 |
+
/// The stringified version of this function name.
|
| 75 |
+
pub const fn as_str(self) -> &'static str {
|
| 76 |
+
match self {
|
| 77 |
+
#( #as_str_arms , )*
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/// If `s` is the name of a function, return it.
|
| 82 |
+
pub fn from_str(s: &str) -> Option<Self> {
|
| 83 |
+
let ret = match s {
|
| 84 |
+
#( #from_str_arms , )*
|
| 85 |
+
_ => return None,
|
| 86 |
+
};
|
| 87 |
+
Some(ret)
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/// The base name enum for this function.
|
| 91 |
+
pub const fn base_name(self) -> #base_enum {
|
| 92 |
+
match self {
|
| 93 |
+
#( #base_arms, )*
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/// Return information about this operation.
|
| 98 |
+
pub fn math_op(self) -> &'static crate::op::MathOpInfo {
|
| 99 |
+
crate::op::ALL_OPERATIONS.iter().find(|op| op.name == self.as_str()).unwrap()
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
Ok(res)
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/// Implement `#[base_name_enum]`, see documentation in `lib.rs`.
|
| 108 |
+
pub fn base_name_enum(
|
| 109 |
+
mut item: ItemEnum,
|
| 110 |
+
attributes: pm2::TokenStream,
|
| 111 |
+
) -> syn::Result<pm2::TokenStream> {
|
| 112 |
+
expect_empty_enum(&item)?;
|
| 113 |
+
if !attributes.is_empty() {
|
| 114 |
+
let sp = attributes.span();
|
| 115 |
+
return Err(syn::Error::new(sp.span(), "no attributes expected"));
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
let mut base_names: Vec<_> = ALL_OPERATIONS
|
| 119 |
+
.iter()
|
| 120 |
+
.map(|func| base_name(func.name))
|
| 121 |
+
.collect();
|
| 122 |
+
base_names.sort_unstable();
|
| 123 |
+
base_names.dedup();
|
| 124 |
+
|
| 125 |
+
let item_name = &item.ident;
|
| 126 |
+
let mut as_str_arms = Vec::new();
|
| 127 |
+
|
| 128 |
+
for base_name in base_names {
|
| 129 |
+
let ident = Ident::new(&base_name.to_upper_camel_case(), Span::call_site());
|
| 130 |
+
|
| 131 |
+
// Match arm for `fn as_str(self)` matcher
|
| 132 |
+
as_str_arms.push(quote! { Self::#ident => #base_name });
|
| 133 |
+
|
| 134 |
+
let variant = Variant {
|
| 135 |
+
attrs: Vec::new(),
|
| 136 |
+
ident,
|
| 137 |
+
fields: Fields::Unit,
|
| 138 |
+
discriminant: None,
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
item.variants.push(variant);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
let res = quote! {
|
| 145 |
+
// Instantiate the enum
|
| 146 |
+
#item
|
| 147 |
+
|
| 148 |
+
impl #item_name {
|
| 149 |
+
/// The stringified version of this base name.
|
| 150 |
+
pub const fn as_str(self) -> &'static str {
|
| 151 |
+
match self {
|
| 152 |
+
#( #as_str_arms ),*
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
};
|
| 157 |
+
|
| 158 |
+
Ok(res)
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
/// Verify that an enum is empty, otherwise return an error
|
| 162 |
+
fn expect_empty_enum(item: &ItemEnum) -> syn::Result<()> {
|
| 163 |
+
if !item.variants.is_empty() {
|
| 164 |
+
Err(syn::Error::new(
|
| 165 |
+
item.variants.span(),
|
| 166 |
+
"expected an empty enum",
|
| 167 |
+
))
|
| 168 |
+
} else {
|
| 169 |
+
Ok(())
|
| 170 |
+
}
|
| 171 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/src/lib.rs
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mod enums;
|
| 2 |
+
mod parse;
|
| 3 |
+
mod shared;
|
| 4 |
+
|
| 5 |
+
use parse::{Invocation, StructuredInput};
|
| 6 |
+
use proc_macro as pm;
|
| 7 |
+
use proc_macro2::{self as pm2, Span};
|
| 8 |
+
use quote::{ToTokens, quote};
|
| 9 |
+
pub(crate) use shared::{ALL_OPERATIONS, FloatTy, MathOpInfo, Ty};
|
| 10 |
+
use syn::spanned::Spanned;
|
| 11 |
+
use syn::visit_mut::VisitMut;
|
| 12 |
+
use syn::{Ident, ItemEnum};
|
| 13 |
+
|
| 14 |
+
const KNOWN_TYPES: &[&str] = &[
|
| 15 |
+
"FTy", "CFn", "CArgs", "CRet", "RustFn", "RustArgs", "RustRet", "public",
|
| 16 |
+
];
|
| 17 |
+
|
| 18 |
+
/// Populate an enum with a variant representing function. Names are in upper camel case.
|
| 19 |
+
///
|
| 20 |
+
/// Applied to an empty enum. Expects one attribute `#[function_enum(BaseName)]` that provides
|
| 21 |
+
/// the name of the `BaseName` enum.
|
| 22 |
+
#[proc_macro_attribute]
|
| 23 |
+
pub fn function_enum(attributes: pm::TokenStream, tokens: pm::TokenStream) -> pm::TokenStream {
|
| 24 |
+
let item = syn::parse_macro_input!(tokens as ItemEnum);
|
| 25 |
+
let res = enums::function_enum(item, attributes.into());
|
| 26 |
+
|
| 27 |
+
match res {
|
| 28 |
+
Ok(ts) => ts,
|
| 29 |
+
Err(e) => e.into_compile_error(),
|
| 30 |
+
}
|
| 31 |
+
.into()
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/// Create an enum representing all possible base names, with names in upper camel case.
|
| 35 |
+
///
|
| 36 |
+
/// Applied to an empty enum.
|
| 37 |
+
#[proc_macro_attribute]
|
| 38 |
+
pub fn base_name_enum(attributes: pm::TokenStream, tokens: pm::TokenStream) -> pm::TokenStream {
|
| 39 |
+
let item = syn::parse_macro_input!(tokens as ItemEnum);
|
| 40 |
+
let res = enums::base_name_enum(item, attributes.into());
|
| 41 |
+
|
| 42 |
+
match res {
|
| 43 |
+
Ok(ts) => ts,
|
| 44 |
+
Err(e) => e.into_compile_error(),
|
| 45 |
+
}
|
| 46 |
+
.into()
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/// Do something for each function present in this crate.
|
| 50 |
+
///
|
| 51 |
+
/// Takes a callback macro and invokes it multiple times, once for each function that
|
| 52 |
+
/// this crate exports. This makes it easy to create generic tests, benchmarks, or other checks
|
| 53 |
+
/// and apply it to each symbol.
|
| 54 |
+
///
|
| 55 |
+
/// Additionally, the `extra` and `fn_extra` patterns can make use of magic identifiers:
|
| 56 |
+
///
|
| 57 |
+
/// - `MACRO_FN_NAME`: gets replaced with the name of the function on that invocation.
|
| 58 |
+
/// - `MACRO_FN_NAME_NORMALIZED`: similar to the above, but removes sufixes so e.g. `sinf` becomes
|
| 59 |
+
/// `sin`, `cosf128` becomes `cos`, etc.
|
| 60 |
+
///
|
| 61 |
+
/// Invoke as:
|
| 62 |
+
///
|
| 63 |
+
/// ```
|
| 64 |
+
/// // Macro that is invoked once per function
|
| 65 |
+
/// macro_rules! callback_macro {
|
| 66 |
+
/// (
|
| 67 |
+
/// // Name of that function
|
| 68 |
+
/// fn_name: $fn_name:ident,
|
| 69 |
+
/// // The basic float type for this function (e.g. `f32`, `f64`)
|
| 70 |
+
/// FTy: $FTy:ty,
|
| 71 |
+
/// // Function signature of the C version (e.g. `fn(f32, &mut f32) -> f32`)
|
| 72 |
+
/// CFn: $CFn:ty,
|
| 73 |
+
/// // A tuple representing the C version's arguments (e.g. `(f32, &mut f32)`)
|
| 74 |
+
/// CArgs: $CArgs:ty,
|
| 75 |
+
/// // The C version's return type (e.g. `f32`)
|
| 76 |
+
/// CRet: $CRet:ty,
|
| 77 |
+
/// // Function signature of the Rust version (e.g. `fn(f32) -> (f32, f32)`)
|
| 78 |
+
/// RustFn: $RustFn:ty,
|
| 79 |
+
/// // A tuple representing the Rust version's arguments (e.g. `(f32,)`)
|
| 80 |
+
/// RustArgs: $RustArgs:ty,
|
| 81 |
+
/// // The Rust version's return type (e.g. `(f32, f32)`)
|
| 82 |
+
/// RustRet: $RustRet:ty,
|
| 83 |
+
/// // True if this is part of `libm`'s public API
|
| 84 |
+
/// public: $public:expr,
|
| 85 |
+
/// // Attributes for the current function, if any
|
| 86 |
+
/// attrs: [$($attr:meta),*],
|
| 87 |
+
/// // Extra tokens passed directly (if any)
|
| 88 |
+
/// extra: [$extra:ident],
|
| 89 |
+
/// // Extra function-tokens passed directly (if any)
|
| 90 |
+
/// fn_extra: $fn_extra:expr,
|
| 91 |
+
/// ) => { };
|
| 92 |
+
/// }
|
| 93 |
+
///
|
| 94 |
+
/// // All fields except for `callback` are optional.
|
| 95 |
+
/// libm_macros::for_each_function! {
|
| 96 |
+
/// // The macro to invoke as a callback
|
| 97 |
+
/// callback: callback_macro,
|
| 98 |
+
/// // Which types to include either as a list (`[CFn, RustFn, RustArgs]`) or "all"
|
| 99 |
+
/// emit_types: all,
|
| 100 |
+
/// // Functions to skip, i.e. `callback` shouldn't be called at all for these.
|
| 101 |
+
/// skip: [sin, cos],
|
| 102 |
+
/// // Attributes passed as `attrs` for specific functions. For example, here the invocation
|
| 103 |
+
/// // with `sinf` and that with `cosf` will both get `meta1` and `meta2`, but no others will.
|
| 104 |
+
/// //
|
| 105 |
+
/// // Note that `f16_enabled` and `f128_enabled` will always get emitted regardless of whether
|
| 106 |
+
/// // or not this is specified.
|
| 107 |
+
/// attributes: [
|
| 108 |
+
/// #[meta1]
|
| 109 |
+
/// #[meta2]
|
| 110 |
+
/// [sinf, cosf],
|
| 111 |
+
/// ],
|
| 112 |
+
/// // Any tokens that should be passed directly to all invocations of the callback. This can
|
| 113 |
+
/// // be used to pass local variables or other things the macro needs access to.
|
| 114 |
+
/// extra: [foo],
|
| 115 |
+
/// // Similar to `extra`, but allow providing a pattern for only specific functions. Uses
|
| 116 |
+
/// // a simplified match-like syntax.
|
| 117 |
+
/// fn_extra: match MACRO_FN_NAME {
|
| 118 |
+
/// hypot | hypotf => |x| x.hypot(),
|
| 119 |
+
/// // `ALL_*` magic matchers also work to extract specific types
|
| 120 |
+
/// ALL_F64 => |x| x,
|
| 121 |
+
/// // The default pattern gets applied to everything that did not match
|
| 122 |
+
/// _ => |x| x,
|
| 123 |
+
/// },
|
| 124 |
+
/// }
|
| 125 |
+
/// ```
|
| 126 |
+
#[proc_macro]
|
| 127 |
+
pub fn for_each_function(tokens: pm::TokenStream) -> pm::TokenStream {
|
| 128 |
+
let input = syn::parse_macro_input!(tokens as Invocation);
|
| 129 |
+
|
| 130 |
+
let res = StructuredInput::from_fields(input)
|
| 131 |
+
.and_then(|mut s_in| validate(&mut s_in).map(|fn_list| (s_in, fn_list)))
|
| 132 |
+
.and_then(|(s_in, fn_list)| expand(s_in, &fn_list));
|
| 133 |
+
|
| 134 |
+
match res {
|
| 135 |
+
Ok(ts) => ts.into(),
|
| 136 |
+
Err(e) => e.into_compile_error().into(),
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
/// Check for any input that is structurally correct but has other problems.
|
| 141 |
+
///
|
| 142 |
+
/// Returns the list of function names that we should expand for.
|
| 143 |
+
fn validate(input: &mut StructuredInput) -> syn::Result<Vec<&'static MathOpInfo>> {
|
| 144 |
+
// Replace magic mappers with a list of relevant functions.
|
| 145 |
+
if let Some(map) = &mut input.fn_extra {
|
| 146 |
+
for (name, ty) in [
|
| 147 |
+
("ALL_F16", FloatTy::F16),
|
| 148 |
+
("ALL_F32", FloatTy::F32),
|
| 149 |
+
("ALL_F64", FloatTy::F64),
|
| 150 |
+
("ALL_F128", FloatTy::F128),
|
| 151 |
+
] {
|
| 152 |
+
let Some(k) = map.keys().find(|key| *key == name) else {
|
| 153 |
+
continue;
|
| 154 |
+
};
|
| 155 |
+
|
| 156 |
+
let key = k.clone();
|
| 157 |
+
let val = map.remove(&key).unwrap();
|
| 158 |
+
|
| 159 |
+
for op in ALL_OPERATIONS.iter().filter(|op| op.float_ty == ty) {
|
| 160 |
+
map.insert(Ident::new(op.name, key.span()), val.clone());
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
// Collect lists of all functions that are provied as macro inputs in various fields (only,
|
| 166 |
+
// skip, attributes).
|
| 167 |
+
let attr_mentions = input
|
| 168 |
+
.attributes
|
| 169 |
+
.iter()
|
| 170 |
+
.flat_map(|map_list| map_list.iter())
|
| 171 |
+
.flat_map(|attr_map| attr_map.names.iter());
|
| 172 |
+
let only_mentions = input.only.iter().flat_map(|only_list| only_list.iter());
|
| 173 |
+
let fn_extra_mentions = input
|
| 174 |
+
.fn_extra
|
| 175 |
+
.iter()
|
| 176 |
+
.flat_map(|v| v.keys())
|
| 177 |
+
.filter(|name| *name != "_");
|
| 178 |
+
let all_mentioned_fns = input
|
| 179 |
+
.skip
|
| 180 |
+
.iter()
|
| 181 |
+
.chain(only_mentions)
|
| 182 |
+
.chain(attr_mentions)
|
| 183 |
+
.chain(fn_extra_mentions);
|
| 184 |
+
|
| 185 |
+
// Make sure that every function mentioned is a real function
|
| 186 |
+
for mentioned in all_mentioned_fns {
|
| 187 |
+
if !ALL_OPERATIONS.iter().any(|func| mentioned == func.name) {
|
| 188 |
+
let e = syn::Error::new(
|
| 189 |
+
mentioned.span(),
|
| 190 |
+
format!("unrecognized function name `{mentioned}`"),
|
| 191 |
+
);
|
| 192 |
+
return Err(e);
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
if !input.skip.is_empty() && input.only.is_some() {
|
| 197 |
+
let e = syn::Error::new(
|
| 198 |
+
input.only_span.unwrap(),
|
| 199 |
+
"only one of `skip` or `only` may be specified",
|
| 200 |
+
);
|
| 201 |
+
return Err(e);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
// Construct a list of what we intend to expand
|
| 205 |
+
let mut fn_list = Vec::new();
|
| 206 |
+
for func in ALL_OPERATIONS.iter() {
|
| 207 |
+
let fn_name = func.name;
|
| 208 |
+
// If we have an `only` list and it does _not_ contain this function name, skip it
|
| 209 |
+
if input
|
| 210 |
+
.only
|
| 211 |
+
.as_ref()
|
| 212 |
+
.is_some_and(|only| !only.iter().any(|o| o == fn_name))
|
| 213 |
+
{
|
| 214 |
+
continue;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
// If there is a `skip` list that contains this function name, skip it
|
| 218 |
+
if input.skip.iter().any(|s| s == fn_name) {
|
| 219 |
+
continue;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
// Omit f16 and f128 functions if requested
|
| 223 |
+
if input.skip_f16_f128 && (func.float_ty == FloatTy::F16 || func.float_ty == FloatTy::F128)
|
| 224 |
+
{
|
| 225 |
+
continue;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
// Run everything else
|
| 229 |
+
fn_list.push(func);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
// Types that the user would like us to provide in the macro
|
| 233 |
+
let mut add_all_types = false;
|
| 234 |
+
for ty in &input.emit_types {
|
| 235 |
+
let ty_name = ty.to_string();
|
| 236 |
+
if ty_name == "all" {
|
| 237 |
+
add_all_types = true;
|
| 238 |
+
continue;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
// Check that all requested types are valid
|
| 242 |
+
if !KNOWN_TYPES.contains(&ty_name.as_str()) {
|
| 243 |
+
let e = syn::Error::new(
|
| 244 |
+
ty_name.span(),
|
| 245 |
+
format!("unrecognized type identifier `{ty_name}`"),
|
| 246 |
+
);
|
| 247 |
+
return Err(e);
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
if add_all_types {
|
| 252 |
+
// Ensure that if `all` was specified that nothing else was
|
| 253 |
+
if input.emit_types.len() > 1 {
|
| 254 |
+
let e = syn::Error::new(
|
| 255 |
+
input.emit_types_span.unwrap(),
|
| 256 |
+
"if `all` is specified, no other type identifiers may be given",
|
| 257 |
+
);
|
| 258 |
+
return Err(e);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
// ...and then add all types
|
| 262 |
+
input.emit_types.clear();
|
| 263 |
+
for ty in KNOWN_TYPES {
|
| 264 |
+
let ident = Ident::new(ty, Span::call_site());
|
| 265 |
+
input.emit_types.push(ident);
|
| 266 |
+
}
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
if let Some(map) = &input.fn_extra
|
| 270 |
+
&& !map.keys().any(|key| key == "_")
|
| 271 |
+
{
|
| 272 |
+
// No default provided; make sure every expected function is covered
|
| 273 |
+
let mut fns_not_covered = Vec::new();
|
| 274 |
+
for func in &fn_list {
|
| 275 |
+
if !map.keys().any(|key| key == func.name) {
|
| 276 |
+
// `name` was not mentioned in the `match` statement
|
| 277 |
+
fns_not_covered.push(func);
|
| 278 |
+
}
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
if !fns_not_covered.is_empty() {
|
| 282 |
+
let e = syn::Error::new(
|
| 283 |
+
input.fn_extra_span.unwrap(),
|
| 284 |
+
format!(
|
| 285 |
+
"`fn_extra`: no default `_` pattern specified and the following \
|
| 286 |
+
patterns are not covered: {fns_not_covered:#?}"
|
| 287 |
+
),
|
| 288 |
+
);
|
| 289 |
+
return Err(e);
|
| 290 |
+
}
|
| 291 |
+
};
|
| 292 |
+
|
| 293 |
+
Ok(fn_list)
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
/// Expand our structured macro input into invocations of the callback macro.
|
| 297 |
+
fn expand(input: StructuredInput, fn_list: &[&MathOpInfo]) -> syn::Result<pm2::TokenStream> {
|
| 298 |
+
let mut out = pm2::TokenStream::new();
|
| 299 |
+
let default_ident = Ident::new("_", Span::call_site());
|
| 300 |
+
let callback = input.callback;
|
| 301 |
+
|
| 302 |
+
for func in fn_list {
|
| 303 |
+
let fn_name = Ident::new(func.name, Span::call_site());
|
| 304 |
+
|
| 305 |
+
// Prepare attributes in an `attrs: ...` field
|
| 306 |
+
let mut meta_fields = Vec::new();
|
| 307 |
+
if let Some(attrs) = &input.attributes {
|
| 308 |
+
let meta_iter = attrs
|
| 309 |
+
.iter()
|
| 310 |
+
.filter(|map| map.names.contains(&fn_name))
|
| 311 |
+
.flat_map(|map| &map.meta)
|
| 312 |
+
.map(|v| v.into_token_stream());
|
| 313 |
+
|
| 314 |
+
meta_fields.extend(meta_iter);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
// Always emit f16 and f128 meta so this doesn't need to be repeated everywhere
|
| 318 |
+
if func.rust_sig.args.contains(&Ty::F16) || func.rust_sig.returns.contains(&Ty::F16) {
|
| 319 |
+
let ts = quote! { cfg(f16_enabled) };
|
| 320 |
+
meta_fields.push(ts);
|
| 321 |
+
}
|
| 322 |
+
if func.rust_sig.args.contains(&Ty::F128) || func.rust_sig.returns.contains(&Ty::F128) {
|
| 323 |
+
let ts = quote! { cfg(f128_enabled) };
|
| 324 |
+
meta_fields.push(ts);
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
let meta_field = quote! { attrs: [ #( #meta_fields ),* ], };
|
| 328 |
+
|
| 329 |
+
// Prepare extra in an `extra: ...` field, running the replacer
|
| 330 |
+
let extra_field = match input.extra.clone() {
|
| 331 |
+
Some(mut extra) => {
|
| 332 |
+
let mut v = MacroReplace::new(func.name);
|
| 333 |
+
v.visit_expr_mut(&mut extra);
|
| 334 |
+
v.finish()?;
|
| 335 |
+
|
| 336 |
+
quote! { extra: #extra, }
|
| 337 |
+
}
|
| 338 |
+
None => pm2::TokenStream::new(),
|
| 339 |
+
};
|
| 340 |
+
|
| 341 |
+
// Prepare function-specific extra in a `fn_extra: ...` field, running the replacer
|
| 342 |
+
let fn_extra_field = match input.fn_extra {
|
| 343 |
+
Some(ref map) => {
|
| 344 |
+
let mut fn_extra = map
|
| 345 |
+
.get(&fn_name)
|
| 346 |
+
.or_else(|| map.get(&default_ident))
|
| 347 |
+
.unwrap()
|
| 348 |
+
.clone();
|
| 349 |
+
|
| 350 |
+
let mut v = MacroReplace::new(func.name);
|
| 351 |
+
v.visit_expr_mut(&mut fn_extra);
|
| 352 |
+
v.finish()?;
|
| 353 |
+
|
| 354 |
+
quote! { fn_extra: #fn_extra, }
|
| 355 |
+
}
|
| 356 |
+
None => pm2::TokenStream::new(),
|
| 357 |
+
};
|
| 358 |
+
|
| 359 |
+
let base_fty = func.float_ty;
|
| 360 |
+
let c_args = &func.c_sig.args;
|
| 361 |
+
let c_ret = &func.c_sig.returns;
|
| 362 |
+
let rust_args = &func.rust_sig.args;
|
| 363 |
+
let rust_ret = &func.rust_sig.returns;
|
| 364 |
+
let public = func.public;
|
| 365 |
+
|
| 366 |
+
let mut ty_fields = Vec::new();
|
| 367 |
+
for ty in &input.emit_types {
|
| 368 |
+
let field = match ty.to_string().as_str() {
|
| 369 |
+
"FTy" => quote! { FTy: #base_fty, },
|
| 370 |
+
"CFn" => quote! { CFn: fn( #(#c_args),* ,) -> ( #(#c_ret),* ), },
|
| 371 |
+
"CArgs" => quote! { CArgs: ( #(#c_args),* ,), },
|
| 372 |
+
"CRet" => quote! { CRet: ( #(#c_ret),* ), },
|
| 373 |
+
"RustFn" => quote! { RustFn: fn( #(#rust_args),* ,) -> ( #(#rust_ret),* ), },
|
| 374 |
+
"RustArgs" => quote! { RustArgs: ( #(#rust_args),* ,), },
|
| 375 |
+
"RustRet" => quote! { RustRet: ( #(#rust_ret),* ), },
|
| 376 |
+
"public" => quote! { public: #public, },
|
| 377 |
+
_ => unreachable!("checked in validation"),
|
| 378 |
+
};
|
| 379 |
+
ty_fields.push(field);
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
let new = quote! {
|
| 383 |
+
#callback! {
|
| 384 |
+
fn_name: #fn_name,
|
| 385 |
+
#( #ty_fields )*
|
| 386 |
+
#meta_field
|
| 387 |
+
#extra_field
|
| 388 |
+
#fn_extra_field
|
| 389 |
+
}
|
| 390 |
+
};
|
| 391 |
+
|
| 392 |
+
out.extend(new);
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
Ok(out)
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
/// Visitor to replace "magic" identifiers that we allow: `MACRO_FN_NAME` and
|
| 399 |
+
/// `MACRO_FN_NAME_NORMALIZED`.
|
| 400 |
+
struct MacroReplace {
|
| 401 |
+
fn_name: &'static str,
|
| 402 |
+
/// Remove the trailing `f` or `f128` to make
|
| 403 |
+
norm_name: String,
|
| 404 |
+
error: Option<syn::Error>,
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
impl MacroReplace {
|
| 408 |
+
fn new(name: &'static str) -> Self {
|
| 409 |
+
let norm_name = base_name(name);
|
| 410 |
+
Self {
|
| 411 |
+
fn_name: name,
|
| 412 |
+
norm_name: norm_name.to_owned(),
|
| 413 |
+
error: None,
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
fn finish(self) -> syn::Result<()> {
|
| 418 |
+
match self.error {
|
| 419 |
+
Some(e) => Err(e),
|
| 420 |
+
None => Ok(()),
|
| 421 |
+
}
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
fn visit_ident_inner(&mut self, i: &mut Ident) {
|
| 425 |
+
let s = i.to_string();
|
| 426 |
+
if !s.starts_with("MACRO") || self.error.is_some() {
|
| 427 |
+
return;
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
match s.as_str() {
|
| 431 |
+
"MACRO_FN_NAME" => *i = Ident::new(self.fn_name, i.span()),
|
| 432 |
+
"MACRO_FN_NAME_NORMALIZED" => *i = Ident::new(&self.norm_name, i.span()),
|
| 433 |
+
_ => {
|
| 434 |
+
self.error = Some(syn::Error::new(
|
| 435 |
+
i.span(),
|
| 436 |
+
format!("unrecognized meta expression `{s}`"),
|
| 437 |
+
));
|
| 438 |
+
}
|
| 439 |
+
}
|
| 440 |
+
}
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
impl VisitMut for MacroReplace {
|
| 444 |
+
fn visit_ident_mut(&mut self, i: &mut Ident) {
|
| 445 |
+
self.visit_ident_inner(i);
|
| 446 |
+
syn::visit_mut::visit_ident_mut(self, i);
|
| 447 |
+
}
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
/// Return the unsuffixed version of a function name; e.g. `abs` and `absf` both return `abs`,
|
| 451 |
+
/// `lgamma_r` and `lgammaf_r` both return `lgamma_r`.
|
| 452 |
+
fn base_name(name: &str) -> &str {
|
| 453 |
+
let known_mappings = &[
|
| 454 |
+
("erff", "erf"),
|
| 455 |
+
("erf", "erf"),
|
| 456 |
+
("lgammaf_r", "lgamma_r"),
|
| 457 |
+
("modff", "modf"),
|
| 458 |
+
("modf", "modf"),
|
| 459 |
+
];
|
| 460 |
+
|
| 461 |
+
match known_mappings.iter().find(|known| known.0 == name) {
|
| 462 |
+
Some(found) => found.1,
|
| 463 |
+
None => name
|
| 464 |
+
.strip_suffix("f")
|
| 465 |
+
.or_else(|| name.strip_suffix("f16"))
|
| 466 |
+
.or_else(|| name.strip_suffix("f128"))
|
| 467 |
+
.unwrap_or(name),
|
| 468 |
+
}
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
impl ToTokens for Ty {
|
| 472 |
+
fn to_tokens(&self, tokens: &mut pm2::TokenStream) {
|
| 473 |
+
let ts = match self {
|
| 474 |
+
Ty::F16 => quote! { f16 },
|
| 475 |
+
Ty::F32 => quote! { f32 },
|
| 476 |
+
Ty::F64 => quote! { f64 },
|
| 477 |
+
Ty::F128 => quote! { f128 },
|
| 478 |
+
Ty::I32 => quote! { i32 },
|
| 479 |
+
Ty::CInt => quote! { ::core::ffi::c_int },
|
| 480 |
+
Ty::MutF16 => quote! { &'a mut f16 },
|
| 481 |
+
Ty::MutF32 => quote! { &'a mut f32 },
|
| 482 |
+
Ty::MutF64 => quote! { &'a mut f64 },
|
| 483 |
+
Ty::MutF128 => quote! { &'a mut f128 },
|
| 484 |
+
Ty::MutI32 => quote! { &'a mut i32 },
|
| 485 |
+
Ty::MutCInt => quote! { &'a mut core::ffi::c_int },
|
| 486 |
+
};
|
| 487 |
+
|
| 488 |
+
tokens.extend(ts);
|
| 489 |
+
}
|
| 490 |
+
}
|
| 491 |
+
impl ToTokens for FloatTy {
|
| 492 |
+
fn to_tokens(&self, tokens: &mut pm2::TokenStream) {
|
| 493 |
+
let ts = match self {
|
| 494 |
+
FloatTy::F16 => quote! { f16 },
|
| 495 |
+
FloatTy::F32 => quote! { f32 },
|
| 496 |
+
FloatTy::F64 => quote! { f64 },
|
| 497 |
+
FloatTy::F128 => quote! { f128 },
|
| 498 |
+
};
|
| 499 |
+
|
| 500 |
+
tokens.extend(ts);
|
| 501 |
+
}
|
| 502 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/libm-macros/src/parse.rs
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use std::collections::BTreeMap;
|
| 2 |
+
|
| 3 |
+
use proc_macro2::Span;
|
| 4 |
+
use quote::ToTokens;
|
| 5 |
+
use syn::parse::{Parse, ParseStream, Parser};
|
| 6 |
+
use syn::punctuated::Punctuated;
|
| 7 |
+
use syn::spanned::Spanned;
|
| 8 |
+
use syn::token::{self, Comma};
|
| 9 |
+
use syn::{Arm, Attribute, Expr, ExprMatch, Ident, LitBool, Meta, Token, bracketed};
|
| 10 |
+
|
| 11 |
+
/// The input to our macro; just a list of `field: value` items.
|
| 12 |
+
#[derive(Debug)]
|
| 13 |
+
pub struct Invocation {
|
| 14 |
+
fields: Punctuated<Mapping, Comma>,
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
impl Parse for Invocation {
|
| 18 |
+
fn parse(input: ParseStream) -> syn::Result<Self> {
|
| 19 |
+
Ok(Self {
|
| 20 |
+
fields: input.parse_terminated(Mapping::parse, Token![,])?,
|
| 21 |
+
})
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/// A `key: expression` mapping with nothing else. Basically a simplified `syn::Field`.
|
| 26 |
+
#[derive(Debug)]
|
| 27 |
+
struct Mapping {
|
| 28 |
+
name: Ident,
|
| 29 |
+
_sep: Token![:],
|
| 30 |
+
expr: Expr,
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
impl Parse for Mapping {
|
| 34 |
+
fn parse(input: ParseStream) -> syn::Result<Self> {
|
| 35 |
+
Ok(Self {
|
| 36 |
+
name: input.parse()?,
|
| 37 |
+
_sep: input.parse()?,
|
| 38 |
+
expr: input.parse()?,
|
| 39 |
+
})
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/// The input provided to our proc macro, after parsing into the form we expect.
|
| 44 |
+
#[derive(Debug)]
|
| 45 |
+
pub struct StructuredInput {
|
| 46 |
+
/// Macro to invoke once per function
|
| 47 |
+
pub callback: Ident,
|
| 48 |
+
/// Whether or not to provide `CFn` `CArgs` `RustFn` etc. This is really only needed
|
| 49 |
+
/// once for crate to set up the main trait.
|
| 50 |
+
pub emit_types: Vec<Ident>,
|
| 51 |
+
/// Skip these functions
|
| 52 |
+
pub skip: Vec<Ident>,
|
| 53 |
+
/// If true, omit f16 and f128 functions that aren't present in other libraries.
|
| 54 |
+
pub skip_f16_f128: bool,
|
| 55 |
+
/// Invoke only for these functions
|
| 56 |
+
pub only: Option<Vec<Ident>>,
|
| 57 |
+
/// Attributes that get applied to specific functions
|
| 58 |
+
pub attributes: Option<Vec<AttributeMap>>,
|
| 59 |
+
/// Extra expressions to pass to all invocations of the macro
|
| 60 |
+
pub extra: Option<Expr>,
|
| 61 |
+
/// Per-function extra expressions to pass to the macro
|
| 62 |
+
pub fn_extra: Option<BTreeMap<Ident, Expr>>,
|
| 63 |
+
// For diagnostics
|
| 64 |
+
pub emit_types_span: Option<Span>,
|
| 65 |
+
pub only_span: Option<Span>,
|
| 66 |
+
pub fn_extra_span: Option<Span>,
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
impl StructuredInput {
|
| 70 |
+
pub fn from_fields(input: Invocation) -> syn::Result<Self> {
|
| 71 |
+
let mut map: Vec<_> = input.fields.into_iter().collect();
|
| 72 |
+
let cb_expr = expect_field(&mut map, "callback")?;
|
| 73 |
+
let emit_types_expr = expect_field(&mut map, "emit_types").ok();
|
| 74 |
+
let skip_expr = expect_field(&mut map, "skip").ok();
|
| 75 |
+
let skip_f16_f128 = expect_field(&mut map, "skip_f16_f128").ok();
|
| 76 |
+
let only_expr = expect_field(&mut map, "only").ok();
|
| 77 |
+
let attr_expr = expect_field(&mut map, "attributes").ok();
|
| 78 |
+
let extra = expect_field(&mut map, "extra").ok();
|
| 79 |
+
let fn_extra = expect_field(&mut map, "fn_extra").ok();
|
| 80 |
+
|
| 81 |
+
if !map.is_empty() {
|
| 82 |
+
Err(syn::Error::new(
|
| 83 |
+
map.first().unwrap().name.span(),
|
| 84 |
+
format!("unexpected fields {map:?}"),
|
| 85 |
+
))?;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
let emit_types_span = emit_types_expr.as_ref().map(|expr| expr.span());
|
| 89 |
+
let emit_types = match emit_types_expr {
|
| 90 |
+
Some(expr) => Parser::parse2(parse_ident_or_array, expr.into_token_stream())?,
|
| 91 |
+
None => Vec::new(),
|
| 92 |
+
};
|
| 93 |
+
|
| 94 |
+
let skip = match skip_expr {
|
| 95 |
+
Some(expr) => Parser::parse2(parse_ident_array, expr.into_token_stream())?,
|
| 96 |
+
None => Vec::new(),
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
let skip_f16_f128 = match skip_f16_f128 {
|
| 100 |
+
Some(expr) => expect_litbool(expr)?.value,
|
| 101 |
+
None => false,
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
let only_span = only_expr.as_ref().map(|expr| expr.span());
|
| 105 |
+
let only = match only_expr {
|
| 106 |
+
Some(expr) => Some(Parser::parse2(parse_ident_array, expr.into_token_stream())?),
|
| 107 |
+
None => None,
|
| 108 |
+
};
|
| 109 |
+
|
| 110 |
+
let attributes = match attr_expr {
|
| 111 |
+
Some(expr) => {
|
| 112 |
+
let mut attributes = Vec::new();
|
| 113 |
+
let attr_exprs = Parser::parse2(parse_expr_array, expr.into_token_stream())?;
|
| 114 |
+
|
| 115 |
+
for attr in attr_exprs {
|
| 116 |
+
attributes.push(syn::parse2(attr.into_token_stream())?);
|
| 117 |
+
}
|
| 118 |
+
Some(attributes)
|
| 119 |
+
}
|
| 120 |
+
None => None,
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
let fn_extra_span = fn_extra.as_ref().map(|expr| expr.span());
|
| 124 |
+
let fn_extra = match fn_extra {
|
| 125 |
+
Some(expr) => Some(extract_fn_extra_field(expr)?),
|
| 126 |
+
None => None,
|
| 127 |
+
};
|
| 128 |
+
|
| 129 |
+
Ok(Self {
|
| 130 |
+
callback: expect_ident(cb_expr)?,
|
| 131 |
+
emit_types,
|
| 132 |
+
skip,
|
| 133 |
+
skip_f16_f128,
|
| 134 |
+
only,
|
| 135 |
+
only_span,
|
| 136 |
+
attributes,
|
| 137 |
+
extra,
|
| 138 |
+
fn_extra,
|
| 139 |
+
fn_extra_span,
|
| 140 |
+
emit_types_span,
|
| 141 |
+
})
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
fn extract_fn_extra_field(expr: Expr) -> syn::Result<BTreeMap<Ident, Expr>> {
|
| 146 |
+
let Expr::Match(mexpr) = expr else {
|
| 147 |
+
let e = syn::Error::new(expr.span(), "`fn_extra` expects a match expression");
|
| 148 |
+
return Err(e);
|
| 149 |
+
};
|
| 150 |
+
|
| 151 |
+
let ExprMatch {
|
| 152 |
+
attrs,
|
| 153 |
+
match_token: _,
|
| 154 |
+
expr,
|
| 155 |
+
brace_token: _,
|
| 156 |
+
arms,
|
| 157 |
+
} = mexpr;
|
| 158 |
+
|
| 159 |
+
expect_empty_attrs(&attrs)?;
|
| 160 |
+
|
| 161 |
+
let match_on = expect_ident(*expr)?;
|
| 162 |
+
if match_on != "MACRO_FN_NAME" {
|
| 163 |
+
let e = syn::Error::new(match_on.span(), "only allowed to match on `MACRO_FN_NAME`");
|
| 164 |
+
return Err(e);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
let mut res = BTreeMap::new();
|
| 168 |
+
|
| 169 |
+
for arm in arms {
|
| 170 |
+
let Arm {
|
| 171 |
+
attrs,
|
| 172 |
+
pat,
|
| 173 |
+
guard,
|
| 174 |
+
fat_arrow_token: _,
|
| 175 |
+
body,
|
| 176 |
+
comma: _,
|
| 177 |
+
} = arm;
|
| 178 |
+
|
| 179 |
+
expect_empty_attrs(&attrs)?;
|
| 180 |
+
|
| 181 |
+
let keys = match pat {
|
| 182 |
+
syn::Pat::Wild(w) => vec![Ident::new("_", w.span())],
|
| 183 |
+
_ => Parser::parse2(parse_ident_pat, pat.into_token_stream())?,
|
| 184 |
+
};
|
| 185 |
+
|
| 186 |
+
if let Some(guard) = guard {
|
| 187 |
+
let e = syn::Error::new(guard.0.span(), "no guards allowed in this position");
|
| 188 |
+
return Err(e);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
for key in keys {
|
| 192 |
+
let inserted = res.insert(key.clone(), *body.clone());
|
| 193 |
+
if inserted.is_some() {
|
| 194 |
+
let e = syn::Error::new(key.span(), format!("key `{key}` specified twice"));
|
| 195 |
+
return Err(e);
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
Ok(res)
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
fn expect_empty_attrs(attrs: &[Attribute]) -> syn::Result<()> {
|
| 204 |
+
if attrs.is_empty() {
|
| 205 |
+
return Ok(());
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
let e = syn::Error::new(
|
| 209 |
+
attrs.first().unwrap().span(),
|
| 210 |
+
"no attributes allowed in this position",
|
| 211 |
+
);
|
| 212 |
+
Err(e)
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/// Extract a named field from a map, raising an error if it doesn't exist.
|
| 216 |
+
fn expect_field(v: &mut Vec<Mapping>, name: &str) -> syn::Result<Expr> {
|
| 217 |
+
let pos = v.iter().position(|v| v.name == name).ok_or_else(|| {
|
| 218 |
+
syn::Error::new(
|
| 219 |
+
Span::call_site(),
|
| 220 |
+
format!("missing expected field `{name}`"),
|
| 221 |
+
)
|
| 222 |
+
})?;
|
| 223 |
+
|
| 224 |
+
Ok(v.remove(pos).expr)
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/// Coerce an expression into a simple identifier.
|
| 228 |
+
fn expect_ident(expr: Expr) -> syn::Result<Ident> {
|
| 229 |
+
syn::parse2(expr.into_token_stream())
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
/// Coerce an expression into a simple keyword.
|
| 233 |
+
fn expect_litbool(expr: Expr) -> syn::Result<LitBool> {
|
| 234 |
+
syn::parse2(expr.into_token_stream())
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
/// Parse either a single identifier (`foo`) or an array of identifiers (`[foo, bar, baz]`).
|
| 238 |
+
fn parse_ident_or_array(input: ParseStream) -> syn::Result<Vec<Ident>> {
|
| 239 |
+
if !input.peek(token::Bracket) {
|
| 240 |
+
return Ok(vec![input.parse()?]);
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
parse_ident_array(input)
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
/// Parse an array of expressions.
|
| 247 |
+
fn parse_expr_array(input: ParseStream) -> syn::Result<Vec<Expr>> {
|
| 248 |
+
let content;
|
| 249 |
+
let _ = bracketed!(content in input);
|
| 250 |
+
let fields = content.parse_terminated(Expr::parse, Token![,])?;
|
| 251 |
+
Ok(fields.into_iter().collect())
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/// Parse an array of idents, e.g. `[foo, bar, baz]`.
|
| 255 |
+
fn parse_ident_array(input: ParseStream) -> syn::Result<Vec<Ident>> {
|
| 256 |
+
let content;
|
| 257 |
+
let _ = bracketed!(content in input);
|
| 258 |
+
let fields = content.parse_terminated(Ident::parse, Token![,])?;
|
| 259 |
+
Ok(fields.into_iter().collect())
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
/// Parse an pattern of idents, specifically `(foo | bar | baz)`.
|
| 263 |
+
fn parse_ident_pat(input: ParseStream) -> syn::Result<Vec<Ident>> {
|
| 264 |
+
if !input.peek2(Token![|]) {
|
| 265 |
+
return Ok(vec![input.parse()?]);
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
let fields = Punctuated::<Ident, Token![|]>::parse_separated_nonempty(input)?;
|
| 269 |
+
Ok(fields.into_iter().collect())
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
/// A mapping of attributes to identifiers (just a simplified `Expr`).
|
| 273 |
+
///
|
| 274 |
+
/// Expressed as:
|
| 275 |
+
///
|
| 276 |
+
/// ```ignore
|
| 277 |
+
/// #[meta1]
|
| 278 |
+
/// #[meta2]
|
| 279 |
+
/// [foo, bar, baz]
|
| 280 |
+
/// ```
|
| 281 |
+
#[derive(Debug)]
|
| 282 |
+
pub struct AttributeMap {
|
| 283 |
+
pub meta: Vec<Meta>,
|
| 284 |
+
pub names: Vec<Ident>,
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
impl Parse for AttributeMap {
|
| 288 |
+
fn parse(input: ParseStream) -> syn::Result<Self> {
|
| 289 |
+
let attrs = input.call(Attribute::parse_outer)?;
|
| 290 |
+
|
| 291 |
+
Ok(Self {
|
| 292 |
+
meta: attrs.into_iter().map(|a| a.meta).collect(),
|
| 293 |
+
names: parse_ident_array(input)?,
|
| 294 |
+
})
|
| 295 |
+
}
|
| 296 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/r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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* List of all functions that is shared between `libm-macros` and `libm-test`. */
|
| 2 |
+
|
| 3 |
+
use std::fmt;
|
| 4 |
+
use std::sync::LazyLock;
|
| 5 |
+
|
| 6 |
+
struct NestedOp {
|
| 7 |
+
float_ty: FloatTy,
|
| 8 |
+
rust_sig: Signature,
|
| 9 |
+
c_sig: Option<Signature>,
|
| 10 |
+
fn_list: &'static [&'static str],
|
| 11 |
+
public: bool,
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
/// We need a flat list to work with most of the time, but define things as a more convenient
|
| 15 |
+
/// nested list.
|
| 16 |
+
const ALL_OPERATIONS_NESTED: &[NestedOp] = &[
|
| 17 |
+
NestedOp {
|
| 18 |
+
// `fn(f16) -> f16`
|
| 19 |
+
float_ty: FloatTy::F16,
|
| 20 |
+
rust_sig: Signature {
|
| 21 |
+
args: &[Ty::F16],
|
| 22 |
+
returns: &[Ty::F16],
|
| 23 |
+
},
|
| 24 |
+
c_sig: None,
|
| 25 |
+
fn_list: &[
|
| 26 |
+
"ceilf16",
|
| 27 |
+
"fabsf16",
|
| 28 |
+
"floorf16",
|
| 29 |
+
"rintf16",
|
| 30 |
+
"roundevenf16",
|
| 31 |
+
"roundf16",
|
| 32 |
+
"sqrtf16",
|
| 33 |
+
"truncf16",
|
| 34 |
+
],
|
| 35 |
+
public: true,
|
| 36 |
+
},
|
| 37 |
+
NestedOp {
|
| 38 |
+
// `fn(f32) -> f32`
|
| 39 |
+
float_ty: FloatTy::F32,
|
| 40 |
+
rust_sig: Signature {
|
| 41 |
+
args: &[Ty::F32],
|
| 42 |
+
returns: &[Ty::F32],
|
| 43 |
+
},
|
| 44 |
+
c_sig: None,
|
| 45 |
+
fn_list: &[
|
| 46 |
+
"acosf",
|
| 47 |
+
"acoshf",
|
| 48 |
+
"asinf",
|
| 49 |
+
"asinhf",
|
| 50 |
+
"atanf",
|
| 51 |
+
"atanhf",
|
| 52 |
+
"cbrtf",
|
| 53 |
+
"ceilf",
|
| 54 |
+
"cosf",
|
| 55 |
+
"coshf",
|
| 56 |
+
"erfcf",
|
| 57 |
+
"erff",
|
| 58 |
+
"exp10f",
|
| 59 |
+
"exp2f",
|
| 60 |
+
"expf",
|
| 61 |
+
"expm1f",
|
| 62 |
+
"fabsf",
|
| 63 |
+
"floorf",
|
| 64 |
+
"j0f",
|
| 65 |
+
"j1f",
|
| 66 |
+
"lgammaf",
|
| 67 |
+
"log10f",
|
| 68 |
+
"log1pf",
|
| 69 |
+
"log2f",
|
| 70 |
+
"logf",
|
| 71 |
+
"rintf",
|
| 72 |
+
"roundevenf",
|
| 73 |
+
"roundf",
|
| 74 |
+
"sinf",
|
| 75 |
+
"sinhf",
|
| 76 |
+
"sqrtf",
|
| 77 |
+
"tanf",
|
| 78 |
+
"tanhf",
|
| 79 |
+
"tgammaf",
|
| 80 |
+
"truncf",
|
| 81 |
+
"y0f",
|
| 82 |
+
"y1f",
|
| 83 |
+
],
|
| 84 |
+
public: true,
|
| 85 |
+
},
|
| 86 |
+
NestedOp {
|
| 87 |
+
// `(f64) -> f64`
|
| 88 |
+
float_ty: FloatTy::F64,
|
| 89 |
+
rust_sig: Signature {
|
| 90 |
+
args: &[Ty::F64],
|
| 91 |
+
returns: &[Ty::F64],
|
| 92 |
+
},
|
| 93 |
+
c_sig: None,
|
| 94 |
+
fn_list: &[
|
| 95 |
+
"acos",
|
| 96 |
+
"acosh",
|
| 97 |
+
"asin",
|
| 98 |
+
"asinh",
|
| 99 |
+
"atan",
|
| 100 |
+
"atanh",
|
| 101 |
+
"cbrt",
|
| 102 |
+
"ceil",
|
| 103 |
+
"cos",
|
| 104 |
+
"cosh",
|
| 105 |
+
"erf",
|
| 106 |
+
"erfc",
|
| 107 |
+
"exp",
|
| 108 |
+
"exp10",
|
| 109 |
+
"exp2",
|
| 110 |
+
"expm1",
|
| 111 |
+
"fabs",
|
| 112 |
+
"floor",
|
| 113 |
+
"j0",
|
| 114 |
+
"j1",
|
| 115 |
+
"lgamma",
|
| 116 |
+
"log",
|
| 117 |
+
"log10",
|
| 118 |
+
"log1p",
|
| 119 |
+
"log2",
|
| 120 |
+
"rint",
|
| 121 |
+
"round",
|
| 122 |
+
"roundeven",
|
| 123 |
+
"sin",
|
| 124 |
+
"sinh",
|
| 125 |
+
"sqrt",
|
| 126 |
+
"tan",
|
| 127 |
+
"tanh",
|
| 128 |
+
"tgamma",
|
| 129 |
+
"trunc",
|
| 130 |
+
"y0",
|
| 131 |
+
"y1",
|
| 132 |
+
],
|
| 133 |
+
public: true,
|
| 134 |
+
},
|
| 135 |
+
NestedOp {
|
| 136 |
+
// `fn(f128) -> f128`
|
| 137 |
+
float_ty: FloatTy::F128,
|
| 138 |
+
rust_sig: Signature {
|
| 139 |
+
args: &[Ty::F128],
|
| 140 |
+
returns: &[Ty::F128],
|
| 141 |
+
},
|
| 142 |
+
c_sig: None,
|
| 143 |
+
fn_list: &[
|
| 144 |
+
"ceilf128",
|
| 145 |
+
"fabsf128",
|
| 146 |
+
"floorf128",
|
| 147 |
+
"rintf128",
|
| 148 |
+
"roundevenf128",
|
| 149 |
+
"roundf128",
|
| 150 |
+
"sqrtf128",
|
| 151 |
+
"truncf128",
|
| 152 |
+
],
|
| 153 |
+
public: true,
|
| 154 |
+
},
|
| 155 |
+
NestedOp {
|
| 156 |
+
// `(f16, f16) -> f16`
|
| 157 |
+
float_ty: FloatTy::F16,
|
| 158 |
+
rust_sig: Signature {
|
| 159 |
+
args: &[Ty::F16, Ty::F16],
|
| 160 |
+
returns: &[Ty::F16],
|
| 161 |
+
},
|
| 162 |
+
c_sig: None,
|
| 163 |
+
fn_list: &[
|
| 164 |
+
"copysignf16",
|
| 165 |
+
"fdimf16",
|
| 166 |
+
"fmaxf16",
|
| 167 |
+
"fmaximum_numf16",
|
| 168 |
+
"fmaximumf16",
|
| 169 |
+
"fminf16",
|
| 170 |
+
"fminimum_numf16",
|
| 171 |
+
"fminimumf16",
|
| 172 |
+
"fmodf16",
|
| 173 |
+
],
|
| 174 |
+
public: true,
|
| 175 |
+
},
|
| 176 |
+
NestedOp {
|
| 177 |
+
// `(f32, f32) -> f32`
|
| 178 |
+
float_ty: FloatTy::F32,
|
| 179 |
+
rust_sig: Signature {
|
| 180 |
+
args: &[Ty::F32, Ty::F32],
|
| 181 |
+
returns: &[Ty::F32],
|
| 182 |
+
},
|
| 183 |
+
c_sig: None,
|
| 184 |
+
fn_list: &[
|
| 185 |
+
"atan2f",
|
| 186 |
+
"copysignf",
|
| 187 |
+
"fdimf",
|
| 188 |
+
"fmaxf",
|
| 189 |
+
"fmaximum_numf",
|
| 190 |
+
"fmaximumf",
|
| 191 |
+
"fminf",
|
| 192 |
+
"fminimum_numf",
|
| 193 |
+
"fminimumf",
|
| 194 |
+
"fmodf",
|
| 195 |
+
"hypotf",
|
| 196 |
+
"nextafterf",
|
| 197 |
+
"powf",
|
| 198 |
+
"remainderf",
|
| 199 |
+
],
|
| 200 |
+
public: true,
|
| 201 |
+
},
|
| 202 |
+
NestedOp {
|
| 203 |
+
// `(f64, f64) -> f64`
|
| 204 |
+
float_ty: FloatTy::F64,
|
| 205 |
+
rust_sig: Signature {
|
| 206 |
+
args: &[Ty::F64, Ty::F64],
|
| 207 |
+
returns: &[Ty::F64],
|
| 208 |
+
},
|
| 209 |
+
c_sig: None,
|
| 210 |
+
fn_list: &[
|
| 211 |
+
"atan2",
|
| 212 |
+
"copysign",
|
| 213 |
+
"fdim",
|
| 214 |
+
"fmax",
|
| 215 |
+
"fmaximum",
|
| 216 |
+
"fmaximum_num",
|
| 217 |
+
"fmin",
|
| 218 |
+
"fminimum",
|
| 219 |
+
"fminimum_num",
|
| 220 |
+
"fmod",
|
| 221 |
+
"hypot",
|
| 222 |
+
"nextafter",
|
| 223 |
+
"pow",
|
| 224 |
+
"remainder",
|
| 225 |
+
],
|
| 226 |
+
public: true,
|
| 227 |
+
},
|
| 228 |
+
NestedOp {
|
| 229 |
+
// `(f128, f128) -> f128`
|
| 230 |
+
float_ty: FloatTy::F128,
|
| 231 |
+
rust_sig: Signature {
|
| 232 |
+
args: &[Ty::F128, Ty::F128],
|
| 233 |
+
returns: &[Ty::F128],
|
| 234 |
+
},
|
| 235 |
+
c_sig: None,
|
| 236 |
+
fn_list: &[
|
| 237 |
+
"copysignf128",
|
| 238 |
+
"fdimf128",
|
| 239 |
+
"fmaxf128",
|
| 240 |
+
"fmaximum_numf128",
|
| 241 |
+
"fmaximumf128",
|
| 242 |
+
"fminf128",
|
| 243 |
+
"fminimum_numf128",
|
| 244 |
+
"fminimumf128",
|
| 245 |
+
"fmodf128",
|
| 246 |
+
],
|
| 247 |
+
public: true,
|
| 248 |
+
},
|
| 249 |
+
NestedOp {
|
| 250 |
+
// `(f32, f32, f32) -> f32`
|
| 251 |
+
float_ty: FloatTy::F32,
|
| 252 |
+
rust_sig: Signature {
|
| 253 |
+
args: &[Ty::F32, Ty::F32, Ty::F32],
|
| 254 |
+
returns: &[Ty::F32],
|
| 255 |
+
},
|
| 256 |
+
c_sig: None,
|
| 257 |
+
fn_list: &["fmaf"],
|
| 258 |
+
public: true,
|
| 259 |
+
},
|
| 260 |
+
NestedOp {
|
| 261 |
+
// `(f64, f64, f64) -> f64`
|
| 262 |
+
float_ty: FloatTy::F64,
|
| 263 |
+
rust_sig: Signature {
|
| 264 |
+
args: &[Ty::F64, Ty::F64, Ty::F64],
|
| 265 |
+
returns: &[Ty::F64],
|
| 266 |
+
},
|
| 267 |
+
c_sig: None,
|
| 268 |
+
fn_list: &["fma"],
|
| 269 |
+
public: true,
|
| 270 |
+
},
|
| 271 |
+
NestedOp {
|
| 272 |
+
// `(f128, f128, f128) -> f128`
|
| 273 |
+
float_ty: FloatTy::F128,
|
| 274 |
+
rust_sig: Signature {
|
| 275 |
+
args: &[Ty::F128, Ty::F128, Ty::F128],
|
| 276 |
+
returns: &[Ty::F128],
|
| 277 |
+
},
|
| 278 |
+
c_sig: None,
|
| 279 |
+
fn_list: &["fmaf128"],
|
| 280 |
+
public: true,
|
| 281 |
+
},
|
| 282 |
+
NestedOp {
|
| 283 |
+
// `(f32) -> i32`
|
| 284 |
+
float_ty: FloatTy::F32,
|
| 285 |
+
rust_sig: Signature {
|
| 286 |
+
args: &[Ty::F32],
|
| 287 |
+
returns: &[Ty::I32],
|
| 288 |
+
},
|
| 289 |
+
c_sig: None,
|
| 290 |
+
fn_list: &["ilogbf"],
|
| 291 |
+
public: true,
|
| 292 |
+
},
|
| 293 |
+
NestedOp {
|
| 294 |
+
// `(f64) -> i32`
|
| 295 |
+
float_ty: FloatTy::F64,
|
| 296 |
+
rust_sig: Signature {
|
| 297 |
+
args: &[Ty::F64],
|
| 298 |
+
returns: &[Ty::I32],
|
| 299 |
+
},
|
| 300 |
+
c_sig: None,
|
| 301 |
+
fn_list: &["ilogb"],
|
| 302 |
+
public: true,
|
| 303 |
+
},
|
| 304 |
+
NestedOp {
|
| 305 |
+
// `(i32, f32) -> f32`
|
| 306 |
+
float_ty: FloatTy::F32,
|
| 307 |
+
rust_sig: Signature {
|
| 308 |
+
args: &[Ty::I32, Ty::F32],
|
| 309 |
+
returns: &[Ty::F32],
|
| 310 |
+
},
|
| 311 |
+
c_sig: None,
|
| 312 |
+
fn_list: &["jnf", "ynf"],
|
| 313 |
+
public: true,
|
| 314 |
+
},
|
| 315 |
+
NestedOp {
|
| 316 |
+
// `(i32, f64) -> f64`
|
| 317 |
+
float_ty: FloatTy::F64,
|
| 318 |
+
rust_sig: Signature {
|
| 319 |
+
args: &[Ty::I32, Ty::F64],
|
| 320 |
+
returns: &[Ty::F64],
|
| 321 |
+
},
|
| 322 |
+
c_sig: None,
|
| 323 |
+
fn_list: &["jn", "yn"],
|
| 324 |
+
public: true,
|
| 325 |
+
},
|
| 326 |
+
NestedOp {
|
| 327 |
+
// `(f16, i32) -> f16`
|
| 328 |
+
float_ty: FloatTy::F16,
|
| 329 |
+
rust_sig: Signature {
|
| 330 |
+
args: &[Ty::F16, Ty::I32],
|
| 331 |
+
returns: &[Ty::F16],
|
| 332 |
+
},
|
| 333 |
+
c_sig: None,
|
| 334 |
+
fn_list: &["ldexpf16", "scalbnf16"],
|
| 335 |
+
public: true,
|
| 336 |
+
},
|
| 337 |
+
NestedOp {
|
| 338 |
+
// `(f32, i32) -> f32`
|
| 339 |
+
float_ty: FloatTy::F32,
|
| 340 |
+
rust_sig: Signature {
|
| 341 |
+
args: &[Ty::F32, Ty::I32],
|
| 342 |
+
returns: &[Ty::F32],
|
| 343 |
+
},
|
| 344 |
+
c_sig: None,
|
| 345 |
+
fn_list: &["ldexpf", "scalbnf"],
|
| 346 |
+
public: true,
|
| 347 |
+
},
|
| 348 |
+
NestedOp {
|
| 349 |
+
// `(f64, i64) -> f64`
|
| 350 |
+
float_ty: FloatTy::F64,
|
| 351 |
+
rust_sig: Signature {
|
| 352 |
+
args: &[Ty::F64, Ty::I32],
|
| 353 |
+
returns: &[Ty::F64],
|
| 354 |
+
},
|
| 355 |
+
c_sig: None,
|
| 356 |
+
fn_list: &["ldexp", "scalbn"],
|
| 357 |
+
public: true,
|
| 358 |
+
},
|
| 359 |
+
NestedOp {
|
| 360 |
+
// `(f128, i32) -> f128`
|
| 361 |
+
float_ty: FloatTy::F128,
|
| 362 |
+
rust_sig: Signature {
|
| 363 |
+
args: &[Ty::F128, Ty::I32],
|
| 364 |
+
returns: &[Ty::F128],
|
| 365 |
+
},
|
| 366 |
+
c_sig: None,
|
| 367 |
+
fn_list: &["ldexpf128", "scalbnf128"],
|
| 368 |
+
public: true,
|
| 369 |
+
},
|
| 370 |
+
NestedOp {
|
| 371 |
+
// `(f32, &mut f32) -> f32` as `(f32) -> (f32, f32)`
|
| 372 |
+
float_ty: FloatTy::F32,
|
| 373 |
+
rust_sig: Signature {
|
| 374 |
+
args: &[Ty::F32],
|
| 375 |
+
returns: &[Ty::F32, Ty::F32],
|
| 376 |
+
},
|
| 377 |
+
c_sig: Some(Signature {
|
| 378 |
+
args: &[Ty::F32, Ty::MutF32],
|
| 379 |
+
returns: &[Ty::F32],
|
| 380 |
+
}),
|
| 381 |
+
fn_list: &["modff"],
|
| 382 |
+
public: true,
|
| 383 |
+
},
|
| 384 |
+
NestedOp {
|
| 385 |
+
// `(f64, &mut f64) -> f64` as `(f64) -> (f64, f64)`
|
| 386 |
+
float_ty: FloatTy::F64,
|
| 387 |
+
rust_sig: Signature {
|
| 388 |
+
args: &[Ty::F64],
|
| 389 |
+
returns: &[Ty::F64, Ty::F64],
|
| 390 |
+
},
|
| 391 |
+
c_sig: Some(Signature {
|
| 392 |
+
args: &[Ty::F64, Ty::MutF64],
|
| 393 |
+
returns: &[Ty::F64],
|
| 394 |
+
}),
|
| 395 |
+
fn_list: &["modf"],
|
| 396 |
+
public: true,
|
| 397 |
+
},
|
| 398 |
+
NestedOp {
|
| 399 |
+
// `(f32, &mut c_int) -> f32` as `(f32) -> (f32, i32)`
|
| 400 |
+
float_ty: FloatTy::F32,
|
| 401 |
+
rust_sig: Signature {
|
| 402 |
+
args: &[Ty::F32],
|
| 403 |
+
returns: &[Ty::F32, Ty::I32],
|
| 404 |
+
},
|
| 405 |
+
c_sig: Some(Signature {
|
| 406 |
+
args: &[Ty::F32, Ty::MutCInt],
|
| 407 |
+
returns: &[Ty::F32],
|
| 408 |
+
}),
|
| 409 |
+
fn_list: &["frexpf", "lgammaf_r"],
|
| 410 |
+
public: true,
|
| 411 |
+
},
|
| 412 |
+
NestedOp {
|
| 413 |
+
// `(f64, &mut c_int) -> f64` as `(f64) -> (f64, i32)`
|
| 414 |
+
float_ty: FloatTy::F64,
|
| 415 |
+
rust_sig: Signature {
|
| 416 |
+
args: &[Ty::F64],
|
| 417 |
+
returns: &[Ty::F64, Ty::I32],
|
| 418 |
+
},
|
| 419 |
+
c_sig: Some(Signature {
|
| 420 |
+
args: &[Ty::F64, Ty::MutCInt],
|
| 421 |
+
returns: &[Ty::F64],
|
| 422 |
+
}),
|
| 423 |
+
fn_list: &["frexp", "lgamma_r"],
|
| 424 |
+
public: true,
|
| 425 |
+
},
|
| 426 |
+
NestedOp {
|
| 427 |
+
// `(f32, f32, &mut c_int) -> f32` as `(f32, f32) -> (f32, i32)`
|
| 428 |
+
float_ty: FloatTy::F32,
|
| 429 |
+
rust_sig: Signature {
|
| 430 |
+
args: &[Ty::F32, Ty::F32],
|
| 431 |
+
returns: &[Ty::F32, Ty::I32],
|
| 432 |
+
},
|
| 433 |
+
c_sig: Some(Signature {
|
| 434 |
+
args: &[Ty::F32, Ty::F32, Ty::MutCInt],
|
| 435 |
+
returns: &[Ty::F32],
|
| 436 |
+
}),
|
| 437 |
+
fn_list: &["remquof"],
|
| 438 |
+
public: true,
|
| 439 |
+
},
|
| 440 |
+
NestedOp {
|
| 441 |
+
// `(f64, f64, &mut c_int) -> f64` as `(f64, f64) -> (f64, i32)`
|
| 442 |
+
float_ty: FloatTy::F64,
|
| 443 |
+
rust_sig: Signature {
|
| 444 |
+
args: &[Ty::F64, Ty::F64],
|
| 445 |
+
returns: &[Ty::F64, Ty::I32],
|
| 446 |
+
},
|
| 447 |
+
c_sig: Some(Signature {
|
| 448 |
+
args: &[Ty::F64, Ty::F64, Ty::MutCInt],
|
| 449 |
+
returns: &[Ty::F64],
|
| 450 |
+
}),
|
| 451 |
+
fn_list: &["remquo"],
|
| 452 |
+
public: true,
|
| 453 |
+
},
|
| 454 |
+
NestedOp {
|
| 455 |
+
// `(f32, &mut f32, &mut f32)` as `(f32) -> (f32, f32)`
|
| 456 |
+
float_ty: FloatTy::F32,
|
| 457 |
+
rust_sig: Signature {
|
| 458 |
+
args: &[Ty::F32],
|
| 459 |
+
returns: &[Ty::F32, Ty::F32],
|
| 460 |
+
},
|
| 461 |
+
c_sig: Some(Signature {
|
| 462 |
+
args: &[Ty::F32, Ty::MutF32, Ty::MutF32],
|
| 463 |
+
returns: &[],
|
| 464 |
+
}),
|
| 465 |
+
fn_list: &["sincosf"],
|
| 466 |
+
public: true,
|
| 467 |
+
},
|
| 468 |
+
NestedOp {
|
| 469 |
+
// `(f64, &mut f64, &mut f64)` as `(f64) -> (f64, f64)`
|
| 470 |
+
float_ty: FloatTy::F64,
|
| 471 |
+
rust_sig: Signature {
|
| 472 |
+
args: &[Ty::F64],
|
| 473 |
+
returns: &[Ty::F64, Ty::F64],
|
| 474 |
+
},
|
| 475 |
+
c_sig: Some(Signature {
|
| 476 |
+
args: &[Ty::F64, Ty::MutF64, Ty::MutF64],
|
| 477 |
+
returns: &[],
|
| 478 |
+
}),
|
| 479 |
+
fn_list: &["sincos"],
|
| 480 |
+
public: true,
|
| 481 |
+
},
|
| 482 |
+
];
|
| 483 |
+
|
| 484 |
+
/// A type used in a function signature.
|
| 485 |
+
#[allow(dead_code)]
|
| 486 |
+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
| 487 |
+
pub enum Ty {
|
| 488 |
+
F16,
|
| 489 |
+
F32,
|
| 490 |
+
F64,
|
| 491 |
+
F128,
|
| 492 |
+
I32,
|
| 493 |
+
CInt,
|
| 494 |
+
MutF16,
|
| 495 |
+
MutF32,
|
| 496 |
+
MutF64,
|
| 497 |
+
MutF128,
|
| 498 |
+
MutI32,
|
| 499 |
+
MutCInt,
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
/// A subset of [`Ty`] representing only floats.
|
| 503 |
+
#[allow(dead_code)]
|
| 504 |
+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
| 505 |
+
pub enum FloatTy {
|
| 506 |
+
F16,
|
| 507 |
+
F32,
|
| 508 |
+
F64,
|
| 509 |
+
F128,
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
impl fmt::Display for Ty {
|
| 513 |
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
| 514 |
+
let s = match self {
|
| 515 |
+
Ty::F16 => "f16",
|
| 516 |
+
Ty::F32 => "f32",
|
| 517 |
+
Ty::F64 => "f64",
|
| 518 |
+
Ty::F128 => "f128",
|
| 519 |
+
Ty::I32 => "i32",
|
| 520 |
+
Ty::CInt => "::core::ffi::c_int",
|
| 521 |
+
Ty::MutF16 => "&mut f16",
|
| 522 |
+
Ty::MutF32 => "&mut f32",
|
| 523 |
+
Ty::MutF64 => "&mut f64",
|
| 524 |
+
Ty::MutF128 => "&mut f128",
|
| 525 |
+
Ty::MutI32 => "&mut i32",
|
| 526 |
+
Ty::MutCInt => "&mut ::core::ffi::c_int",
|
| 527 |
+
};
|
| 528 |
+
f.write_str(s)
|
| 529 |
+
}
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
impl fmt::Display for FloatTy {
|
| 533 |
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
| 534 |
+
let s = match self {
|
| 535 |
+
FloatTy::F16 => "f16",
|
| 536 |
+
FloatTy::F32 => "f32",
|
| 537 |
+
FloatTy::F64 => "f64",
|
| 538 |
+
FloatTy::F128 => "f128",
|
| 539 |
+
};
|
| 540 |
+
f.write_str(s)
|
| 541 |
+
}
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
/// Representation of e.g. `(f32, f32) -> f32`
|
| 545 |
+
#[derive(Debug, Clone)]
|
| 546 |
+
pub struct Signature {
|
| 547 |
+
pub args: &'static [Ty],
|
| 548 |
+
pub returns: &'static [Ty],
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
/// Combined information about a function implementation.
|
| 552 |
+
#[derive(Debug, Clone)]
|
| 553 |
+
pub struct MathOpInfo {
|
| 554 |
+
pub name: &'static str,
|
| 555 |
+
pub float_ty: FloatTy,
|
| 556 |
+
/// Function signature for C implementations
|
| 557 |
+
pub c_sig: Signature,
|
| 558 |
+
/// Function signature for Rust implementations
|
| 559 |
+
pub rust_sig: Signature,
|
| 560 |
+
/// True if part of libm's public API
|
| 561 |
+
pub public: bool,
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
/// A flat representation of `ALL_FUNCTIONS`.
|
| 565 |
+
pub static ALL_OPERATIONS: LazyLock<Vec<MathOpInfo>> = LazyLock::new(|| {
|
| 566 |
+
let mut ret = Vec::new();
|
| 567 |
+
|
| 568 |
+
for op in ALL_OPERATIONS_NESTED {
|
| 569 |
+
let fn_names = op.fn_list;
|
| 570 |
+
for name in fn_names {
|
| 571 |
+
let api = MathOpInfo {
|
| 572 |
+
name,
|
| 573 |
+
float_ty: op.float_ty,
|
| 574 |
+
rust_sig: op.rust_sig.clone(),
|
| 575 |
+
c_sig: op.c_sig.clone().unwrap_or_else(|| op.rust_sig.clone()),
|
| 576 |
+
public: op.public,
|
| 577 |
+
};
|
| 578 |
+
ret.push(api);
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
if !fn_names.is_sorted() {
|
| 582 |
+
let mut sorted = (*fn_names).to_owned();
|
| 583 |
+
sorted.sort_unstable();
|
| 584 |
+
panic!("names list is not sorted: {fn_names:?}\nExpected: {sorted:?}");
|
| 585 |
+
}
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
ret.sort_by_key(|item| item.name);
|
| 589 |
+
ret
|
| 590 |
+
});
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/Cargo.toml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "musl-math-sys"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
publish = false
|
| 6 |
+
license = "MIT OR Apache-2.0"
|
| 7 |
+
|
| 8 |
+
[dev-dependencies]
|
| 9 |
+
libm.workspace = true
|
| 10 |
+
|
| 11 |
+
[build-dependencies]
|
| 12 |
+
cc.workspace = true
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/build.rs
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use std::collections::BTreeMap;
|
| 2 |
+
use std::path::{Path, PathBuf};
|
| 3 |
+
use std::process::{Command, Stdio};
|
| 4 |
+
use std::{env, fs, str};
|
| 5 |
+
|
| 6 |
+
/// Static library that will be built
|
| 7 |
+
const LIB_NAME: &str = "musl_math_prefixed";
|
| 8 |
+
|
| 9 |
+
/// Files that have more than one symbol. Map of file names to the symbols defined in that file.
|
| 10 |
+
const MULTIPLE_SYMBOLS: &[(&str, &[&str])] = &[
|
| 11 |
+
(
|
| 12 |
+
"__invtrigl",
|
| 13 |
+
&["__invtrigl", "__invtrigl_R", "__pio2_hi", "__pio2_lo"],
|
| 14 |
+
),
|
| 15 |
+
("__polevll", &["__polevll", "__p1evll"]),
|
| 16 |
+
("erf", &["erf", "erfc"]),
|
| 17 |
+
("erff", &["erff", "erfcf"]),
|
| 18 |
+
("erfl", &["erfl", "erfcl"]),
|
| 19 |
+
("exp10", &["exp10", "pow10"]),
|
| 20 |
+
("exp10f", &["exp10f", "pow10f"]),
|
| 21 |
+
("exp10l", &["exp10l", "pow10l"]),
|
| 22 |
+
("exp2f_data", &["exp2f_data", "__exp2f_data"]),
|
| 23 |
+
("exp_data", &["exp_data", "__exp_data"]),
|
| 24 |
+
("j0", &["j0", "y0"]),
|
| 25 |
+
("j0f", &["j0f", "y0f"]),
|
| 26 |
+
("j1", &["j1", "y1"]),
|
| 27 |
+
("j1f", &["j1f", "y1f"]),
|
| 28 |
+
("jn", &["jn", "yn"]),
|
| 29 |
+
("jnf", &["jnf", "ynf"]),
|
| 30 |
+
("lgamma", &["lgamma", "__lgamma_r"]),
|
| 31 |
+
("remainder", &["remainder", "drem"]),
|
| 32 |
+
("remainderf", &["remainderf", "dremf"]),
|
| 33 |
+
("lgammaf", &["lgammaf", "lgammaf_r", "__lgammaf_r"]),
|
| 34 |
+
("lgammal", &["lgammal", "lgammal_r", "__lgammal_r"]),
|
| 35 |
+
("log2_data", &["log2_data", "__log2_data"]),
|
| 36 |
+
("log2f_data", &["log2f_data", "__log2f_data"]),
|
| 37 |
+
("log_data", &["log_data", "__log_data"]),
|
| 38 |
+
("logf_data", &["logf_data", "__logf_data"]),
|
| 39 |
+
("pow_data", &["pow_data", "__pow_log_data"]),
|
| 40 |
+
("powf_data", &["powf_data", "__powf_log2_data"]),
|
| 41 |
+
("signgam", &["signgam", "__signgam"]),
|
| 42 |
+
("sqrt_data", &["sqrt_data", "__rsqrt_tab"]),
|
| 43 |
+
];
|
| 44 |
+
|
| 45 |
+
fn main() {
|
| 46 |
+
let cfg = Config::from_env();
|
| 47 |
+
|
| 48 |
+
if cfg.target_env == "msvc"
|
| 49 |
+
|| cfg.target_families.iter().any(|f| f == "wasm")
|
| 50 |
+
|| cfg.target_features.iter().any(|f| f == "thumb-mode")
|
| 51 |
+
{
|
| 52 |
+
println!(
|
| 53 |
+
"cargo::warning=Musl doesn't compile with the current \
|
| 54 |
+
target {}; skipping build",
|
| 55 |
+
&cfg.target_string
|
| 56 |
+
);
|
| 57 |
+
return;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
build_musl_math(&cfg);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
#[allow(dead_code)]
|
| 64 |
+
#[derive(Debug)]
|
| 65 |
+
struct Config {
|
| 66 |
+
manifest_dir: PathBuf,
|
| 67 |
+
out_dir: PathBuf,
|
| 68 |
+
musl_dir: PathBuf,
|
| 69 |
+
musl_arch: String,
|
| 70 |
+
target_arch: String,
|
| 71 |
+
target_env: String,
|
| 72 |
+
target_families: Vec<String>,
|
| 73 |
+
target_os: String,
|
| 74 |
+
target_string: String,
|
| 75 |
+
target_vendor: String,
|
| 76 |
+
target_features: Vec<String>,
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
impl Config {
|
| 80 |
+
fn from_env() -> Self {
|
| 81 |
+
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
| 82 |
+
let target_families = env::var("CARGO_CFG_TARGET_FAMILY")
|
| 83 |
+
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
|
| 84 |
+
.unwrap_or_default();
|
| 85 |
+
let target_features = env::var("CARGO_CFG_TARGET_FEATURE")
|
| 86 |
+
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
|
| 87 |
+
.unwrap_or_default();
|
| 88 |
+
let musl_dir = manifest_dir.join("musl");
|
| 89 |
+
|
| 90 |
+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
| 91 |
+
let musl_arch = if target_arch == "x86" {
|
| 92 |
+
"i386".to_owned()
|
| 93 |
+
} else {
|
| 94 |
+
target_arch.clone()
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
println!(
|
| 98 |
+
"cargo::rerun-if-changed={}/c_patches",
|
| 99 |
+
manifest_dir.display()
|
| 100 |
+
);
|
| 101 |
+
println!("cargo::rerun-if-changed={}", musl_dir.display());
|
| 102 |
+
|
| 103 |
+
Self {
|
| 104 |
+
manifest_dir,
|
| 105 |
+
out_dir: PathBuf::from(env::var("OUT_DIR").unwrap()),
|
| 106 |
+
musl_dir,
|
| 107 |
+
musl_arch,
|
| 108 |
+
target_arch,
|
| 109 |
+
target_env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),
|
| 110 |
+
target_families,
|
| 111 |
+
target_os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
|
| 112 |
+
target_string: env::var("TARGET").unwrap(),
|
| 113 |
+
target_vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),
|
| 114 |
+
target_features,
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/// Build musl math symbols to a static library
|
| 120 |
+
fn build_musl_math(cfg: &Config) {
|
| 121 |
+
let musl_dir = &cfg.musl_dir;
|
| 122 |
+
let math = musl_dir.join("src/math");
|
| 123 |
+
let arch_dir = musl_dir.join("arch").join(&cfg.musl_arch);
|
| 124 |
+
assert!(
|
| 125 |
+
math.exists(),
|
| 126 |
+
"musl source not found. You may need to run `./ci/update-musl.sh`."
|
| 127 |
+
);
|
| 128 |
+
|
| 129 |
+
let source_map = find_math_source(&math, cfg);
|
| 130 |
+
let out_path = cfg.out_dir.join(format!("lib{LIB_NAME}.a"));
|
| 131 |
+
|
| 132 |
+
// Run configuration steps. Usually done as part of the musl `Makefile`.
|
| 133 |
+
let obj_include = cfg.out_dir.join("musl_obj/include");
|
| 134 |
+
fs::create_dir_all(&obj_include).unwrap();
|
| 135 |
+
fs::create_dir_all(obj_include.join("bits")).unwrap();
|
| 136 |
+
let sed_stat = Command::new("sed")
|
| 137 |
+
.arg("-f")
|
| 138 |
+
.arg(musl_dir.join("tools/mkalltypes.sed"))
|
| 139 |
+
.arg(arch_dir.join("bits/alltypes.h.in"))
|
| 140 |
+
.arg(musl_dir.join("include/alltypes.h.in"))
|
| 141 |
+
.stderr(Stdio::inherit())
|
| 142 |
+
.output()
|
| 143 |
+
.unwrap();
|
| 144 |
+
assert!(
|
| 145 |
+
sed_stat.status.success(),
|
| 146 |
+
"sed command failed: {:?}",
|
| 147 |
+
sed_stat.status
|
| 148 |
+
);
|
| 149 |
+
|
| 150 |
+
fs::write(obj_include.join("bits/alltypes.h"), sed_stat.stdout).unwrap();
|
| 151 |
+
|
| 152 |
+
let mut cbuild = cc::Build::new();
|
| 153 |
+
cbuild
|
| 154 |
+
.extra_warnings(false)
|
| 155 |
+
.warnings(false)
|
| 156 |
+
.flag_if_supported("-Wno-bitwise-op-parentheses")
|
| 157 |
+
.flag_if_supported("-Wno-literal-range")
|
| 158 |
+
.flag_if_supported("-Wno-parentheses")
|
| 159 |
+
.flag_if_supported("-Wno-shift-count-overflow")
|
| 160 |
+
.flag_if_supported("-Wno-shift-op-parentheses")
|
| 161 |
+
.flag_if_supported("-Wno-unused-but-set-variable")
|
| 162 |
+
.flag_if_supported("-std=c99")
|
| 163 |
+
.flag_if_supported("-ffreestanding")
|
| 164 |
+
.flag_if_supported("-nostdinc")
|
| 165 |
+
.define("_ALL_SOURCE", "1")
|
| 166 |
+
.define(
|
| 167 |
+
"ROOT_INCLUDE_FEATURES",
|
| 168 |
+
Some(musl_dir.join("include/features.h").to_str().unwrap()),
|
| 169 |
+
)
|
| 170 |
+
// Our overrides are in this directory
|
| 171 |
+
.include(cfg.manifest_dir.join("c_patches"))
|
| 172 |
+
.include(musl_dir.join("arch").join(&cfg.musl_arch))
|
| 173 |
+
.include(musl_dir.join("arch/generic"))
|
| 174 |
+
.include(musl_dir.join("src/include"))
|
| 175 |
+
.include(musl_dir.join("src/internal"))
|
| 176 |
+
.include(obj_include)
|
| 177 |
+
.include(musl_dir.join("include"))
|
| 178 |
+
.file(cfg.manifest_dir.join("c_patches/alias.c"));
|
| 179 |
+
|
| 180 |
+
for (sym_name, src_file) in source_map {
|
| 181 |
+
// Build the source file
|
| 182 |
+
cbuild.file(src_file);
|
| 183 |
+
|
| 184 |
+
// Trickery! Redefine the symbol names to have the prefix `musl_`, which allows us to
|
| 185 |
+
// differentiate these symbols from whatever we provide.
|
| 186 |
+
if let Some((_names, syms)) = MULTIPLE_SYMBOLS
|
| 187 |
+
.iter()
|
| 188 |
+
.find(|(name, _syms)| *name == sym_name)
|
| 189 |
+
{
|
| 190 |
+
// Handle the occasional file that defines multiple symbols
|
| 191 |
+
for sym in *syms {
|
| 192 |
+
cbuild.define(sym, Some(format!("musl_{sym}").as_str()));
|
| 193 |
+
}
|
| 194 |
+
} else {
|
| 195 |
+
// If the file doesn't define multiple symbols, the file name will be the symbol
|
| 196 |
+
cbuild.define(&sym_name, Some(format!("musl_{sym_name}").as_str()));
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
if cfg!(windows) {
|
| 201 |
+
// On Windows we don't have a good way to check symbols, so skip that step.
|
| 202 |
+
cbuild.compile(LIB_NAME);
|
| 203 |
+
return;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
let objfiles = cbuild.compile_intermediates();
|
| 207 |
+
|
| 208 |
+
// We create the archive ourselves with relocations rather than letting `cc` do it so we can
|
| 209 |
+
// encourage it to resolve symbols now. This should help avoid accidentally linking the wrong
|
| 210 |
+
// thing.
|
| 211 |
+
let stat = cbuild
|
| 212 |
+
.get_compiler()
|
| 213 |
+
.to_command()
|
| 214 |
+
.arg("-r")
|
| 215 |
+
.arg("-o")
|
| 216 |
+
.arg(&out_path)
|
| 217 |
+
.args(objfiles)
|
| 218 |
+
.status()
|
| 219 |
+
.unwrap();
|
| 220 |
+
assert!(stat.success());
|
| 221 |
+
|
| 222 |
+
println!("cargo::rustc-link-lib={LIB_NAME}");
|
| 223 |
+
println!("cargo::rustc-link-search=native={}", cfg.out_dir.display());
|
| 224 |
+
|
| 225 |
+
validate_archive_symbols(&out_path);
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
/// Build a map of `name -> path`. `name` is typically the symbol name, but this doesn't account
|
| 229 |
+
/// for files that provide multiple symbols.
|
| 230 |
+
fn find_math_source(math_root: &Path, cfg: &Config) -> BTreeMap<String, PathBuf> {
|
| 231 |
+
let mut map = BTreeMap::new();
|
| 232 |
+
let mut arch_dir = None;
|
| 233 |
+
|
| 234 |
+
// Locate all files and directories
|
| 235 |
+
for item in fs::read_dir(math_root).unwrap() {
|
| 236 |
+
let path = item.unwrap().path();
|
| 237 |
+
let meta = fs::metadata(&path).unwrap();
|
| 238 |
+
|
| 239 |
+
if meta.is_dir() {
|
| 240 |
+
// Make note of the arch-specific directory if it exists
|
| 241 |
+
if path.file_name().unwrap() == cfg.target_arch.as_str() {
|
| 242 |
+
arch_dir = Some(path);
|
| 243 |
+
}
|
| 244 |
+
continue;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
// Skip non-source files
|
| 248 |
+
if path.extension().is_some_and(|ext| ext == "h") {
|
| 249 |
+
continue;
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
let sym_name = path.file_stem().unwrap();
|
| 253 |
+
map.insert(sym_name.to_str().unwrap().to_owned(), path.to_owned());
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
// If arch-specific versions are available, build those instead.
|
| 257 |
+
if let Some(arch_dir) = arch_dir {
|
| 258 |
+
for item in fs::read_dir(arch_dir).unwrap() {
|
| 259 |
+
let path = item.unwrap().path();
|
| 260 |
+
let sym_name = path.file_stem().unwrap();
|
| 261 |
+
|
| 262 |
+
if path.extension().unwrap() == "s" {
|
| 263 |
+
// FIXME: we never build assembly versions since we have no good way to
|
| 264 |
+
// rename the symbol (our options are probably preprocessor or objcopy).
|
| 265 |
+
continue;
|
| 266 |
+
}
|
| 267 |
+
map.insert(sym_name.to_str().unwrap().to_owned(), path);
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
map
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
/// Make sure we don't have something like a loose unprefixed `_cos` called somewhere, which could
|
| 275 |
+
/// wind up linking to system libraries rather than the built musl library.
|
| 276 |
+
fn validate_archive_symbols(out_path: &Path) {
|
| 277 |
+
const ALLOWED_UNDEF_PFX: &[&str] = &[
|
| 278 |
+
// PIC and arch-specific
|
| 279 |
+
".TOC",
|
| 280 |
+
"_GLOBAL_OFFSET_TABLE_",
|
| 281 |
+
"__x86.get_pc_thunk",
|
| 282 |
+
// gcc/compiler-rt/compiler-builtins symbols
|
| 283 |
+
"__add",
|
| 284 |
+
"__aeabi_",
|
| 285 |
+
"__div",
|
| 286 |
+
"__eq",
|
| 287 |
+
"__extend",
|
| 288 |
+
"__fix",
|
| 289 |
+
"__float",
|
| 290 |
+
"__gcc_",
|
| 291 |
+
"__ge",
|
| 292 |
+
"__gt",
|
| 293 |
+
"__le",
|
| 294 |
+
"__lshr",
|
| 295 |
+
"__lt",
|
| 296 |
+
"__mul",
|
| 297 |
+
"__ne",
|
| 298 |
+
"__stack_chk_fail",
|
| 299 |
+
"__stack_chk_guard",
|
| 300 |
+
"__sub",
|
| 301 |
+
"__trunc",
|
| 302 |
+
"__undef",
|
| 303 |
+
// string routines
|
| 304 |
+
"__bzero",
|
| 305 |
+
"bzero",
|
| 306 |
+
// FPENV interfaces
|
| 307 |
+
"feclearexcept",
|
| 308 |
+
"fegetround",
|
| 309 |
+
"feraiseexcept",
|
| 310 |
+
"fesetround",
|
| 311 |
+
"fetestexcept",
|
| 312 |
+
];
|
| 313 |
+
|
| 314 |
+
// List global undefined symbols
|
| 315 |
+
let out = Command::new("nm")
|
| 316 |
+
.arg("-guj")
|
| 317 |
+
.arg(out_path)
|
| 318 |
+
.stderr(Stdio::inherit())
|
| 319 |
+
.output()
|
| 320 |
+
.unwrap();
|
| 321 |
+
|
| 322 |
+
let undef = str::from_utf8(&out.stdout).unwrap();
|
| 323 |
+
let mut undef = undef.lines().collect::<Vec<_>>();
|
| 324 |
+
undef.retain(|sym| {
|
| 325 |
+
// Account for file formats that add a leading `_`
|
| 326 |
+
!ALLOWED_UNDEF_PFX
|
| 327 |
+
.iter()
|
| 328 |
+
.any(|pfx| sym.starts_with(pfx) || sym[1..].starts_with(pfx))
|
| 329 |
+
});
|
| 330 |
+
|
| 331 |
+
assert!(
|
| 332 |
+
undef.is_empty(),
|
| 333 |
+
"found disallowed undefined symbols: {undef:#?}"
|
| 334 |
+
);
|
| 335 |
+
|
| 336 |
+
// Find any symbols that are missing the `_musl_` prefix`
|
| 337 |
+
let out = Command::new("nm")
|
| 338 |
+
.arg("-gUj")
|
| 339 |
+
.arg(out_path)
|
| 340 |
+
.stderr(Stdio::inherit())
|
| 341 |
+
.output()
|
| 342 |
+
.unwrap();
|
| 343 |
+
|
| 344 |
+
let defined = str::from_utf8(&out.stdout).unwrap();
|
| 345 |
+
let mut defined = defined.lines().collect::<Vec<_>>();
|
| 346 |
+
defined.retain(|sym| {
|
| 347 |
+
!(sym.starts_with("_musl_")
|
| 348 |
+
|| sym.starts_with("musl_")
|
| 349 |
+
|| sym.starts_with("__x86.get_pc_thunk"))
|
| 350 |
+
});
|
| 351 |
+
|
| 352 |
+
assert!(defined.is_empty(), "found unprefixed symbols: {defined:#?}");
|
| 353 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/c_patches/alias.c
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* On platforms that don't support weak symbols, define required aliases
|
| 2 |
+
* as wrappers. See comments in `features.h` for more.
|
| 3 |
+
*/
|
| 4 |
+
#if defined(__APPLE__) || defined(__MINGW32__)
|
| 5 |
+
|
| 6 |
+
double __lgamma_r(double a, int *b);
|
| 7 |
+
float __lgammaf_r(float a, int *b);
|
| 8 |
+
long __lgammal_r(long double a, int *b);
|
| 9 |
+
double exp10(double a);
|
| 10 |
+
float exp10f(float a);
|
| 11 |
+
long exp10l(long double a);
|
| 12 |
+
double remainder(double a, double b);
|
| 13 |
+
float remainderf(float a, float b);
|
| 14 |
+
|
| 15 |
+
double lgamma_r(double a, int *b) {
|
| 16 |
+
return __lgamma_r(a, b);
|
| 17 |
+
}
|
| 18 |
+
float lgammaf_r(float a, int *b) {
|
| 19 |
+
return __lgammaf_r(a, b);
|
| 20 |
+
}
|
| 21 |
+
long double lgammal_r(long double a, int *b) {
|
| 22 |
+
return __lgammal_r(a, b);
|
| 23 |
+
}
|
| 24 |
+
double pow10(double a) {
|
| 25 |
+
return exp10(a);
|
| 26 |
+
}
|
| 27 |
+
float pow10f(float a) {
|
| 28 |
+
return exp10f(a);
|
| 29 |
+
}
|
| 30 |
+
long double pow10l(long double a) {
|
| 31 |
+
return exp10l(a);
|
| 32 |
+
}
|
| 33 |
+
double drem(double a, double b) {
|
| 34 |
+
return remainder(a, b);
|
| 35 |
+
}
|
| 36 |
+
float dremf(float a, float b) {
|
| 37 |
+
return remainderf(a, b);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
#endif
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/c_patches/features.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This is meant to override Musl's src/include/features.h
|
| 2 |
+
*
|
| 3 |
+
* We use a separate file here to redefine some attributes that don't work on
|
| 4 |
+
* all platforms that we would like to build on.
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
#ifndef FEATURES_H
|
| 8 |
+
#define FEATURES_H
|
| 9 |
+
|
| 10 |
+
/* Get the required `#include "../../include/features.h"` since we can't use
|
| 11 |
+
* the relative path. The C macros need double indirection to get a usable
|
| 12 |
+
* string. */
|
| 13 |
+
#define _stringify_inner(s) #s
|
| 14 |
+
#define _stringify(s) _stringify_inner(s)
|
| 15 |
+
#include _stringify(ROOT_INCLUDE_FEATURES)
|
| 16 |
+
|
| 17 |
+
#if defined(__APPLE__)
|
| 18 |
+
#define weak __attribute__((__weak__))
|
| 19 |
+
#define hidden __attribute__((__visibility__("hidden")))
|
| 20 |
+
|
| 21 |
+
/* We _should_ be able to define this as:
|
| 22 |
+
* _Pragma(_stringify(weak musl_ ## new = musl_ ## old))
|
| 23 |
+
* However, weak symbols aren't handled correctly [1]. So we manually write
|
| 24 |
+
* wrappers, which are in `alias.c`.
|
| 25 |
+
*
|
| 26 |
+
* [1]: https://github.com/llvm/llvm-project/issues/111321
|
| 27 |
+
*/
|
| 28 |
+
#define weak_alias(old, new) /* nothing */
|
| 29 |
+
|
| 30 |
+
#else
|
| 31 |
+
#define weak __attribute__((__weak__))
|
| 32 |
+
#define hidden __attribute__((__visibility__("hidden")))
|
| 33 |
+
#define weak_alias(old, new) \
|
| 34 |
+
extern __typeof(old) musl_ ## new \
|
| 35 |
+
__attribute__((__weak__, __alias__(_stringify(musl_ ## old))))
|
| 36 |
+
|
| 37 |
+
#endif /* defined(__APPLE__) */
|
| 38 |
+
|
| 39 |
+
#endif
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/musl-math-sys/src/lib.rs
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Bindings to Musl math functions (these are built in `build.rs`).
|
| 2 |
+
|
| 3 |
+
use std::ffi::{c_char, c_int, c_long};
|
| 4 |
+
|
| 5 |
+
/// Macro for creating bindings and exposing a safe function (since the implementations have no
|
| 6 |
+
/// preconditions). Included functions must have correct signatures, otherwise this will be
|
| 7 |
+
/// unsound.
|
| 8 |
+
macro_rules! functions {
|
| 9 |
+
( $(
|
| 10 |
+
$( #[$meta:meta] )*
|
| 11 |
+
$pfx_name:ident: $name:ident( $($arg:ident: $aty:ty),+ ) -> $rty:ty;
|
| 12 |
+
)* ) => {
|
| 13 |
+
unsafe extern "C" {
|
| 14 |
+
$( fn $pfx_name( $($arg: $aty),+ ) -> $rty; )*
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
$(
|
| 18 |
+
// Expose a safe version
|
| 19 |
+
$( #[$meta] )*
|
| 20 |
+
pub fn $name( $($arg: $aty),+ ) -> $rty {
|
| 21 |
+
// SAFETY: FFI calls with no preconditions
|
| 22 |
+
unsafe { $pfx_name( $($arg),+ ) }
|
| 23 |
+
}
|
| 24 |
+
)*
|
| 25 |
+
|
| 26 |
+
#[cfg(test)]
|
| 27 |
+
mod tests {
|
| 28 |
+
use super::*;
|
| 29 |
+
use test_support::CallTest;
|
| 30 |
+
|
| 31 |
+
$( functions!(
|
| 32 |
+
@single_test
|
| 33 |
+
$name($($arg: $aty),+) -> $rty
|
| 34 |
+
); )*
|
| 35 |
+
}
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
(@single_test
|
| 39 |
+
$name:ident( $($arg:ident: $aty:ty),+ ) -> $rty:ty
|
| 40 |
+
) => {
|
| 41 |
+
// Run a simple check to ensure we can link and call the function without crashing.
|
| 42 |
+
#[test]
|
| 43 |
+
fn $name() {
|
| 44 |
+
<fn($($aty),+) -> $rty>::check(super::$name);
|
| 45 |
+
}
|
| 46 |
+
};
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
#[cfg(test)]
|
| 50 |
+
mod test_support {
|
| 51 |
+
use core::ffi::c_char;
|
| 52 |
+
|
| 53 |
+
/// Just verify that we are able to call the function.
|
| 54 |
+
pub trait CallTest {
|
| 55 |
+
fn check(f: Self);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
macro_rules! impl_calltest {
|
| 59 |
+
($( ($($arg:ty),*) -> $ret:ty; )*) => {
|
| 60 |
+
$(
|
| 61 |
+
impl CallTest for fn($($arg),*) -> $ret {
|
| 62 |
+
fn check(f: Self) {
|
| 63 |
+
f($(1 as $arg),*);
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
)*
|
| 67 |
+
};
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
impl_calltest! {
|
| 71 |
+
(f32) -> f32;
|
| 72 |
+
(f64) -> f64;
|
| 73 |
+
(f32, f32) -> f32;
|
| 74 |
+
(f64, f64) -> f64;
|
| 75 |
+
(i32, f32) -> f32;
|
| 76 |
+
(i32, f64) -> f64;
|
| 77 |
+
(f32, f32, f32) -> f32;
|
| 78 |
+
(f64, f64, f64) -> f64;
|
| 79 |
+
(f32, i32) -> f32;
|
| 80 |
+
(f32, i64) -> f32;
|
| 81 |
+
(f32) -> i32;
|
| 82 |
+
(f64) -> i32;
|
| 83 |
+
(f64, i32) -> f64;
|
| 84 |
+
(f64, i64) -> f64;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
impl CallTest for fn(f32, &mut f32) -> f32 {
|
| 88 |
+
fn check(f: Self) {
|
| 89 |
+
let mut tmp = 0.0;
|
| 90 |
+
f(0.0, &mut tmp);
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
impl CallTest for fn(f64, &mut f64) -> f64 {
|
| 94 |
+
fn check(f: Self) {
|
| 95 |
+
let mut tmp = 0.0;
|
| 96 |
+
f(0.0, &mut tmp);
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
impl CallTest for fn(f32, &mut i32) -> f32 {
|
| 100 |
+
fn check(f: Self) {
|
| 101 |
+
let mut tmp = 1;
|
| 102 |
+
f(0.0, &mut tmp);
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
impl CallTest for fn(f64, &mut i32) -> f64 {
|
| 106 |
+
fn check(f: Self) {
|
| 107 |
+
let mut tmp = 1;
|
| 108 |
+
f(0.0, &mut tmp);
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
impl CallTest for fn(f32, f32, &mut i32) -> f32 {
|
| 112 |
+
fn check(f: Self) {
|
| 113 |
+
let mut tmp = 1;
|
| 114 |
+
f(0.0, 0.0, &mut tmp);
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
impl CallTest for fn(f64, f64, &mut i32) -> f64 {
|
| 118 |
+
fn check(f: Self) {
|
| 119 |
+
let mut tmp = 1;
|
| 120 |
+
f(0.0, 0.0, &mut tmp);
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
impl CallTest for fn(f32, &mut f32, &mut f32) {
|
| 124 |
+
fn check(f: Self) {
|
| 125 |
+
let mut tmp1 = 1.0;
|
| 126 |
+
let mut tmp2 = 1.0;
|
| 127 |
+
f(0.0, &mut tmp1, &mut tmp2);
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
impl CallTest for fn(f64, &mut f64, &mut f64) {
|
| 131 |
+
fn check(f: Self) {
|
| 132 |
+
let mut tmp1 = 1.0;
|
| 133 |
+
let mut tmp2 = 1.0;
|
| 134 |
+
f(0.0, &mut tmp1, &mut tmp2);
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
impl CallTest for fn(*const c_char) -> f32 {
|
| 138 |
+
fn check(f: Self) {
|
| 139 |
+
f(c"1".as_ptr());
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
impl CallTest for fn(*const c_char) -> f64 {
|
| 143 |
+
fn check(f: Self) {
|
| 144 |
+
f(c"1".as_ptr());
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
functions! {
|
| 150 |
+
musl_acos: acos(a: f64) -> f64;
|
| 151 |
+
musl_acosf: acosf(a: f32) -> f32;
|
| 152 |
+
musl_acosh: acosh(a: f64) -> f64;
|
| 153 |
+
musl_acoshf: acoshf(a: f32) -> f32;
|
| 154 |
+
musl_asin: asin(a: f64) -> f64;
|
| 155 |
+
musl_asinf: asinf(a: f32) -> f32;
|
| 156 |
+
musl_asinh: asinh(a: f64) -> f64;
|
| 157 |
+
musl_asinhf: asinhf(a: f32) -> f32;
|
| 158 |
+
musl_atan2: atan2(a: f64, b: f64) -> f64;
|
| 159 |
+
musl_atan2f: atan2f(a: f32, b: f32) -> f32;
|
| 160 |
+
musl_atan: atan(a: f64) -> f64;
|
| 161 |
+
musl_atanf: atanf(a: f32) -> f32;
|
| 162 |
+
musl_atanh: atanh(a: f64) -> f64;
|
| 163 |
+
musl_atanhf: atanhf(a: f32) -> f32;
|
| 164 |
+
musl_cbrt: cbrt(a: f64) -> f64;
|
| 165 |
+
musl_cbrtf: cbrtf(a: f32) -> f32;
|
| 166 |
+
musl_ceil: ceil(a: f64) -> f64;
|
| 167 |
+
musl_ceilf: ceilf(a: f32) -> f32;
|
| 168 |
+
musl_copysign: copysign(a: f64, b: f64) -> f64;
|
| 169 |
+
musl_copysignf: copysignf(a: f32, b: f32) -> f32;
|
| 170 |
+
musl_cos: cos(a: f64) -> f64;
|
| 171 |
+
musl_cosf: cosf(a: f32) -> f32;
|
| 172 |
+
musl_cosh: cosh(a: f64) -> f64;
|
| 173 |
+
musl_coshf: coshf(a: f32) -> f32;
|
| 174 |
+
musl_drem: drem(a: f64, b: f64) -> f64;
|
| 175 |
+
musl_dremf: dremf(a: f32, b: f32) -> f32;
|
| 176 |
+
musl_erf: erf(a: f64) -> f64;
|
| 177 |
+
musl_erfc: erfc(a: f64) -> f64;
|
| 178 |
+
musl_erfcf: erfcf(a: f32) -> f32;
|
| 179 |
+
musl_erff: erff(a: f32) -> f32;
|
| 180 |
+
musl_exp10: exp10(a: f64) -> f64;
|
| 181 |
+
musl_exp10f: exp10f(a: f32) -> f32;
|
| 182 |
+
musl_exp2: exp2(a: f64) -> f64;
|
| 183 |
+
musl_exp2f: exp2f(a: f32) -> f32;
|
| 184 |
+
musl_exp: exp(a: f64) -> f64;
|
| 185 |
+
musl_expf: expf(a: f32) -> f32;
|
| 186 |
+
musl_expm1: expm1(a: f64) -> f64;
|
| 187 |
+
musl_expm1f: expm1f(a: f32) -> f32;
|
| 188 |
+
musl_fabs: fabs(a: f64) -> f64;
|
| 189 |
+
musl_fabsf: fabsf(a: f32) -> f32;
|
| 190 |
+
musl_fdim: fdim(a: f64, b: f64) -> f64;
|
| 191 |
+
musl_fdimf: fdimf(a: f32, b: f32) -> f32;
|
| 192 |
+
musl_finite: finite(a: f64) -> c_int;
|
| 193 |
+
musl_finitef: finitef(a: f32) -> c_int;
|
| 194 |
+
musl_floor: floor(a: f64) -> f64;
|
| 195 |
+
musl_floorf: floorf(a: f32) -> f32;
|
| 196 |
+
musl_fma: fma(a: f64, b: f64, c: f64) -> f64;
|
| 197 |
+
musl_fmaf: fmaf(a: f32, b: f32, c: f32) -> f32;
|
| 198 |
+
musl_fmax: fmax(a: f64, b: f64) -> f64;
|
| 199 |
+
musl_fmaxf: fmaxf(a: f32, b: f32) -> f32;
|
| 200 |
+
musl_fmin: fmin(a: f64, b: f64) -> f64;
|
| 201 |
+
musl_fminf: fminf(a: f32, b: f32) -> f32;
|
| 202 |
+
musl_fmod: fmod(a: f64, b: f64) -> f64;
|
| 203 |
+
musl_fmodf: fmodf(a: f32, b: f32) -> f32;
|
| 204 |
+
musl_frexp: frexp(a: f64, b: &mut c_int) -> f64;
|
| 205 |
+
musl_frexpf: frexpf(a: f32, b: &mut c_int) -> f32;
|
| 206 |
+
musl_hypot: hypot(a: f64, b: f64) -> f64;
|
| 207 |
+
musl_hypotf: hypotf(a: f32, b: f32) -> f32;
|
| 208 |
+
musl_ilogb: ilogb(a: f64) -> c_int;
|
| 209 |
+
musl_ilogbf: ilogbf(a: f32) -> c_int;
|
| 210 |
+
musl_j0: j0(a: f64) -> f64;
|
| 211 |
+
musl_j0f: j0f(a: f32) -> f32;
|
| 212 |
+
musl_j1: j1(a: f64) -> f64;
|
| 213 |
+
musl_j1f: j1f(a: f32) -> f32;
|
| 214 |
+
musl_jn: jn(a: c_int, b: f64) -> f64;
|
| 215 |
+
musl_jnf: jnf(a: c_int, b: f32) -> f32;
|
| 216 |
+
musl_ldexp: ldexp(a: f64, b: c_int) -> f64;
|
| 217 |
+
musl_ldexpf: ldexpf(a: f32, b: c_int) -> f32;
|
| 218 |
+
musl_lgamma: lgamma(a: f64) -> f64;
|
| 219 |
+
musl_lgamma_r: lgamma_r(a: f64, b: &mut c_int) -> f64;
|
| 220 |
+
musl_lgammaf: lgammaf(a: f32) -> f32;
|
| 221 |
+
musl_lgammaf_r: lgammaf_r(a: f32, b: &mut c_int) -> f32;
|
| 222 |
+
musl_log10: log10(a: f64) -> f64;
|
| 223 |
+
musl_log10f: log10f(a: f32) -> f32;
|
| 224 |
+
musl_log1p: log1p(a: f64) -> f64;
|
| 225 |
+
musl_log1pf: log1pf(a: f32) -> f32;
|
| 226 |
+
musl_log2: log2(a: f64) -> f64;
|
| 227 |
+
musl_log2f: log2f(a: f32) -> f32;
|
| 228 |
+
musl_log: log(a: f64) -> f64;
|
| 229 |
+
musl_logb: logb(a: f64) -> f64;
|
| 230 |
+
musl_logbf: logbf(a: f32) -> f32;
|
| 231 |
+
musl_logf: logf(a: f32) -> f32;
|
| 232 |
+
musl_modf: modf(a: f64, b: &mut f64) -> f64;
|
| 233 |
+
musl_modff: modff(a: f32, b: &mut f32) -> f32;
|
| 234 |
+
|
| 235 |
+
// FIXME: these need to be unsafe
|
| 236 |
+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
|
| 237 |
+
musl_nan: nan(a: *const c_char) -> f64;
|
| 238 |
+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
|
| 239 |
+
musl_nanf: nanf(a: *const c_char) -> f32;
|
| 240 |
+
|
| 241 |
+
musl_nearbyint: nearbyint(a: f64) -> f64;
|
| 242 |
+
musl_nearbyintf: nearbyintf(a: f32) -> f32;
|
| 243 |
+
musl_nextafter: nextafter(a: f64, b: f64) -> f64;
|
| 244 |
+
musl_nextafterf: nextafterf(a: f32, b: f32) -> f32;
|
| 245 |
+
musl_pow10: pow10(a: f64) -> f64;
|
| 246 |
+
musl_pow10f: pow10f(a: f32) -> f32;
|
| 247 |
+
musl_pow: pow(a: f64, b: f64) -> f64;
|
| 248 |
+
musl_powf: powf(a: f32, b: f32) -> f32;
|
| 249 |
+
musl_remainder: remainder(a: f64, b: f64) -> f64;
|
| 250 |
+
musl_remainderf: remainderf(a: f32, b: f32) -> f32;
|
| 251 |
+
musl_remquo: remquo(a: f64, b: f64, c: &mut c_int) -> f64;
|
| 252 |
+
musl_remquof: remquof(a: f32, b: f32, c: &mut c_int) -> f32;
|
| 253 |
+
musl_rint: rint(a: f64) -> f64;
|
| 254 |
+
musl_rintf: rintf(a: f32) -> f32;
|
| 255 |
+
musl_round: round(a: f64) -> f64;
|
| 256 |
+
musl_roundf: roundf(a: f32) -> f32;
|
| 257 |
+
musl_scalbln: scalbln(a: f64, b: c_long) -> f64;
|
| 258 |
+
musl_scalblnf: scalblnf(a: f32, b: c_long) -> f32;
|
| 259 |
+
musl_scalbn: scalbn(a: f64, b: c_int) -> f64;
|
| 260 |
+
musl_scalbnf: scalbnf(a: f32, b: c_int) -> f32;
|
| 261 |
+
musl_significand: significand(a: f64) -> f64;
|
| 262 |
+
musl_significandf: significandf(a: f32) -> f32;
|
| 263 |
+
musl_sin: sin(a: f64) -> f64;
|
| 264 |
+
musl_sincos: sincos(a: f64, b: &mut f64, c: &mut f64) -> ();
|
| 265 |
+
musl_sincosf: sincosf(a: f32, b: &mut f32, c: &mut f32) -> ();
|
| 266 |
+
musl_sinf: sinf(a: f32) -> f32;
|
| 267 |
+
musl_sinh: sinh(a: f64) -> f64;
|
| 268 |
+
musl_sinhf: sinhf(a: f32) -> f32;
|
| 269 |
+
musl_sqrt: sqrt(a: f64) -> f64;
|
| 270 |
+
musl_sqrtf: sqrtf(a: f32) -> f32;
|
| 271 |
+
musl_tan: tan(a: f64) -> f64;
|
| 272 |
+
musl_tanf: tanf(a: f32) -> f32;
|
| 273 |
+
musl_tanh: tanh(a: f64) -> f64;
|
| 274 |
+
musl_tanhf: tanhf(a: f32) -> f32;
|
| 275 |
+
musl_tgamma: tgamma(a: f64) -> f64;
|
| 276 |
+
musl_tgammaf: tgammaf(a: f32) -> f32;
|
| 277 |
+
musl_trunc: trunc(a: f64) -> f64;
|
| 278 |
+
musl_truncf: truncf(a: f32) -> f32;
|
| 279 |
+
musl_y0: y0(a: f64) -> f64;
|
| 280 |
+
musl_y0f: y0f(a: f32) -> f32;
|
| 281 |
+
musl_y1: y1(a: f64) -> f64;
|
| 282 |
+
musl_y1f: y1f(a: f32) -> f32;
|
| 283 |
+
musl_yn: yn(a: c_int, b: f64) -> f64;
|
| 284 |
+
musl_ynf: ynf(a: c_int, b: f32) -> f32;
|
| 285 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/panic-handler/Cargo.toml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "panic-handler"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
publish = false
|
| 6 |
+
|
| 7 |
+
[lib]
|
| 8 |
+
test = false
|
| 9 |
+
bench = false
|
| 10 |
+
|
| 11 |
+
[dependencies]
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/panic-handler/src/lib.rs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! This is needed for tests on targets that require a `#[panic_handler]` function
|
| 2 |
+
|
| 3 |
+
#![no_std]
|
| 4 |
+
|
| 5 |
+
#[panic_handler]
|
| 6 |
+
fn panic(_: &core::panic::PanicInfo<'_>) -> ! {
|
| 7 |
+
loop {}
|
| 8 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/Cargo.toml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "symbol-check"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
publish = false
|
| 6 |
+
|
| 7 |
+
[dependencies]
|
| 8 |
+
object.workspace = true
|
| 9 |
+
regex.workspace = true
|
| 10 |
+
serde_json.workspace = true
|
| 11 |
+
|
| 12 |
+
[dev-dependencies]
|
| 13 |
+
assert_cmd.workspace = true
|
| 14 |
+
cc.workspace = true
|
| 15 |
+
tempfile.workspace = true
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/build.rs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use std::env;
|
| 2 |
+
|
| 3 |
+
fn main() {
|
| 4 |
+
println!("cargo::rustc-env=HOST={}", env::var("HOST").unwrap());
|
| 5 |
+
println!("cargo::rustc-env=TARGET={}", env::var("TARGET").unwrap());
|
| 6 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/src/main.rs
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Tool used by CI to inspect compiler-builtins archives and help ensure we won't run into any
|
| 2 |
+
//! linking errors.
|
| 3 |
+
//!
|
| 4 |
+
//! Note that symcheck is a "hostprog", i.e. is built and run on the host target even when the
|
| 5 |
+
//! actual target is cross compiled.
|
| 6 |
+
|
| 7 |
+
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
| 8 |
+
use std::fs;
|
| 9 |
+
use std::io::{BufRead, BufReader};
|
| 10 |
+
use std::path::{Path, PathBuf};
|
| 11 |
+
use std::process::{Command, Stdio};
|
| 12 |
+
use std::sync::LazyLock;
|
| 13 |
+
|
| 14 |
+
use object::read::archive::ArchiveFile;
|
| 15 |
+
use object::{
|
| 16 |
+
File as ObjFile, Object, ObjectSection, ObjectSymbol, Result as ObjResult, Symbol, SymbolKind,
|
| 17 |
+
SymbolScope,
|
| 18 |
+
};
|
| 19 |
+
use regex::Regex;
|
| 20 |
+
use serde_json::Value;
|
| 21 |
+
|
| 22 |
+
const CHECK_LIBRARIES: &[&str] = &["compiler_builtins", "builtins_test_intrinsics"];
|
| 23 |
+
const CHECK_EXTENSIONS: &[Option<&str>] = &[Some("rlib"), Some("a"), Some("exe"), None];
|
| 24 |
+
|
| 25 |
+
const USAGE: &str = "Usage:
|
| 26 |
+
|
| 27 |
+
symbol-check build-and-check [TARGET] -- CARGO_BUILD_ARGS ...
|
| 28 |
+
|
| 29 |
+
Cargo will get invoked with `CARGO_ARGS` and the specified target. All output
|
| 30 |
+
`compiler_builtins*.rlib` files will be checked.
|
| 31 |
+
|
| 32 |
+
If TARGET is not specified, the host target is used.
|
| 33 |
+
|
| 34 |
+
check PATHS ...
|
| 35 |
+
|
| 36 |
+
Run the same checks on the given set of paths, without invoking Cargo. Paths
|
| 37 |
+
may be either archives or object files.
|
| 38 |
+
";
|
| 39 |
+
|
| 40 |
+
fn main() {
|
| 41 |
+
// Create a `&str` vec so we can match on it.
|
| 42 |
+
let args = std::env::args().collect::<Vec<_>>();
|
| 43 |
+
let args_ref = args.iter().map(String::as_str).collect::<Vec<_>>();
|
| 44 |
+
|
| 45 |
+
match &args_ref[1..] {
|
| 46 |
+
["build-and-check", target, "--", args @ ..] if !args.is_empty() => {
|
| 47 |
+
run_build_and_check(target, args);
|
| 48 |
+
}
|
| 49 |
+
["build-and-check", "--", args @ ..] if !args.is_empty() => {
|
| 50 |
+
run_build_and_check(env!("HOST"), args);
|
| 51 |
+
}
|
| 52 |
+
["check", paths @ ..] if !paths.is_empty() => {
|
| 53 |
+
check_paths(paths);
|
| 54 |
+
}
|
| 55 |
+
_ => {
|
| 56 |
+
println!("{USAGE}");
|
| 57 |
+
std::process::exit(1);
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
fn run_build_and_check(target: &str, args: &[&str]) {
|
| 63 |
+
// Make sure `--target` isn't passed to avoid confusion (since it should be
|
| 64 |
+
// proivded only once, positionally).
|
| 65 |
+
for arg in args {
|
| 66 |
+
assert!(
|
| 67 |
+
!arg.contains("--target"),
|
| 68 |
+
"target must be passed positionally. {USAGE}"
|
| 69 |
+
);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
let paths = exec_cargo_with_args(target, args);
|
| 73 |
+
check_paths(&paths);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
fn check_paths<P: AsRef<Path>>(paths: &[P]) {
|
| 77 |
+
for path in paths {
|
| 78 |
+
let path = path.as_ref();
|
| 79 |
+
println!("Checking {}", path.display());
|
| 80 |
+
let archive = BinFile::from_path(path);
|
| 81 |
+
|
| 82 |
+
verify_no_duplicates(&archive);
|
| 83 |
+
verify_core_symbols(&archive);
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/// Run `cargo build` with the provided additional arguments, collecting the list of created
|
| 88 |
+
/// libraries.
|
| 89 |
+
fn exec_cargo_with_args(target: &str, args: &[&str]) -> Vec<PathBuf> {
|
| 90 |
+
let mut cmd = Command::new("cargo");
|
| 91 |
+
cmd.args([
|
| 92 |
+
"build",
|
| 93 |
+
"--target",
|
| 94 |
+
target,
|
| 95 |
+
"--message-format=json-diagnostic-rendered-ansi",
|
| 96 |
+
])
|
| 97 |
+
.args(args)
|
| 98 |
+
.stdout(Stdio::piped());
|
| 99 |
+
|
| 100 |
+
println!("running: {cmd:?}");
|
| 101 |
+
let mut child = cmd.spawn().expect("failed to launch Cargo");
|
| 102 |
+
|
| 103 |
+
let stdout = child.stdout.take().unwrap();
|
| 104 |
+
let reader = BufReader::new(stdout);
|
| 105 |
+
let mut check_files = Vec::new();
|
| 106 |
+
|
| 107 |
+
for line in reader.lines() {
|
| 108 |
+
let line = line.expect("failed to read line");
|
| 109 |
+
let j: Value = serde_json::from_str(&line).expect("failed to deserialize");
|
| 110 |
+
let reason = &j["reason"];
|
| 111 |
+
|
| 112 |
+
// Forward output that is meant to be user-facing
|
| 113 |
+
if reason == "compiler-message" {
|
| 114 |
+
println!("{}", j["message"]["rendered"].as_str().unwrap());
|
| 115 |
+
} else if reason == "build-finished" {
|
| 116 |
+
println!("build finshed. success: {}", j["success"]);
|
| 117 |
+
} else if reason == "build-script-executed" {
|
| 118 |
+
let pretty = serde_json::to_string_pretty(&j).unwrap();
|
| 119 |
+
println!("build script output: {pretty}",);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
// Only interested in the artifact list now
|
| 123 |
+
if reason != "compiler-artifact" {
|
| 124 |
+
continue;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
// Find rlibs in the created file list that match our expected library names and
|
| 128 |
+
// extensions.
|
| 129 |
+
for fpath in j["filenames"].as_array().expect("filenames not an array") {
|
| 130 |
+
let path = fpath.as_str().expect("file name not a string");
|
| 131 |
+
let path = PathBuf::from(path);
|
| 132 |
+
|
| 133 |
+
if CHECK_EXTENSIONS.contains(&path.extension().map(|ex| ex.to_str().unwrap())) {
|
| 134 |
+
let fname = path.file_name().unwrap().to_str().unwrap();
|
| 135 |
+
|
| 136 |
+
if CHECK_LIBRARIES.iter().any(|lib| fname.contains(lib)) {
|
| 137 |
+
check_files.push(path);
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
assert!(child.wait().expect("failed to wait on Cargo").success());
|
| 144 |
+
|
| 145 |
+
assert!(!check_files.is_empty(), "no compiler_builtins rlibs found");
|
| 146 |
+
println!("Collected the following rlibs to check: {check_files:#?}");
|
| 147 |
+
|
| 148 |
+
check_files
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/// Information collected from `object`, for convenience.
|
| 152 |
+
#[expect(unused)] // only for printing
|
| 153 |
+
#[derive(Clone, Debug)]
|
| 154 |
+
struct SymInfo {
|
| 155 |
+
name: String,
|
| 156 |
+
kind: SymbolKind,
|
| 157 |
+
scope: SymbolScope,
|
| 158 |
+
section: String,
|
| 159 |
+
is_undefined: bool,
|
| 160 |
+
is_global: bool,
|
| 161 |
+
is_local: bool,
|
| 162 |
+
is_weak: bool,
|
| 163 |
+
is_common: bool,
|
| 164 |
+
address: u64,
|
| 165 |
+
object: String,
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
impl SymInfo {
|
| 169 |
+
fn new(sym: &Symbol, obj: &ObjFile, obj_path: &str) -> Self {
|
| 170 |
+
// Include the section name if possible. Fall back to the `Section` debug impl if not.
|
| 171 |
+
let section = sym.section();
|
| 172 |
+
let section_name = sym
|
| 173 |
+
.section()
|
| 174 |
+
.index()
|
| 175 |
+
.and_then(|idx| obj.section_by_index(idx).ok())
|
| 176 |
+
.and_then(|sec| sec.name().ok())
|
| 177 |
+
.map(ToString::to_string)
|
| 178 |
+
.unwrap_or_else(|| format!("{section:?}"));
|
| 179 |
+
|
| 180 |
+
Self {
|
| 181 |
+
name: sym.name().expect("missing name").to_owned(),
|
| 182 |
+
kind: sym.kind(),
|
| 183 |
+
scope: sym.scope(),
|
| 184 |
+
section: section_name,
|
| 185 |
+
is_undefined: sym.is_undefined(),
|
| 186 |
+
is_global: sym.is_global(),
|
| 187 |
+
is_local: sym.is_local(),
|
| 188 |
+
is_weak: sym.is_weak(),
|
| 189 |
+
is_common: sym.is_common(),
|
| 190 |
+
address: sym.address(),
|
| 191 |
+
object: obj_path.to_owned(),
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
/// Ensure that the same global symbol isn't defined in multiple object files within an archive.
|
| 197 |
+
///
|
| 198 |
+
/// Note that this will also locate cases where a symbol is weakly defined in more than one place.
|
| 199 |
+
/// Technically there are no linker errors that will come from this, but it keeps our binary more
|
| 200 |
+
/// straightforward and saves some distribution size.
|
| 201 |
+
fn verify_no_duplicates(archive: &BinFile) {
|
| 202 |
+
let mut syms = BTreeMap::<String, SymInfo>::new();
|
| 203 |
+
let mut dups = Vec::new();
|
| 204 |
+
let mut found_any = false;
|
| 205 |
+
|
| 206 |
+
archive.for_each_symbol(|symbol, obj, member| {
|
| 207 |
+
// Only check defined globals
|
| 208 |
+
if !symbol.is_global() || symbol.is_undefined() {
|
| 209 |
+
return;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
let sym = SymInfo::new(&symbol, obj, member);
|
| 213 |
+
|
| 214 |
+
// x86-32 includes multiple copies of thunk symbols
|
| 215 |
+
if sym.name.starts_with("__x86.get_pc_thunk") {
|
| 216 |
+
return;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
// GDB pretty printing symbols may show up more than once but are weak.
|
| 220 |
+
if sym.section == ".debug_gdb_scripts" && sym.is_weak {
|
| 221 |
+
return;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
// Windows has symbols for literal numeric constants, string literals, and MinGW pseudo-
|
| 225 |
+
// relocations. These are allowed to have repeated definitions.
|
| 226 |
+
let win_allowed_dup_pfx = ["__real@", "__xmm@", "__ymm@", "??_C@_", ".refptr"];
|
| 227 |
+
if win_allowed_dup_pfx
|
| 228 |
+
.iter()
|
| 229 |
+
.any(|pfx| sym.name.starts_with(pfx))
|
| 230 |
+
{
|
| 231 |
+
return;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
match syms.get(&sym.name) {
|
| 235 |
+
Some(existing) => {
|
| 236 |
+
dups.push(sym);
|
| 237 |
+
dups.push(existing.clone());
|
| 238 |
+
}
|
| 239 |
+
None => {
|
| 240 |
+
syms.insert(sym.name.clone(), sym);
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
found_any = true;
|
| 245 |
+
});
|
| 246 |
+
|
| 247 |
+
assert!(found_any, "no symbols found");
|
| 248 |
+
|
| 249 |
+
if !dups.is_empty() {
|
| 250 |
+
let count = dups.iter().map(|x| &x.name).collect::<HashSet<_>>().len();
|
| 251 |
+
dups.sort_unstable_by(|a, b| a.name.cmp(&b.name));
|
| 252 |
+
panic!("found {count} duplicate symbols: {dups:#?}");
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
println!(" success: no duplicate symbols found");
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
/// Ensure that there are no references to symbols from `core` that aren't also (somehow) defined.
|
| 259 |
+
fn verify_core_symbols(archive: &BinFile) {
|
| 260 |
+
// Match both mangling styles:
|
| 261 |
+
//
|
| 262 |
+
// * `_ZN4core3str8converts9from_utf817hd4454ac14cbbb790E` (old)
|
| 263 |
+
// * `_RNvNtNtCscK9O3IwVk7N_4core3str8converts9from_utf8` (v0)
|
| 264 |
+
//
|
| 265 |
+
// Also account for the Apple leading `_`.
|
| 266 |
+
static RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"^_?_[RZ].*4core").unwrap());
|
| 267 |
+
|
| 268 |
+
let mut defined = BTreeSet::new();
|
| 269 |
+
let mut undefined = Vec::new();
|
| 270 |
+
let mut has_symbols = false;
|
| 271 |
+
|
| 272 |
+
archive.for_each_symbol(|symbol, obj, member| {
|
| 273 |
+
has_symbols = true;
|
| 274 |
+
|
| 275 |
+
// Find only symbols from `core`
|
| 276 |
+
if !RE.is_match(symbol.name().unwrap()) {
|
| 277 |
+
return;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
let sym = SymInfo::new(&symbol, obj, member);
|
| 281 |
+
if sym.is_undefined {
|
| 282 |
+
undefined.push(sym);
|
| 283 |
+
} else {
|
| 284 |
+
defined.insert(sym.name);
|
| 285 |
+
}
|
| 286 |
+
});
|
| 287 |
+
|
| 288 |
+
assert!(has_symbols, "no symbols found");
|
| 289 |
+
|
| 290 |
+
// Discard any symbols that are defined somewhere in the archive
|
| 291 |
+
undefined.retain(|sym| !defined.contains(&sym.name));
|
| 292 |
+
|
| 293 |
+
if !undefined.is_empty() {
|
| 294 |
+
undefined.sort_unstable_by(|a, b| a.name.cmp(&b.name));
|
| 295 |
+
panic!(
|
| 296 |
+
"found {} undefined symbols from core: {undefined:#?}",
|
| 297 |
+
undefined.len()
|
| 298 |
+
);
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
println!(" success: no undefined references to core found");
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
/// Thin wrapper for owning data used by `object`.
|
| 305 |
+
struct BinFile {
|
| 306 |
+
path: PathBuf,
|
| 307 |
+
data: Vec<u8>,
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
impl BinFile {
|
| 311 |
+
fn from_path(path: &Path) -> Self {
|
| 312 |
+
Self {
|
| 313 |
+
path: path.to_owned(),
|
| 314 |
+
data: fs::read(path).expect("reading file failed"),
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
fn as_archive_file(&self) -> ObjResult<ArchiveFile<'_>> {
|
| 319 |
+
ArchiveFile::parse(self.data.as_slice())
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
fn as_obj_file(&self) -> ObjResult<ObjFile<'_>> {
|
| 323 |
+
ObjFile::parse(self.data.as_slice())
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
/// For a given archive, do something with each object file. For an object file, do
|
| 327 |
+
/// something once.
|
| 328 |
+
fn for_each_object(&self, mut f: impl FnMut(ObjFile, &str)) {
|
| 329 |
+
// Try as an archive first.
|
| 330 |
+
let as_archive = self.as_archive_file();
|
| 331 |
+
if let Ok(archive) = as_archive {
|
| 332 |
+
for member in archive.members() {
|
| 333 |
+
let member = member.expect("failed to access member");
|
| 334 |
+
let obj_data = member
|
| 335 |
+
.data(self.data.as_slice())
|
| 336 |
+
.expect("failed to access object");
|
| 337 |
+
let obj = ObjFile::parse(obj_data).expect("failed to parse object");
|
| 338 |
+
f(obj, &String::from_utf8_lossy(member.name()));
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
return;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
// Fall back to parsing as an object file.
|
| 345 |
+
let as_obj = self.as_obj_file();
|
| 346 |
+
if let Ok(obj) = as_obj {
|
| 347 |
+
f(obj, &self.path.to_string_lossy());
|
| 348 |
+
return;
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
panic!(
|
| 352 |
+
"failed to parse as either archive or object file: {:?}, {:?}",
|
| 353 |
+
as_archive.unwrap_err(),
|
| 354 |
+
as_obj.unwrap_err(),
|
| 355 |
+
);
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
/// D something with each symbol in an archive or object file.
|
| 359 |
+
fn for_each_symbol(&self, mut f: impl FnMut(Symbol, &ObjFile, &str)) {
|
| 360 |
+
self.for_each_object(|obj, obj_path| {
|
| 361 |
+
obj.symbols().for_each(|sym| f(sym, &obj, obj_path));
|
| 362 |
+
});
|
| 363 |
+
}
|
| 364 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/tests/all.rs
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use std::env;
|
| 2 |
+
use std::ffi::OsString;
|
| 3 |
+
use std::path::{Path, PathBuf};
|
| 4 |
+
use std::process::{Command, Stdio};
|
| 5 |
+
use std::sync::LazyLock;
|
| 6 |
+
|
| 7 |
+
use assert_cmd::assert::Assert;
|
| 8 |
+
use assert_cmd::cargo::cargo_bin_cmd;
|
| 9 |
+
use tempfile::tempdir;
|
| 10 |
+
|
| 11 |
+
trait AssertExt {
|
| 12 |
+
fn stderr_contains(self, s: &str) -> Self;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
impl AssertExt for Assert {
|
| 16 |
+
fn stderr_contains(self, s: &str) -> Self {
|
| 17 |
+
let out = String::from_utf8_lossy(&self.get_output().stderr);
|
| 18 |
+
assert!(out.contains(s), "looking for: `{s}`\nout:\n```\n{out}\n```");
|
| 19 |
+
self
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
#[test]
|
| 24 |
+
fn test_duplicates() {
|
| 25 |
+
let dir = tempdir().unwrap();
|
| 26 |
+
let dup_out = dir.path().join("dup.o");
|
| 27 |
+
let lib_out = dir.path().join("libfoo.rlib");
|
| 28 |
+
|
| 29 |
+
// For the "bad" file, we need duplicate symbols from different object files in the archive. Do
|
| 30 |
+
// this reliably by building an archive and a separate object file then merging them.
|
| 31 |
+
rustc_build(&input_dir().join("duplicates.rs"), &lib_out, |cmd| cmd);
|
| 32 |
+
rustc_build(&input_dir().join("duplicates.rs"), &dup_out, |cmd| {
|
| 33 |
+
cmd.arg("--emit=obj")
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
let mut ar = cc_build().get_archiver();
|
| 37 |
+
|
| 38 |
+
if ar.get_program().to_string_lossy().contains("lib.exe") {
|
| 39 |
+
let mut out_arg = OsString::from("-out:");
|
| 40 |
+
out_arg.push(&lib_out);
|
| 41 |
+
ar.arg(&out_arg);
|
| 42 |
+
// Repeating the same file as the first arg makes lib.exe append (taken from the
|
| 43 |
+
// `cc` implementation).
|
| 44 |
+
ar.arg(&lib_out);
|
| 45 |
+
} else {
|
| 46 |
+
ar.arg("rs")
|
| 47 |
+
// Eat an `libfoo.rlib(lib.rmeta) has no symbols` info message on MacOS
|
| 48 |
+
.stderr(Stdio::null())
|
| 49 |
+
.arg(&lib_out);
|
| 50 |
+
}
|
| 51 |
+
let status = ar.arg(&dup_out).status().unwrap();
|
| 52 |
+
assert!(status.success());
|
| 53 |
+
|
| 54 |
+
let assert = cargo_bin_cmd!().arg("check").arg(&lib_out).assert();
|
| 55 |
+
assert
|
| 56 |
+
.failure()
|
| 57 |
+
.stderr_contains("duplicate symbols")
|
| 58 |
+
.stderr_contains("FDUP")
|
| 59 |
+
.stderr_contains("IDUP")
|
| 60 |
+
.stderr_contains("fndup");
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
#[test]
|
| 64 |
+
fn test_core_symbols() {
|
| 65 |
+
let dir = tempdir().unwrap();
|
| 66 |
+
let lib_out = dir.path().join("libfoo.rlib");
|
| 67 |
+
rustc_build(&input_dir().join("core_symbols.rs"), &lib_out, |cmd| cmd);
|
| 68 |
+
let assert = cargo_bin_cmd!().arg("check").arg(&lib_out).assert();
|
| 69 |
+
assert
|
| 70 |
+
.failure()
|
| 71 |
+
.stderr_contains("found 1 undefined symbols from core")
|
| 72 |
+
.stderr_contains("from_utf8");
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
#[test]
|
| 76 |
+
fn test_good() {
|
| 77 |
+
let dir = tempdir().unwrap();
|
| 78 |
+
let lib_out = dir.path().join("libfoo.rlib");
|
| 79 |
+
rustc_build(&input_dir().join("good.rs"), &lib_out, |cmd| cmd);
|
| 80 |
+
let assert = cargo_bin_cmd!().arg("check").arg(&lib_out).assert();
|
| 81 |
+
assert.success();
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/// Build i -> o with optional additional configuration.
|
| 85 |
+
fn rustc_build(i: &Path, o: &Path, mut f: impl FnMut(&mut Command) -> &mut Command) {
|
| 86 |
+
let mut cmd = Command::new("rustc");
|
| 87 |
+
cmd.arg(i)
|
| 88 |
+
.arg("--target")
|
| 89 |
+
.arg(target())
|
| 90 |
+
.arg("--crate-type=lib")
|
| 91 |
+
.arg("-o")
|
| 92 |
+
.arg(o);
|
| 93 |
+
f(&mut cmd);
|
| 94 |
+
let status = cmd.status().unwrap();
|
| 95 |
+
assert!(status.success());
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/// Configure `cc` with the host and target.
|
| 99 |
+
fn cc_build() -> cc::Build {
|
| 100 |
+
let mut b = cc::Build::new();
|
| 101 |
+
b.host(env!("HOST")).target(&target());
|
| 102 |
+
b
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/// Symcheck runs on the host but we want to verify that we find issues on all targets, so
|
| 106 |
+
/// the cross target may be specified.
|
| 107 |
+
fn target() -> String {
|
| 108 |
+
static TARGET: LazyLock<String> = LazyLock::new(|| {
|
| 109 |
+
let target = match env::var("SYMCHECK_TEST_TARGET") {
|
| 110 |
+
Ok(t) => t,
|
| 111 |
+
// Require on CI so we don't accidentally always test the native target
|
| 112 |
+
_ if env::var("CI").is_ok() => panic!("SYMCHECK_TEST_TARGET must be set in CI"),
|
| 113 |
+
// Fall back to native for local convenience.
|
| 114 |
+
Err(_) => env!("HOST").to_string(),
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
println!("using target {target}");
|
| 118 |
+
target
|
| 119 |
+
});
|
| 120 |
+
|
| 121 |
+
TARGET.clone()
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
fn input_dir() -> PathBuf {
|
| 125 |
+
Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/input")
|
| 126 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/tests/input/core_symbols.rs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Ensure we catch calls to `core`.
|
| 2 |
+
|
| 3 |
+
#![no_std]
|
| 4 |
+
|
| 5 |
+
#[unsafe(no_mangle)]
|
| 6 |
+
pub fn call_from_core(s: &[u8]) -> &str {
|
| 7 |
+
match core::str::from_utf8(&s) {
|
| 8 |
+
Ok(s) => s,
|
| 9 |
+
Err(_) => "",
|
| 10 |
+
}
|
| 11 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/tests/input/duplicates.rs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Ensure we catch duplicate symbols (the duplicates are in the aux file). Gets built twice
|
| 2 |
+
//! as separate object files.
|
| 3 |
+
|
| 4 |
+
#![no_std]
|
| 5 |
+
|
| 6 |
+
#[unsafe(no_mangle)]
|
| 7 |
+
static IDUP: i32 = 0;
|
| 8 |
+
#[unsafe(no_mangle)]
|
| 9 |
+
static FDUP: f32 = 0.0;
|
| 10 |
+
|
| 11 |
+
#[unsafe(no_mangle)]
|
| 12 |
+
pub fn fndup() {}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/symbol-check/tests/input/good.rs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#![no_std]
|
| 2 |
+
|
| 3 |
+
#[unsafe(no_mangle)]
|
| 4 |
+
pub fn good() {}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/util/Cargo.toml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "util"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
publish = false
|
| 6 |
+
license = "MIT OR Apache-2.0"
|
| 7 |
+
|
| 8 |
+
[dependencies]
|
| 9 |
+
libm.workspace = true
|
| 10 |
+
libm-macros.workspace = true
|
| 11 |
+
libm-test.workspace = true
|
| 12 |
+
musl-math-sys = { workspace = true, optional = true }
|
| 13 |
+
rug = { workspace = true, optional = true }
|
| 14 |
+
|
| 15 |
+
[features]
|
| 16 |
+
default = ["build-musl", "build-mpfr", "unstable-float"]
|
| 17 |
+
build-musl = ["libm-test/build-musl", "dep:musl-math-sys"]
|
| 18 |
+
build-mpfr = ["libm-test/build-mpfr", "dep:rug"]
|
| 19 |
+
unstable-float = ["libm/unstable-float", "libm-test/unstable-float", "rug?/nightly-float"]
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/util/build.rs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#![allow(unexpected_cfgs)]
|
| 2 |
+
|
| 3 |
+
#[path = "../../libm/configure.rs"]
|
| 4 |
+
mod configure;
|
| 5 |
+
|
| 6 |
+
fn main() {
|
| 7 |
+
println!("cargo:rerun-if-changed=../../libm/configure.rs");
|
| 8 |
+
let cfg = configure::Config::from_env();
|
| 9 |
+
configure::emit_libm_config(&cfg);
|
| 10 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/crates/util/src/main.rs
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Helper CLI utility for common tasks.
|
| 2 |
+
|
| 3 |
+
#![cfg_attr(f16_enabled, feature(f16))]
|
| 4 |
+
#![cfg_attr(f128_enabled, feature(f128))]
|
| 5 |
+
|
| 6 |
+
use std::any::type_name;
|
| 7 |
+
use std::env;
|
| 8 |
+
use std::num::ParseIntError;
|
| 9 |
+
use std::str::FromStr;
|
| 10 |
+
|
| 11 |
+
use libm::support::{Hexf, hf32, hf64};
|
| 12 |
+
#[cfg(feature = "build-mpfr")]
|
| 13 |
+
use libm_test::mpfloat::MpOp;
|
| 14 |
+
use libm_test::{MathOp, TupleCall};
|
| 15 |
+
#[cfg(feature = "build-mpfr")]
|
| 16 |
+
use rug::az::{self, Az};
|
| 17 |
+
|
| 18 |
+
const USAGE: &str = "\
|
| 19 |
+
usage:
|
| 20 |
+
|
| 21 |
+
cargo run -p util -- <SUBCOMMAND>
|
| 22 |
+
|
| 23 |
+
SUBCOMMAND:
|
| 24 |
+
eval <BASIS> <OP> inputs...
|
| 25 |
+
Evaulate the expression with a given basis. This can be useful for
|
| 26 |
+
running routines with a debugger, or quickly checking input. Examples:
|
| 27 |
+
* eval musl sinf 1.234 # print the results of musl sinf(1.234f32)
|
| 28 |
+
* eval mpfr pow 1.234 2.432 # print the results of mpfr pow(1.234, 2.432)
|
| 29 |
+
";
|
| 30 |
+
|
| 31 |
+
fn main() {
|
| 32 |
+
let args = env::args().collect::<Vec<_>>();
|
| 33 |
+
let str_args = args.iter().map(|s| s.as_str()).collect::<Vec<_>>();
|
| 34 |
+
|
| 35 |
+
match &str_args.as_slice()[1..] {
|
| 36 |
+
["eval", basis, op, inputs @ ..] => do_eval(basis, op, inputs),
|
| 37 |
+
_ => {
|
| 38 |
+
println!("{USAGE}\nunrecognized input `{str_args:?}`");
|
| 39 |
+
std::process::exit(1);
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
macro_rules! handle_call {
|
| 45 |
+
(
|
| 46 |
+
fn_name: $fn_name:ident,
|
| 47 |
+
CFn: $CFn:ty,
|
| 48 |
+
RustFn: $RustFn:ty,
|
| 49 |
+
RustArgs: $RustArgs:ty,
|
| 50 |
+
attrs: [$($attr:meta),*],
|
| 51 |
+
extra: ($basis:ident, $op:ident, $inputs:ident),
|
| 52 |
+
fn_extra: $musl_fn:expr,
|
| 53 |
+
) => {
|
| 54 |
+
$(#[$attr])*
|
| 55 |
+
if $op == stringify!($fn_name) {
|
| 56 |
+
type Op = libm_test::op::$fn_name::Routine;
|
| 57 |
+
|
| 58 |
+
let input = <$RustArgs>::parse($inputs);
|
| 59 |
+
let libm_fn: <Op as MathOp>::RustFn = libm::$fn_name;
|
| 60 |
+
|
| 61 |
+
let output = match $basis {
|
| 62 |
+
"libm" => input.call_intercept_panics(libm_fn),
|
| 63 |
+
#[cfg(feature = "build-musl")]
|
| 64 |
+
"musl" => {
|
| 65 |
+
let musl_fn: <Op as MathOp>::CFn =
|
| 66 |
+
$musl_fn.unwrap_or_else(|| panic!("no musl function for {}", $op));
|
| 67 |
+
input.call(musl_fn)
|
| 68 |
+
}
|
| 69 |
+
#[cfg(feature = "build-mpfr")]
|
| 70 |
+
"mpfr" => {
|
| 71 |
+
let mut mp = <Op as MpOp>::new_mp();
|
| 72 |
+
Op::run(&mut mp, input)
|
| 73 |
+
}
|
| 74 |
+
_ => panic!("unrecognized or disabled basis '{}'", $basis),
|
| 75 |
+
};
|
| 76 |
+
println!("{output:?} {:x}", Hexf(output));
|
| 77 |
+
return;
|
| 78 |
+
}
|
| 79 |
+
};
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/// Evaluate the specified operation with a given basis.
|
| 83 |
+
fn do_eval(basis: &str, op: &str, inputs: &[&str]) {
|
| 84 |
+
libm_macros::for_each_function! {
|
| 85 |
+
callback: handle_call,
|
| 86 |
+
emit_types: [CFn, RustFn, RustArgs],
|
| 87 |
+
extra: (basis, op, inputs),
|
| 88 |
+
fn_extra: match MACRO_FN_NAME {
|
| 89 |
+
// Not provided by musl
|
| 90 |
+
fmaximum
|
| 91 |
+
| fmaximum_num
|
| 92 |
+
| fmaximum_numf
|
| 93 |
+
| fmaximumf
|
| 94 |
+
| fminimum
|
| 95 |
+
| fminimum_num
|
| 96 |
+
| fminimum_numf
|
| 97 |
+
| fminimumf
|
| 98 |
+
| roundeven
|
| 99 |
+
| roundevenf
|
| 100 |
+
| ALL_F16
|
| 101 |
+
| ALL_F128 => None,
|
| 102 |
+
_ => Some(musl_math_sys::MACRO_FN_NAME)
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
panic!("no operation matching {op}");
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
/// Parse a tuple from a space-delimited string.
|
| 110 |
+
trait ParseTuple {
|
| 111 |
+
fn parse(input: &[&str]) -> Self;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
macro_rules! impl_parse_tuple {
|
| 115 |
+
($ty:ty) => {
|
| 116 |
+
impl ParseTuple for ($ty,) {
|
| 117 |
+
fn parse(input: &[&str]) -> Self {
|
| 118 |
+
assert_eq!(input.len(), 1, "expected a single argument, got {input:?}");
|
| 119 |
+
(parse(input, 0),)
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
impl ParseTuple for ($ty, $ty) {
|
| 124 |
+
fn parse(input: &[&str]) -> Self {
|
| 125 |
+
assert_eq!(input.len(), 2, "expected two arguments, got {input:?}");
|
| 126 |
+
(parse(input, 0), parse(input, 1))
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
impl ParseTuple for ($ty, i32) {
|
| 131 |
+
fn parse(input: &[&str]) -> Self {
|
| 132 |
+
assert_eq!(input.len(), 2, "expected two arguments, got {input:?}");
|
| 133 |
+
(parse(input, 0), parse(input, 1))
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
impl ParseTuple for (i32, $ty) {
|
| 138 |
+
fn parse(input: &[&str]) -> Self {
|
| 139 |
+
assert_eq!(input.len(), 2, "expected two arguments, got {input:?}");
|
| 140 |
+
(parse(input, 0), parse(input, 1))
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
impl ParseTuple for ($ty, $ty, $ty) {
|
| 145 |
+
fn parse(input: &[&str]) -> Self {
|
| 146 |
+
assert_eq!(input.len(), 3, "expected three arguments, got {input:?}");
|
| 147 |
+
(parse(input, 0), parse(input, 1), parse(input, 2))
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
};
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
#[allow(unused_macros)]
|
| 154 |
+
#[cfg(feature = "build-mpfr")]
|
| 155 |
+
macro_rules! impl_parse_tuple_via_rug {
|
| 156 |
+
($ty:ty) => {
|
| 157 |
+
impl ParseTuple for ($ty,) {
|
| 158 |
+
fn parse(input: &[&str]) -> Self {
|
| 159 |
+
assert_eq!(input.len(), 1, "expected a single argument, got {input:?}");
|
| 160 |
+
(parse_rug(input, 0),)
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
impl ParseTuple for ($ty, $ty) {
|
| 165 |
+
fn parse(input: &[&str]) -> Self {
|
| 166 |
+
assert_eq!(input.len(), 2, "expected two arguments, got {input:?}");
|
| 167 |
+
(parse_rug(input, 0), parse_rug(input, 1))
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
impl ParseTuple for ($ty, i32) {
|
| 172 |
+
fn parse(input: &[&str]) -> Self {
|
| 173 |
+
assert_eq!(input.len(), 2, "expected two arguments, got {input:?}");
|
| 174 |
+
(parse_rug(input, 0), parse(input, 1))
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
impl ParseTuple for (i32, $ty) {
|
| 179 |
+
fn parse(input: &[&str]) -> Self {
|
| 180 |
+
assert_eq!(input.len(), 2, "expected two arguments, got {input:?}");
|
| 181 |
+
(parse(input, 0), parse_rug(input, 1))
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
impl ParseTuple for ($ty, $ty, $ty) {
|
| 186 |
+
fn parse(input: &[&str]) -> Self {
|
| 187 |
+
assert_eq!(input.len(), 3, "expected three arguments, got {input:?}");
|
| 188 |
+
(
|
| 189 |
+
parse_rug(input, 0),
|
| 190 |
+
parse_rug(input, 1),
|
| 191 |
+
parse_rug(input, 2),
|
| 192 |
+
)
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
};
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
// Fallback for when Rug is not built.
|
| 199 |
+
#[allow(unused_macros)]
|
| 200 |
+
#[cfg(not(feature = "build-mpfr"))]
|
| 201 |
+
macro_rules! impl_parse_tuple_via_rug {
|
| 202 |
+
($ty:ty) => {
|
| 203 |
+
impl ParseTuple for ($ty,) {
|
| 204 |
+
fn parse(_input: &[&str]) -> Self {
|
| 205 |
+
panic!("parsing this type requires the `build-mpfr` feature")
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
impl ParseTuple for ($ty, $ty) {
|
| 210 |
+
fn parse(_input: &[&str]) -> Self {
|
| 211 |
+
panic!("parsing this type requires the `build-mpfr` feature")
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
impl ParseTuple for ($ty, i32) {
|
| 216 |
+
fn parse(_input: &[&str]) -> Self {
|
| 217 |
+
panic!("parsing this type requires the `build-mpfr` feature")
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
impl ParseTuple for (i32, $ty) {
|
| 222 |
+
fn parse(_input: &[&str]) -> Self {
|
| 223 |
+
panic!("parsing this type requires the `build-mpfr` feature")
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
impl ParseTuple for ($ty, $ty, $ty) {
|
| 228 |
+
fn parse(_input: &[&str]) -> Self {
|
| 229 |
+
panic!("parsing this type requires the `build-mpfr` feature")
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
};
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
impl_parse_tuple!(f32);
|
| 236 |
+
impl_parse_tuple!(f64);
|
| 237 |
+
|
| 238 |
+
#[cfg(f16_enabled)]
|
| 239 |
+
impl_parse_tuple_via_rug!(f16);
|
| 240 |
+
#[cfg(f128_enabled)]
|
| 241 |
+
impl_parse_tuple_via_rug!(f128);
|
| 242 |
+
|
| 243 |
+
/// Try to parse the number, printing a nice message on failure.
|
| 244 |
+
fn parse<T: FromStr + FromStrRadix>(input: &[&str], idx: usize) -> T {
|
| 245 |
+
let s = input[idx];
|
| 246 |
+
|
| 247 |
+
let msg = || format!("invalid {} input '{s}'", type_name::<T>());
|
| 248 |
+
|
| 249 |
+
if s.starts_with("0x") || s.starts_with("-0x") {
|
| 250 |
+
return T::from_str_radix(s, 16).unwrap_or_else(|_| panic!("{}", msg()));
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
if s.starts_with("0b") {
|
| 254 |
+
return T::from_str_radix(s, 2).unwrap_or_else(|_| panic!("{}", msg()));
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
s.parse().unwrap_or_else(|_| panic!("{}", msg()))
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
/// Try to parse the float type going via `rug`, for `f16` and `f128` which don't yet implement
|
| 261 |
+
/// `FromStr`.
|
| 262 |
+
#[cfg(feature = "build-mpfr")]
|
| 263 |
+
fn parse_rug<F>(input: &[&str], idx: usize) -> F
|
| 264 |
+
where
|
| 265 |
+
F: libm_test::Float + FromStrRadix,
|
| 266 |
+
rug::Float: az::Cast<F>,
|
| 267 |
+
{
|
| 268 |
+
let s = input[idx];
|
| 269 |
+
|
| 270 |
+
let msg = || format!("invalid {} input '{s}'", type_name::<F>());
|
| 271 |
+
|
| 272 |
+
if s.starts_with("0x") {
|
| 273 |
+
return F::from_str_radix(s, 16).unwrap_or_else(|_| panic!("{}", msg()));
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
if s.starts_with("0b") {
|
| 277 |
+
return F::from_str_radix(s, 2).unwrap_or_else(|_| panic!("{}", msg()));
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
let x = rug::Float::parse(s).unwrap_or_else(|_| panic!("{}", msg()));
|
| 281 |
+
let x = rug::Float::with_val(F::BITS, x);
|
| 282 |
+
x.az()
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
trait FromStrRadix: Sized {
|
| 286 |
+
fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError>;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
impl FromStrRadix for i32 {
|
| 290 |
+
fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> {
|
| 291 |
+
let s = strip_radix_prefix(s, radix);
|
| 292 |
+
i32::from_str_radix(s, radix)
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
#[cfg(f16_enabled)]
|
| 297 |
+
impl FromStrRadix for f16 {
|
| 298 |
+
fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> {
|
| 299 |
+
if radix == 16 && s.contains("p") {
|
| 300 |
+
return Ok(libm::support::hf16(s));
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
let s = strip_radix_prefix(s, radix);
|
| 304 |
+
u16::from_str_radix(s, radix).map(Self::from_bits)
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
impl FromStrRadix for f32 {
|
| 309 |
+
fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> {
|
| 310 |
+
if radix == 16 && s.contains("p") {
|
| 311 |
+
// Parse as hex float
|
| 312 |
+
return Ok(hf32(s));
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
let s = strip_radix_prefix(s, radix);
|
| 316 |
+
u32::from_str_radix(s, radix).map(Self::from_bits)
|
| 317 |
+
}
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
impl FromStrRadix for f64 {
|
| 321 |
+
fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> {
|
| 322 |
+
if s.contains("p") {
|
| 323 |
+
return Ok(hf64(s));
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
let s = strip_radix_prefix(s, radix);
|
| 327 |
+
u64::from_str_radix(s, radix).map(Self::from_bits)
|
| 328 |
+
}
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
#[cfg(f128_enabled)]
|
| 332 |
+
impl FromStrRadix for f128 {
|
| 333 |
+
fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> {
|
| 334 |
+
if radix == 16 && s.contains("p") {
|
| 335 |
+
return Ok(libm::support::hf128(s));
|
| 336 |
+
}
|
| 337 |
+
let s = strip_radix_prefix(s, radix);
|
| 338 |
+
u128::from_str_radix(s, radix).map(Self::from_bits)
|
| 339 |
+
}
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
fn strip_radix_prefix(s: &str, radix: u32) -> &str {
|
| 343 |
+
if radix == 16 {
|
| 344 |
+
s.strip_prefix("0x").unwrap()
|
| 345 |
+
} else if radix == 2 {
|
| 346 |
+
s.strip_pref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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"__comment": "Autogenerated by update-api-list.py. List of files that define a function with a given name. This file is checked in to make it obvious if refactoring breaks things",
|
| 3 |
+
"acos": {
|
| 4 |
+
"sources": [
|
| 5 |
+
"libm/src/math/acos.rs"
|
| 6 |
+
],
|
| 7 |
+
"type": "f64"
|
| 8 |
+
},
|
| 9 |
+
"acosf": {
|
| 10 |
+
"sources": [
|
| 11 |
+
"libm/src/math/acosf.rs"
|
| 12 |
+
],
|
| 13 |
+
"type": "f32"
|
| 14 |
+
},
|
| 15 |
+
"acosh": {
|
| 16 |
+
"sources": [
|
| 17 |
+
"libm/src/math/acosh.rs"
|
| 18 |
+
],
|
| 19 |
+
"type": "f64"
|
| 20 |
+
},
|
| 21 |
+
"acoshf": {
|
| 22 |
+
"sources": [
|
| 23 |
+
"libm/src/math/acoshf.rs"
|
| 24 |
+
],
|
| 25 |
+
"type": "f32"
|
| 26 |
+
},
|
| 27 |
+
"asin": {
|
| 28 |
+
"sources": [
|
| 29 |
+
"libm/src/math/asin.rs"
|
| 30 |
+
],
|
| 31 |
+
"type": "f64"
|
| 32 |
+
},
|
| 33 |
+
"asinf": {
|
| 34 |
+
"sources": [
|
| 35 |
+
"libm/src/math/asinf.rs"
|
| 36 |
+
],
|
| 37 |
+
"type": "f32"
|
| 38 |
+
},
|
| 39 |
+
"asinh": {
|
| 40 |
+
"sources": [
|
| 41 |
+
"libm/src/math/asinh.rs"
|
| 42 |
+
],
|
| 43 |
+
"type": "f64"
|
| 44 |
+
},
|
| 45 |
+
"asinhf": {
|
| 46 |
+
"sources": [
|
| 47 |
+
"libm/src/math/asinhf.rs"
|
| 48 |
+
],
|
| 49 |
+
"type": "f32"
|
| 50 |
+
},
|
| 51 |
+
"atan": {
|
| 52 |
+
"sources": [
|
| 53 |
+
"libm/src/math/atan.rs"
|
| 54 |
+
],
|
| 55 |
+
"type": "f64"
|
| 56 |
+
},
|
| 57 |
+
"atan2": {
|
| 58 |
+
"sources": [
|
| 59 |
+
"libm/src/math/atan2.rs"
|
| 60 |
+
],
|
| 61 |
+
"type": "f64"
|
| 62 |
+
},
|
| 63 |
+
"atan2f": {
|
| 64 |
+
"sources": [
|
| 65 |
+
"libm/src/math/atan2f.rs"
|
| 66 |
+
],
|
| 67 |
+
"type": "f32"
|
| 68 |
+
},
|
| 69 |
+
"atanf": {
|
| 70 |
+
"sources": [
|
| 71 |
+
"libm/src/math/atanf.rs"
|
| 72 |
+
],
|
| 73 |
+
"type": "f32"
|
| 74 |
+
},
|
| 75 |
+
"atanh": {
|
| 76 |
+
"sources": [
|
| 77 |
+
"libm/src/math/atanh.rs"
|
| 78 |
+
],
|
| 79 |
+
"type": "f64"
|
| 80 |
+
},
|
| 81 |
+
"atanhf": {
|
| 82 |
+
"sources": [
|
| 83 |
+
"libm/src/math/atanhf.rs"
|
| 84 |
+
],
|
| 85 |
+
"type": "f32"
|
| 86 |
+
},
|
| 87 |
+
"cbrt": {
|
| 88 |
+
"sources": [
|
| 89 |
+
"libm/src/math/cbrt.rs"
|
| 90 |
+
],
|
| 91 |
+
"type": "f64"
|
| 92 |
+
},
|
| 93 |
+
"cbrtf": {
|
| 94 |
+
"sources": [
|
| 95 |
+
"libm/src/math/cbrtf.rs"
|
| 96 |
+
],
|
| 97 |
+
"type": "f32"
|
| 98 |
+
},
|
| 99 |
+
"ceil": {
|
| 100 |
+
"sources": [
|
| 101 |
+
"libm/src/math/arch/i586.rs",
|
| 102 |
+
"libm/src/math/arch/wasm32.rs",
|
| 103 |
+
"libm/src/math/ceil.rs",
|
| 104 |
+
"libm/src/math/generic/ceil.rs"
|
| 105 |
+
],
|
| 106 |
+
"type": "f64"
|
| 107 |
+
},
|
| 108 |
+
"ceilf": {
|
| 109 |
+
"sources": [
|
| 110 |
+
"libm/src/math/arch/wasm32.rs",
|
| 111 |
+
"libm/src/math/ceil.rs",
|
| 112 |
+
"libm/src/math/generic/ceil.rs"
|
| 113 |
+
],
|
| 114 |
+
"type": "f32"
|
| 115 |
+
},
|
| 116 |
+
"ceilf128": {
|
| 117 |
+
"sources": [
|
| 118 |
+
"libm/src/math/ceil.rs",
|
| 119 |
+
"libm/src/math/generic/ceil.rs"
|
| 120 |
+
],
|
| 121 |
+
"type": "f128"
|
| 122 |
+
},
|
| 123 |
+
"ceilf16": {
|
| 124 |
+
"sources": [
|
| 125 |
+
"libm/src/math/ceil.rs",
|
| 126 |
+
"libm/src/math/generic/ceil.rs"
|
| 127 |
+
],
|
| 128 |
+
"type": "f16"
|
| 129 |
+
},
|
| 130 |
+
"copysign": {
|
| 131 |
+
"sources": [
|
| 132 |
+
"libm/src/math/copysign.rs",
|
| 133 |
+
"libm/src/math/generic/copysign.rs"
|
| 134 |
+
],
|
| 135 |
+
"type": "f64"
|
| 136 |
+
},
|
| 137 |
+
"copysignf": {
|
| 138 |
+
"sources": [
|
| 139 |
+
"libm/src/math/copysign.rs",
|
| 140 |
+
"libm/src/math/generic/copysign.rs"
|
| 141 |
+
],
|
| 142 |
+
"type": "f32"
|
| 143 |
+
},
|
| 144 |
+
"copysignf128": {
|
| 145 |
+
"sources": [
|
| 146 |
+
"libm/src/math/copysign.rs",
|
| 147 |
+
"libm/src/math/generic/copysign.rs"
|
| 148 |
+
],
|
| 149 |
+
"type": "f128"
|
| 150 |
+
},
|
| 151 |
+
"copysignf16": {
|
| 152 |
+
"sources": [
|
| 153 |
+
"libm/src/math/copysign.rs",
|
| 154 |
+
"libm/src/math/generic/copysign.rs"
|
| 155 |
+
],
|
| 156 |
+
"type": "f16"
|
| 157 |
+
},
|
| 158 |
+
"cos": {
|
| 159 |
+
"sources": [
|
| 160 |
+
"libm/src/math/cos.rs"
|
| 161 |
+
],
|
| 162 |
+
"type": "f64"
|
| 163 |
+
},
|
| 164 |
+
"cosf": {
|
| 165 |
+
"sources": [
|
| 166 |
+
"libm/src/math/cosf.rs"
|
| 167 |
+
],
|
| 168 |
+
"type": "f32"
|
| 169 |
+
},
|
| 170 |
+
"cosh": {
|
| 171 |
+
"sources": [
|
| 172 |
+
"libm/src/math/cosh.rs"
|
| 173 |
+
],
|
| 174 |
+
"type": "f64"
|
| 175 |
+
},
|
| 176 |
+
"coshf": {
|
| 177 |
+
"sources": [
|
| 178 |
+
"libm/src/math/coshf.rs"
|
| 179 |
+
],
|
| 180 |
+
"type": "f32"
|
| 181 |
+
},
|
| 182 |
+
"erf": {
|
| 183 |
+
"sources": [
|
| 184 |
+
"libm/src/math/erf.rs"
|
| 185 |
+
],
|
| 186 |
+
"type": "f64"
|
| 187 |
+
},
|
| 188 |
+
"erfc": {
|
| 189 |
+
"sources": [
|
| 190 |
+
"libm/src/math/erf.rs"
|
| 191 |
+
],
|
| 192 |
+
"type": "f64"
|
| 193 |
+
},
|
| 194 |
+
"erfcf": {
|
| 195 |
+
"sources": [
|
| 196 |
+
"libm/src/math/erff.rs"
|
| 197 |
+
],
|
| 198 |
+
"type": "f32"
|
| 199 |
+
},
|
| 200 |
+
"erff": {
|
| 201 |
+
"sources": [
|
| 202 |
+
"libm/src/math/erff.rs"
|
| 203 |
+
],
|
| 204 |
+
"type": "f32"
|
| 205 |
+
},
|
| 206 |
+
"exp": {
|
| 207 |
+
"sources": [
|
| 208 |
+
"libm/src/math/exp.rs"
|
| 209 |
+
],
|
| 210 |
+
"type": "f64"
|
| 211 |
+
},
|
| 212 |
+
"exp10": {
|
| 213 |
+
"sources": [
|
| 214 |
+
"libm/src/math/exp10.rs"
|
| 215 |
+
],
|
| 216 |
+
"type": "f64"
|
| 217 |
+
},
|
| 218 |
+
"exp10f": {
|
| 219 |
+
"sources": [
|
| 220 |
+
"libm/src/math/exp10f.rs"
|
| 221 |
+
],
|
| 222 |
+
"type": "f32"
|
| 223 |
+
},
|
| 224 |
+
"exp2": {
|
| 225 |
+
"sources": [
|
| 226 |
+
"libm/src/math/exp2.rs"
|
| 227 |
+
],
|
| 228 |
+
"type": "f64"
|
| 229 |
+
},
|
| 230 |
+
"exp2f": {
|
| 231 |
+
"sources": [
|
| 232 |
+
"libm/src/math/exp2f.rs"
|
| 233 |
+
],
|
| 234 |
+
"type": "f32"
|
| 235 |
+
},
|
| 236 |
+
"expf": {
|
| 237 |
+
"sources": [
|
| 238 |
+
"libm/src/math/expf.rs"
|
| 239 |
+
],
|
| 240 |
+
"type": "f32"
|
| 241 |
+
},
|
| 242 |
+
"expm1": {
|
| 243 |
+
"sources": [
|
| 244 |
+
"libm/src/math/expm1.rs"
|
| 245 |
+
],
|
| 246 |
+
"type": "f64"
|
| 247 |
+
},
|
| 248 |
+
"expm1f": {
|
| 249 |
+
"sources": [
|
| 250 |
+
"libm/src/math/expm1f.rs"
|
| 251 |
+
],
|
| 252 |
+
"type": "f32"
|
| 253 |
+
},
|
| 254 |
+
"fabs": {
|
| 255 |
+
"sources": [
|
| 256 |
+
"libm/src/math/arch/wasm32.rs",
|
| 257 |
+
"libm/src/math/fabs.rs",
|
| 258 |
+
"libm/src/math/generic/fabs.rs"
|
| 259 |
+
],
|
| 260 |
+
"type": "f64"
|
| 261 |
+
},
|
| 262 |
+
"fabsf": {
|
| 263 |
+
"sources": [
|
| 264 |
+
"libm/src/math/arch/wasm32.rs",
|
| 265 |
+
"libm/src/math/fabs.rs",
|
| 266 |
+
"libm/src/math/generic/fabs.rs"
|
| 267 |
+
],
|
| 268 |
+
"type": "f32"
|
| 269 |
+
},
|
| 270 |
+
"fabsf128": {
|
| 271 |
+
"sources": [
|
| 272 |
+
"libm/src/math/fabs.rs",
|
| 273 |
+
"libm/src/math/generic/fabs.rs"
|
| 274 |
+
],
|
| 275 |
+
"type": "f128"
|
| 276 |
+
},
|
| 277 |
+
"fabsf16": {
|
| 278 |
+
"sources": [
|
| 279 |
+
"libm/src/math/fabs.rs",
|
| 280 |
+
"libm/src/math/generic/fabs.rs"
|
| 281 |
+
],
|
| 282 |
+
"type": "f16"
|
| 283 |
+
},
|
| 284 |
+
"fdim": {
|
| 285 |
+
"sources": [
|
| 286 |
+
"libm/src/math/fdim.rs",
|
| 287 |
+
"libm/src/math/generic/fdim.rs"
|
| 288 |
+
],
|
| 289 |
+
"type": "f64"
|
| 290 |
+
},
|
| 291 |
+
"fdimf": {
|
| 292 |
+
"sources": [
|
| 293 |
+
"libm/src/math/fdim.rs",
|
| 294 |
+
"libm/src/math/generic/fdim.rs"
|
| 295 |
+
],
|
| 296 |
+
"type": "f32"
|
| 297 |
+
},
|
| 298 |
+
"fdimf128": {
|
| 299 |
+
"sources": [
|
| 300 |
+
"libm/src/math/fdim.rs",
|
| 301 |
+
"libm/src/math/generic/fdim.rs"
|
| 302 |
+
],
|
| 303 |
+
"type": "f128"
|
| 304 |
+
},
|
| 305 |
+
"fdimf16": {
|
| 306 |
+
"sources": [
|
| 307 |
+
"libm/src/math/fdim.rs",
|
| 308 |
+
"libm/src/math/generic/fdim.rs"
|
| 309 |
+
],
|
| 310 |
+
"type": "f16"
|
| 311 |
+
},
|
| 312 |
+
"floor": {
|
| 313 |
+
"sources": [
|
| 314 |
+
"libm/src/math/arch/i586.rs",
|
| 315 |
+
"libm/src/math/arch/wasm32.rs",
|
| 316 |
+
"libm/src/math/floor.rs",
|
| 317 |
+
"libm/src/math/generic/floor.rs"
|
| 318 |
+
],
|
| 319 |
+
"type": "f64"
|
| 320 |
+
},
|
| 321 |
+
"floorf": {
|
| 322 |
+
"sources": [
|
| 323 |
+
"libm/src/math/arch/wasm32.rs",
|
| 324 |
+
"libm/src/math/floor.rs",
|
| 325 |
+
"libm/src/math/generic/floor.rs"
|
| 326 |
+
],
|
| 327 |
+
"type": "f32"
|
| 328 |
+
},
|
| 329 |
+
"floorf128": {
|
| 330 |
+
"sources": [
|
| 331 |
+
"libm/src/math/floor.rs",
|
| 332 |
+
"libm/src/math/generic/floor.rs"
|
| 333 |
+
],
|
| 334 |
+
"type": "f128"
|
| 335 |
+
},
|
| 336 |
+
"floorf16": {
|
| 337 |
+
"sources": [
|
| 338 |
+
"libm/src/math/floor.rs",
|
| 339 |
+
"libm/src/math/generic/floor.rs"
|
| 340 |
+
],
|
| 341 |
+
"type": "f16"
|
| 342 |
+
},
|
| 343 |
+
"fma": {
|
| 344 |
+
"sources": [
|
| 345 |
+
"libm/src/math/arch/aarch64.rs",
|
| 346 |
+
"libm/src/math/arch/x86/fma.rs",
|
| 347 |
+
"libm/src/math/fma.rs"
|
| 348 |
+
],
|
| 349 |
+
"type": "f64"
|
| 350 |
+
},
|
| 351 |
+
"fmaf": {
|
| 352 |
+
"sources": [
|
| 353 |
+
"libm/src/math/arch/aarch64.rs",
|
| 354 |
+
"libm/src/math/arch/x86/fma.rs",
|
| 355 |
+
"libm/src/math/fma.rs"
|
| 356 |
+
],
|
| 357 |
+
"type": "f32"
|
| 358 |
+
},
|
| 359 |
+
"fmaf128": {
|
| 360 |
+
"sources": [
|
| 361 |
+
"libm/src/math/fma.rs"
|
| 362 |
+
],
|
| 363 |
+
"type": "f128"
|
| 364 |
+
},
|
| 365 |
+
"fmax": {
|
| 366 |
+
"sources": [
|
| 367 |
+
"libm/src/math/fmin_fmax.rs",
|
| 368 |
+
"libm/src/math/generic/fmax.rs"
|
| 369 |
+
],
|
| 370 |
+
"type": "f64"
|
| 371 |
+
},
|
| 372 |
+
"fmaxf": {
|
| 373 |
+
"sources": [
|
| 374 |
+
"libm/src/math/fmin_fmax.rs",
|
| 375 |
+
"libm/src/math/generic/fmax.rs"
|
| 376 |
+
],
|
| 377 |
+
"type": "f32"
|
| 378 |
+
},
|
| 379 |
+
"fmaxf128": {
|
| 380 |
+
"sources": [
|
| 381 |
+
"libm/src/math/fmin_fmax.rs",
|
| 382 |
+
"libm/src/math/generic/fmax.rs"
|
| 383 |
+
],
|
| 384 |
+
"type": "f128"
|
| 385 |
+
},
|
| 386 |
+
"fmaxf16": {
|
| 387 |
+
"sources": [
|
| 388 |
+
"libm/src/math/fmin_fmax.rs",
|
| 389 |
+
"libm/src/math/generic/fmax.rs"
|
| 390 |
+
],
|
| 391 |
+
"type": "f16"
|
| 392 |
+
},
|
| 393 |
+
"fmaximum": {
|
| 394 |
+
"sources": [
|
| 395 |
+
"libm/src/math/fminimum_fmaximum.rs",
|
| 396 |
+
"libm/src/math/generic/fmaximum.rs"
|
| 397 |
+
],
|
| 398 |
+
"type": "f64"
|
| 399 |
+
},
|
| 400 |
+
"fmaximum_num": {
|
| 401 |
+
"sources": [
|
| 402 |
+
"libm/src/math/fminimum_fmaximum_num.rs",
|
| 403 |
+
"libm/src/math/generic/fmaximum_num.rs"
|
| 404 |
+
],
|
| 405 |
+
"type": "f64"
|
| 406 |
+
},
|
| 407 |
+
"fmaximum_numf": {
|
| 408 |
+
"sources": [
|
| 409 |
+
"libm/src/math/fminimum_fmaximum_num.rs",
|
| 410 |
+
"libm/src/math/generic/fmaximum_num.rs"
|
| 411 |
+
],
|
| 412 |
+
"type": "f32"
|
| 413 |
+
},
|
| 414 |
+
"fmaximum_numf128": {
|
| 415 |
+
"sources": [
|
| 416 |
+
"libm/src/math/fminimum_fmaximum_num.rs",
|
| 417 |
+
"libm/src/math/generic/fmaximum_num.rs"
|
| 418 |
+
],
|
| 419 |
+
"type": "f128"
|
| 420 |
+
},
|
| 421 |
+
"fmaximum_numf16": {
|
| 422 |
+
"sources": [
|
| 423 |
+
"libm/src/math/fminimum_fmaximum_num.rs",
|
| 424 |
+
"libm/src/math/generic/fmaximum_num.rs"
|
| 425 |
+
],
|
| 426 |
+
"type": "f16"
|
| 427 |
+
},
|
| 428 |
+
"fmaximumf": {
|
| 429 |
+
"sources": [
|
| 430 |
+
"libm/src/math/fminimum_fmaximum.rs",
|
| 431 |
+
"libm/src/math/generic/fmaximum.rs"
|
| 432 |
+
],
|
| 433 |
+
"type": "f32"
|
| 434 |
+
},
|
| 435 |
+
"fmaximumf128": {
|
| 436 |
+
"sources": [
|
| 437 |
+
"libm/src/math/fminimum_fmaximum.rs",
|
| 438 |
+
"libm/src/math/generic/fmaximum.rs"
|
| 439 |
+
],
|
| 440 |
+
"type": "f128"
|
| 441 |
+
},
|
| 442 |
+
"fmaximumf16": {
|
| 443 |
+
"sources": [
|
| 444 |
+
"libm/src/math/fminimum_fmaximum.rs",
|
| 445 |
+
"libm/src/math/generic/fmaximum.rs"
|
| 446 |
+
],
|
| 447 |
+
"type": "f16"
|
| 448 |
+
},
|
| 449 |
+
"fmin": {
|
| 450 |
+
"sources": [
|
| 451 |
+
"libm/src/math/fmin_fmax.rs",
|
| 452 |
+
"libm/src/math/generic/fmin.rs"
|
| 453 |
+
],
|
| 454 |
+
"type": "f64"
|
| 455 |
+
},
|
| 456 |
+
"fminf": {
|
| 457 |
+
"sources": [
|
| 458 |
+
"libm/src/math/fmin_fmax.rs",
|
| 459 |
+
"libm/src/math/generic/fmin.rs"
|
| 460 |
+
],
|
| 461 |
+
"type": "f32"
|
| 462 |
+
},
|
| 463 |
+
"fminf128": {
|
| 464 |
+
"sources": [
|
| 465 |
+
"libm/src/math/fmin_fmax.rs",
|
| 466 |
+
"libm/src/math/generic/fmin.rs"
|
| 467 |
+
],
|
| 468 |
+
"type": "f128"
|
| 469 |
+
},
|
| 470 |
+
"fminf16": {
|
| 471 |
+
"sources": [
|
| 472 |
+
"libm/src/math/fmin_fmax.rs",
|
| 473 |
+
"libm/src/math/generic/fmin.rs"
|
| 474 |
+
],
|
| 475 |
+
"type": "f16"
|
| 476 |
+
},
|
| 477 |
+
"fminimum": {
|
| 478 |
+
"sources": [
|
| 479 |
+
"libm/src/math/fminimum_fmaximum.rs",
|
| 480 |
+
"libm/src/math/generic/fminimum.rs"
|
| 481 |
+
],
|
| 482 |
+
"type": "f64"
|
| 483 |
+
},
|
| 484 |
+
"fminimum_num": {
|
| 485 |
+
"sources": [
|
| 486 |
+
"libm/src/math/fminimum_fmaximum_num.rs",
|
| 487 |
+
"libm/src/math/generic/fminimum_num.rs"
|
| 488 |
+
],
|
| 489 |
+
"type": "f64"
|
| 490 |
+
},
|
| 491 |
+
"fminimum_numf": {
|
| 492 |
+
"sources": [
|
| 493 |
+
"libm/src/math/fminimum_fmaximum_num.rs",
|
| 494 |
+
"libm/src/math/generic/fminimum_num.rs"
|
| 495 |
+
],
|
| 496 |
+
"type": "f32"
|
| 497 |
+
},
|
| 498 |
+
"fminimum_numf128": {
|
| 499 |
+
"sources": [
|
| 500 |
+
"libm/src/math/fminimum_fmaximum_num.rs",
|
| 501 |
+
"libm/src/math/generic/fminimum_num.rs"
|
| 502 |
+
],
|
| 503 |
+
"type": "f128"
|
| 504 |
+
},
|
| 505 |
+
"fminimum_numf16": {
|
| 506 |
+
"sources": [
|
| 507 |
+
"libm/src/math/fminimum_fmaximum_num.rs",
|
| 508 |
+
"libm/src/math/generic/fminimum_num.rs"
|
| 509 |
+
],
|
| 510 |
+
"type": "f16"
|
| 511 |
+
},
|
| 512 |
+
"fminimumf": {
|
| 513 |
+
"sources": [
|
| 514 |
+
"libm/src/math/fminimum_fmaximum.rs",
|
| 515 |
+
"libm/src/math/generic/fminimum.rs"
|
| 516 |
+
],
|
| 517 |
+
"type": "f32"
|
| 518 |
+
},
|
| 519 |
+
"fminimumf128": {
|
| 520 |
+
"sources": [
|
| 521 |
+
"libm/src/math/fminimum_fmaximum.rs",
|
| 522 |
+
"libm/src/math/generic/fminimum.rs"
|
| 523 |
+
],
|
| 524 |
+
"type": "f128"
|
| 525 |
+
},
|
| 526 |
+
"fminimumf16": {
|
| 527 |
+
"sources": [
|
| 528 |
+
"libm/src/math/fminimum_fmaximum.rs",
|
| 529 |
+
"libm/src/math/generic/fminimum.rs"
|
| 530 |
+
],
|
| 531 |
+
"type": "f16"
|
| 532 |
+
},
|
| 533 |
+
"fmod": {
|
| 534 |
+
"sources": [
|
| 535 |
+
"libm/src/math/fmod.rs",
|
| 536 |
+
"libm/src/math/generic/fmod.rs"
|
| 537 |
+
],
|
| 538 |
+
"type": "f64"
|
| 539 |
+
},
|
| 540 |
+
"fmodf": {
|
| 541 |
+
"sources": [
|
| 542 |
+
"libm/src/math/fmod.rs",
|
| 543 |
+
"libm/src/math/generic/fmod.rs"
|
| 544 |
+
],
|
| 545 |
+
"type": "f32"
|
| 546 |
+
},
|
| 547 |
+
"fmodf128": {
|
| 548 |
+
"sources": [
|
| 549 |
+
"libm/src/math/fmod.rs",
|
| 550 |
+
"libm/src/math/generic/fmod.rs"
|
| 551 |
+
],
|
| 552 |
+
"type": "f128"
|
| 553 |
+
},
|
| 554 |
+
"fmodf16": {
|
| 555 |
+
"sources": [
|
| 556 |
+
"libm/src/math/fmod.rs",
|
| 557 |
+
"libm/src/math/generic/fmod.rs"
|
| 558 |
+
],
|
| 559 |
+
"type": "f16"
|
| 560 |
+
},
|
| 561 |
+
"frexp": {
|
| 562 |
+
"sources": [
|
| 563 |
+
"libm/src/math/frexp.rs"
|
| 564 |
+
],
|
| 565 |
+
"type": "f64"
|
| 566 |
+
},
|
| 567 |
+
"frexpf": {
|
| 568 |
+
"sources": [
|
| 569 |
+
"libm/src/math/frexpf.rs"
|
| 570 |
+
],
|
| 571 |
+
"type": "f32"
|
| 572 |
+
},
|
| 573 |
+
"hypot": {
|
| 574 |
+
"sources": [
|
| 575 |
+
"libm/src/math/hypot.rs"
|
| 576 |
+
],
|
| 577 |
+
"type": "f64"
|
| 578 |
+
},
|
| 579 |
+
"hypotf": {
|
| 580 |
+
"sources": [
|
| 581 |
+
"libm/src/math/hypotf.rs"
|
| 582 |
+
],
|
| 583 |
+
"type": "f32"
|
| 584 |
+
},
|
| 585 |
+
"ilogb": {
|
| 586 |
+
"sources": [
|
| 587 |
+
"libm/src/math/ilogb.rs"
|
| 588 |
+
],
|
| 589 |
+
"type": "f64"
|
| 590 |
+
},
|
| 591 |
+
"ilogbf": {
|
| 592 |
+
"sources": [
|
| 593 |
+
"libm/src/math/ilogbf.rs"
|
| 594 |
+
],
|
| 595 |
+
"type": "f32"
|
| 596 |
+
},
|
| 597 |
+
"j0": {
|
| 598 |
+
"sources": [
|
| 599 |
+
"libm/src/math/j0.rs"
|
| 600 |
+
],
|
| 601 |
+
"type": "f64"
|
| 602 |
+
},
|
| 603 |
+
"j0f": {
|
| 604 |
+
"sources": [
|
| 605 |
+
"libm/src/math/j0f.rs"
|
| 606 |
+
],
|
| 607 |
+
"type": "f32"
|
| 608 |
+
},
|
| 609 |
+
"j1": {
|
| 610 |
+
"sources": [
|
| 611 |
+
"libm/src/math/j1.rs"
|
| 612 |
+
],
|
| 613 |
+
"type": "f64"
|
| 614 |
+
},
|
| 615 |
+
"j1f": {
|
| 616 |
+
"sources": [
|
| 617 |
+
"libm/src/math/j1f.rs"
|
| 618 |
+
],
|
| 619 |
+
"type": "f32"
|
| 620 |
+
},
|
| 621 |
+
"jn": {
|
| 622 |
+
"sources": [
|
| 623 |
+
"libm/src/math/jn.rs"
|
| 624 |
+
],
|
| 625 |
+
"type": "f64"
|
| 626 |
+
},
|
| 627 |
+
"jnf": {
|
| 628 |
+
"sources": [
|
| 629 |
+
"libm/src/math/jnf.rs"
|
| 630 |
+
],
|
| 631 |
+
"type": "f32"
|
| 632 |
+
},
|
| 633 |
+
"ldexp": {
|
| 634 |
+
"sources": [
|
| 635 |
+
"libm/src/math/ldexp.rs"
|
| 636 |
+
],
|
| 637 |
+
"type": "f64"
|
| 638 |
+
},
|
| 639 |
+
"ldexpf": {
|
| 640 |
+
"sources": [
|
| 641 |
+
"libm/src/math/ldexp.rs"
|
| 642 |
+
],
|
| 643 |
+
"type": "f32"
|
| 644 |
+
},
|
| 645 |
+
"ldexpf128": {
|
| 646 |
+
"sources": [
|
| 647 |
+
"libm/src/math/ldexp.rs"
|
| 648 |
+
],
|
| 649 |
+
"type": "f128"
|
| 650 |
+
},
|
| 651 |
+
"ldexpf16": {
|
| 652 |
+
"sources": [
|
| 653 |
+
"libm/src/math/ldexp.rs"
|
| 654 |
+
],
|
| 655 |
+
"type": "f16"
|
| 656 |
+
},
|
| 657 |
+
"lgamma": {
|
| 658 |
+
"sources": [
|
| 659 |
+
"libm/src/math/lgamma.rs"
|
| 660 |
+
],
|
| 661 |
+
"type": "f64"
|
| 662 |
+
},
|
| 663 |
+
"lgamma_r": {
|
| 664 |
+
"sources": [
|
| 665 |
+
"libm/src/math/lgamma_r.rs"
|
| 666 |
+
],
|
| 667 |
+
"type": "f64"
|
| 668 |
+
},
|
| 669 |
+
"lgammaf": {
|
| 670 |
+
"sources": [
|
| 671 |
+
"libm/src/math/lgammaf.rs"
|
| 672 |
+
],
|
| 673 |
+
"type": "f32"
|
| 674 |
+
},
|
| 675 |
+
"lgammaf_r": {
|
| 676 |
+
"sources": [
|
| 677 |
+
"libm/src/math/lgammaf_r.rs"
|
| 678 |
+
],
|
| 679 |
+
"type": "f32"
|
| 680 |
+
},
|
| 681 |
+
"log": {
|
| 682 |
+
"sources": [
|
| 683 |
+
"libm/src/math/log.rs"
|
| 684 |
+
],
|
| 685 |
+
"type": "f64"
|
| 686 |
+
},
|
| 687 |
+
"log10": {
|
| 688 |
+
"sources": [
|
| 689 |
+
"libm/src/math/log10.rs"
|
| 690 |
+
],
|
| 691 |
+
"type": "f64"
|
| 692 |
+
},
|
| 693 |
+
"log10f": {
|
| 694 |
+
"sources": [
|
| 695 |
+
"libm/src/math/log10f.rs"
|
| 696 |
+
],
|
| 697 |
+
"type": "f32"
|
| 698 |
+
},
|
| 699 |
+
"log1p": {
|
| 700 |
+
"sources": [
|
| 701 |
+
"libm/src/math/log1p.rs"
|
| 702 |
+
],
|
| 703 |
+
"type": "f64"
|
| 704 |
+
},
|
| 705 |
+
"log1pf": {
|
| 706 |
+
"sources": [
|
| 707 |
+
"libm/src/math/log1pf.rs"
|
| 708 |
+
],
|
| 709 |
+
"type": "f32"
|
| 710 |
+
},
|
| 711 |
+
"log2": {
|
| 712 |
+
"sources": [
|
| 713 |
+
"libm/src/math/log2.rs"
|
| 714 |
+
],
|
| 715 |
+
"type": "f64"
|
| 716 |
+
},
|
| 717 |
+
"log2f": {
|
| 718 |
+
"sources": [
|
| 719 |
+
"libm/src/math/log2f.rs"
|
| 720 |
+
],
|
| 721 |
+
"type": "f32"
|
| 722 |
+
},
|
| 723 |
+
"logf": {
|
| 724 |
+
"sources": [
|
| 725 |
+
"libm/src/math/logf.rs"
|
| 726 |
+
],
|
| 727 |
+
"type": "f32"
|
| 728 |
+
},
|
| 729 |
+
"modf": {
|
| 730 |
+
"sources": [
|
| 731 |
+
"libm/src/math/modf.rs"
|
| 732 |
+
],
|
| 733 |
+
"type": "f64"
|
| 734 |
+
},
|
| 735 |
+
"modff": {
|
| 736 |
+
"sources": [
|
| 737 |
+
"libm/src/math/modff.rs"
|
| 738 |
+
],
|
| 739 |
+
"type": "f32"
|
| 740 |
+
},
|
| 741 |
+
"nextafter": {
|
| 742 |
+
"sources": [
|
| 743 |
+
"libm/src/math/nextafter.rs"
|
| 744 |
+
],
|
| 745 |
+
"type": "f64"
|
| 746 |
+
},
|
| 747 |
+
"nextafterf": {
|
| 748 |
+
"sources": [
|
| 749 |
+
"libm/src/math/nextafterf.rs"
|
| 750 |
+
],
|
| 751 |
+
"type": "f32"
|
| 752 |
+
},
|
| 753 |
+
"pow": {
|
| 754 |
+
"sources": [
|
| 755 |
+
"libm/src/math/pow.rs"
|
| 756 |
+
],
|
| 757 |
+
"type": "f64"
|
| 758 |
+
},
|
| 759 |
+
"powf": {
|
| 760 |
+
"sources": [
|
| 761 |
+
"libm/src/math/powf.rs"
|
| 762 |
+
],
|
| 763 |
+
"type": "f32"
|
| 764 |
+
},
|
| 765 |
+
"remainder": {
|
| 766 |
+
"sources": [
|
| 767 |
+
"libm/src/math/remainder.rs"
|
| 768 |
+
],
|
| 769 |
+
"type": "f64"
|
| 770 |
+
},
|
| 771 |
+
"remainderf": {
|
| 772 |
+
"sources": [
|
| 773 |
+
"libm/src/math/remainderf.rs"
|
| 774 |
+
],
|
| 775 |
+
"type": "f32"
|
| 776 |
+
},
|
| 777 |
+
"remquo": {
|
| 778 |
+
"sources": [
|
| 779 |
+
"libm/src/math/remquo.rs"
|
| 780 |
+
],
|
| 781 |
+
"type": "f64"
|
| 782 |
+
},
|
| 783 |
+
"remquof": {
|
| 784 |
+
"sources": [
|
| 785 |
+
"libm/src/math/remquof.rs"
|
| 786 |
+
],
|
| 787 |
+
"type": "f32"
|
| 788 |
+
},
|
| 789 |
+
"rint": {
|
| 790 |
+
"sources": [
|
| 791 |
+
"libm/src/math/arch/aarch64.rs",
|
| 792 |
+
"libm/src/math/arch/wasm32.rs",
|
| 793 |
+
"libm/src/math/rint.rs"
|
| 794 |
+
],
|
| 795 |
+
"type": "f64"
|
| 796 |
+
},
|
| 797 |
+
"rintf": {
|
| 798 |
+
"sources": [
|
| 799 |
+
"libm/src/math/arch/aarch64.rs",
|
| 800 |
+
"libm/src/math/arch/wasm32.rs",
|
| 801 |
+
"libm/src/math/rint.rs"
|
| 802 |
+
],
|
| 803 |
+
"type": "f32"
|
| 804 |
+
},
|
| 805 |
+
"rintf128": {
|
| 806 |
+
"sources": [
|
| 807 |
+
"libm/src/math/rint.rs"
|
| 808 |
+
],
|
| 809 |
+
"type": "f128"
|
| 810 |
+
},
|
| 811 |
+
"rintf16": {
|
| 812 |
+
"sources": [
|
| 813 |
+
"libm/src/math/arch/aarch64.rs",
|
| 814 |
+
"libm/src/math/rint.rs"
|
| 815 |
+
],
|
| 816 |
+
"type": "f16"
|
| 817 |
+
},
|
| 818 |
+
"round": {
|
| 819 |
+
"sources": [
|
| 820 |
+
"libm/src/math/generic/round.rs",
|
| 821 |
+
"libm/src/math/round.rs"
|
| 822 |
+
],
|
| 823 |
+
"type": "f64"
|
| 824 |
+
},
|
| 825 |
+
"roundeven": {
|
| 826 |
+
"sources": [
|
| 827 |
+
"libm/src/math/roundeven.rs"
|
| 828 |
+
],
|
| 829 |
+
"type": "f64"
|
| 830 |
+
},
|
| 831 |
+
"roundevenf": {
|
| 832 |
+
"sources": [
|
| 833 |
+
"libm/src/math/roundeven.rs"
|
| 834 |
+
],
|
| 835 |
+
"type": "f32"
|
| 836 |
+
},
|
| 837 |
+
"roundevenf128": {
|
| 838 |
+
"sources": [
|
| 839 |
+
"libm/src/math/roundeven.rs"
|
| 840 |
+
],
|
| 841 |
+
"type": "f128"
|
| 842 |
+
},
|
| 843 |
+
"roundevenf16": {
|
| 844 |
+
"sources": [
|
| 845 |
+
"libm/src/math/roundeven.rs"
|
| 846 |
+
],
|
| 847 |
+
"type": "f16"
|
| 848 |
+
},
|
| 849 |
+
"roundf": {
|
| 850 |
+
"sources": [
|
| 851 |
+
"libm/src/math/generic/round.rs",
|
| 852 |
+
"libm/src/math/round.rs"
|
| 853 |
+
],
|
| 854 |
+
"type": "f32"
|
| 855 |
+
},
|
| 856 |
+
"roundf128": {
|
| 857 |
+
"sources": [
|
| 858 |
+
"libm/src/math/generic/round.rs",
|
| 859 |
+
"libm/src/math/round.rs"
|
| 860 |
+
],
|
| 861 |
+
"type": "f128"
|
| 862 |
+
},
|
| 863 |
+
"roundf16": {
|
| 864 |
+
"sources": [
|
| 865 |
+
"libm/src/math/generic/round.rs",
|
| 866 |
+
"libm/src/math/round.rs"
|
| 867 |
+
],
|
| 868 |
+
"type": "f16"
|
| 869 |
+
},
|
| 870 |
+
"scalbn": {
|
| 871 |
+
"sources": [
|
| 872 |
+
"libm/src/math/generic/scalbn.rs",
|
| 873 |
+
"libm/src/math/scalbn.rs"
|
| 874 |
+
],
|
| 875 |
+
"type": "f64"
|
| 876 |
+
},
|
| 877 |
+
"scalbnf": {
|
| 878 |
+
"sources": [
|
| 879 |
+
"libm/src/math/generic/scalbn.rs",
|
| 880 |
+
"libm/src/math/scalbn.rs"
|
| 881 |
+
],
|
| 882 |
+
"type": "f32"
|
| 883 |
+
},
|
| 884 |
+
"scalbnf128": {
|
| 885 |
+
"sources": [
|
| 886 |
+
"libm/src/math/generic/scalbn.rs",
|
| 887 |
+
"libm/src/math/scalbn.rs"
|
| 888 |
+
],
|
| 889 |
+
"type": "f128"
|
| 890 |
+
},
|
| 891 |
+
"scalbnf16": {
|
| 892 |
+
"sources": [
|
| 893 |
+
"libm/src/math/generic/scalbn.rs",
|
| 894 |
+
"libm/src/math/scalbn.rs"
|
| 895 |
+
],
|
| 896 |
+
"type": "f16"
|
| 897 |
+
},
|
| 898 |
+
"sin": {
|
| 899 |
+
"sources": [
|
| 900 |
+
"libm/src/math/sin.rs"
|
| 901 |
+
],
|
| 902 |
+
"type": "f64"
|
| 903 |
+
},
|
| 904 |
+
"sincos": {
|
| 905 |
+
"sources": [
|
| 906 |
+
"libm/src/math/sincos.rs"
|
| 907 |
+
],
|
| 908 |
+
"type": "f64"
|
| 909 |
+
},
|
| 910 |
+
"sincosf": {
|
| 911 |
+
"sources": [
|
| 912 |
+
"libm/src/math/sincosf.rs"
|
| 913 |
+
],
|
| 914 |
+
"type": "f32"
|
| 915 |
+
},
|
| 916 |
+
"sinf": {
|
| 917 |
+
"sources": [
|
| 918 |
+
"libm/src/math/sinf.rs"
|
| 919 |
+
],
|
| 920 |
+
"type": "f32"
|
| 921 |
+
},
|
| 922 |
+
"sinh": {
|
| 923 |
+
"sources": [
|
| 924 |
+
"libm/src/math/sinh.rs"
|
| 925 |
+
],
|
| 926 |
+
"type": "f64"
|
| 927 |
+
},
|
| 928 |
+
"sinhf": {
|
| 929 |
+
"sources": [
|
| 930 |
+
"libm/src/math/sinhf.rs"
|
| 931 |
+
],
|
| 932 |
+
"type": "f32"
|
| 933 |
+
},
|
| 934 |
+
"sqrt": {
|
| 935 |
+
"sources": [
|
| 936 |
+
"libm/src/math/arch/aarch64.rs",
|
| 937 |
+
"libm/src/math/arch/wasm32.rs",
|
| 938 |
+
"libm/src/math/arch/x86.rs",
|
| 939 |
+
"libm/src/math/generic/sqrt.rs",
|
| 940 |
+
"libm/src/math/sqrt.rs"
|
| 941 |
+
],
|
| 942 |
+
"type": "f64"
|
| 943 |
+
},
|
| 944 |
+
"sqrtf": {
|
| 945 |
+
"sources": [
|
| 946 |
+
"libm/src/math/arch/aarch64.rs",
|
| 947 |
+
"libm/src/math/arch/wasm32.rs",
|
| 948 |
+
"libm/src/math/arch/x86.rs",
|
| 949 |
+
"libm/src/math/generic/sqrt.rs",
|
| 950 |
+
"libm/src/math/sqrt.rs"
|
| 951 |
+
],
|
| 952 |
+
"type": "f32"
|
| 953 |
+
},
|
| 954 |
+
"sqrtf128": {
|
| 955 |
+
"sources": [
|
| 956 |
+
"libm/src/math/generic/sqrt.rs",
|
| 957 |
+
"libm/src/math/sqrt.rs"
|
| 958 |
+
],
|
| 959 |
+
"type": "f128"
|
| 960 |
+
},
|
| 961 |
+
"sqrtf16": {
|
| 962 |
+
"sources": [
|
| 963 |
+
"libm/src/math/arch/aarch64.rs",
|
| 964 |
+
"libm/src/math/generic/sqrt.rs",
|
| 965 |
+
"libm/src/math/sqrt.rs"
|
| 966 |
+
],
|
| 967 |
+
"type": "f16"
|
| 968 |
+
},
|
| 969 |
+
"tan": {
|
| 970 |
+
"sources": [
|
| 971 |
+
"libm/src/math/tan.rs"
|
| 972 |
+
],
|
| 973 |
+
"type": "f64"
|
| 974 |
+
},
|
| 975 |
+
"tanf": {
|
| 976 |
+
"sources": [
|
| 977 |
+
"libm/src/math/tanf.rs"
|
| 978 |
+
],
|
| 979 |
+
"type": "f32"
|
| 980 |
+
},
|
| 981 |
+
"tanh": {
|
| 982 |
+
"sources": [
|
| 983 |
+
"libm/src/math/tanh.rs"
|
| 984 |
+
],
|
| 985 |
+
"type": "f64"
|
| 986 |
+
},
|
| 987 |
+
"tanhf": {
|
| 988 |
+
"sources": [
|
| 989 |
+
"libm/src/math/tanhf.rs"
|
| 990 |
+
],
|
| 991 |
+
"type": "f32"
|
| 992 |
+
},
|
| 993 |
+
"tgamma": {
|
| 994 |
+
"sources": [
|
| 995 |
+
"libm/src/math/tgamma.rs"
|
| 996 |
+
],
|
| 997 |
+
"type": "f64"
|
| 998 |
+
},
|
| 999 |
+
"tgammaf": {
|
| 1000 |
+
"sources": [
|
| 1001 |
+
"libm/src/math/tgammaf.rs"
|
| 1002 |
+
],
|
| 1003 |
+
"type": "f32"
|
| 1004 |
+
},
|
| 1005 |
+
"trunc": {
|
| 1006 |
+
"sources": [
|
| 1007 |
+
"libm/src/math/arch/wasm32.rs",
|
| 1008 |
+
"libm/src/math/generic/trunc.rs",
|
| 1009 |
+
"libm/src/math/trunc.rs"
|
| 1010 |
+
],
|
| 1011 |
+
"type": "f64"
|
| 1012 |
+
},
|
| 1013 |
+
"truncf": {
|
| 1014 |
+
"sources": [
|
| 1015 |
+
"libm/src/math/arch/wasm32.rs",
|
| 1016 |
+
"libm/src/math/generic/trunc.rs",
|
| 1017 |
+
"libm/src/math/trunc.rs"
|
| 1018 |
+
],
|
| 1019 |
+
"type": "f32"
|
| 1020 |
+
},
|
| 1021 |
+
"truncf128": {
|
| 1022 |
+
"sources": [
|
| 1023 |
+
"libm/src/math/generic/trunc.rs",
|
| 1024 |
+
"libm/src/math/trunc.rs"
|
| 1025 |
+
],
|
| 1026 |
+
"type": "f128"
|
| 1027 |
+
},
|
| 1028 |
+
"truncf16": {
|
| 1029 |
+
"sources": [
|
| 1030 |
+
"libm/src/math/generic/trunc.rs",
|
| 1031 |
+
"libm/src/math/trunc.rs"
|
| 1032 |
+
],
|
| 1033 |
+
"type": "f16"
|
| 1034 |
+
},
|
| 1035 |
+
"y0": {
|
| 1036 |
+
"sources": [
|
| 1037 |
+
"libm/src/math/j0.rs"
|
| 1038 |
+
],
|
| 1039 |
+
"type": "f64"
|
| 1040 |
+
},
|
| 1041 |
+
"y0f": {
|
| 1042 |
+
"sources": [
|
| 1043 |
+
"libm/src/math/j0f.rs"
|
| 1044 |
+
],
|
| 1045 |
+
"type": "f32"
|
| 1046 |
+
},
|
| 1047 |
+
"y1": {
|
| 1048 |
+
"sources": [
|
| 1049 |
+
"libm/src/math/j1.rs"
|
| 1050 |
+
],
|
| 1051 |
+
"type": "f64"
|
| 1052 |
+
},
|
| 1053 |
+
"y1f": {
|
| 1054 |
+
"sources": [
|
| 1055 |
+
"libm/src/math/j1f.rs"
|
| 1056 |
+
],
|
| 1057 |
+
"type": "f32"
|
| 1058 |
+
},
|
| 1059 |
+
"yn": {
|
| 1060 |
+
"sources": [
|
| 1061 |
+
"libm/src/math/jn.rs"
|
| 1062 |
+
],
|
| 1063 |
+
"type": "f64"
|
| 1064 |
+
},
|
| 1065 |
+
"ynf": {
|
| 1066 |
+
"sources": [
|
| 1067 |
+
"libm/src/math/jnf.rs"
|
| 1068 |
+
],
|
| 1069 |
+
"type": "f32"
|
| 1070 |
+
}
|
| 1071 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/function-list.txt
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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26 |
+
cos
|
| 27 |
+
cosf
|
| 28 |
+
cosh
|
| 29 |
+
coshf
|
| 30 |
+
erf
|
| 31 |
+
erfc
|
| 32 |
+
erfcf
|
| 33 |
+
erff
|
| 34 |
+
exp
|
| 35 |
+
exp10
|
| 36 |
+
exp10f
|
| 37 |
+
exp2
|
| 38 |
+
exp2f
|
| 39 |
+
expf
|
| 40 |
+
expm1
|
| 41 |
+
expm1f
|
| 42 |
+
fabs
|
| 43 |
+
fabsf
|
| 44 |
+
fabsf128
|
| 45 |
+
fabsf16
|
| 46 |
+
fdim
|
| 47 |
+
fdimf
|
| 48 |
+
fdimf128
|
| 49 |
+
fdimf16
|
| 50 |
+
floor
|
| 51 |
+
floorf
|
| 52 |
+
floorf128
|
| 53 |
+
floorf16
|
| 54 |
+
fma
|
| 55 |
+
fmaf
|
| 56 |
+
fmaf128
|
| 57 |
+
fmax
|
| 58 |
+
fmaxf
|
| 59 |
+
fmaxf128
|
| 60 |
+
fmaxf16
|
| 61 |
+
fmaximum
|
| 62 |
+
fmaximum_num
|
| 63 |
+
fmaximum_numf
|
| 64 |
+
fmaximum_numf128
|
| 65 |
+
fmaximum_numf16
|
| 66 |
+
fmaximumf
|
| 67 |
+
fmaximumf128
|
| 68 |
+
fmaximumf16
|
| 69 |
+
fmin
|
| 70 |
+
fminf
|
| 71 |
+
fminf128
|
| 72 |
+
fminf16
|
| 73 |
+
fminimum
|
| 74 |
+
fminimum_num
|
| 75 |
+
fminimum_numf
|
| 76 |
+
fminimum_numf128
|
| 77 |
+
fminimum_numf16
|
| 78 |
+
fminimumf
|
| 79 |
+
fminimumf128
|
| 80 |
+
fminimumf16
|
| 81 |
+
fmod
|
| 82 |
+
fmodf
|
| 83 |
+
fmodf128
|
| 84 |
+
fmodf16
|
| 85 |
+
frexp
|
| 86 |
+
frexpf
|
| 87 |
+
hypot
|
| 88 |
+
hypotf
|
| 89 |
+
ilogb
|
| 90 |
+
ilogbf
|
| 91 |
+
j0
|
| 92 |
+
j0f
|
| 93 |
+
j1
|
| 94 |
+
j1f
|
| 95 |
+
jn
|
| 96 |
+
jnf
|
| 97 |
+
ldexp
|
| 98 |
+
ldexpf
|
| 99 |
+
ldexpf128
|
| 100 |
+
ldexpf16
|
| 101 |
+
lgamma
|
| 102 |
+
lgamma_r
|
| 103 |
+
lgammaf
|
| 104 |
+
lgammaf_r
|
| 105 |
+
log
|
| 106 |
+
log10
|
| 107 |
+
log10f
|
| 108 |
+
log1p
|
| 109 |
+
log1pf
|
| 110 |
+
log2
|
| 111 |
+
log2f
|
| 112 |
+
logf
|
| 113 |
+
modf
|
| 114 |
+
modff
|
| 115 |
+
nextafter
|
| 116 |
+
nextafterf
|
| 117 |
+
pow
|
| 118 |
+
powf
|
| 119 |
+
remainder
|
| 120 |
+
remainderf
|
| 121 |
+
remquo
|
| 122 |
+
remquof
|
| 123 |
+
rint
|
| 124 |
+
rintf
|
| 125 |
+
rintf128
|
| 126 |
+
rintf16
|
| 127 |
+
round
|
| 128 |
+
roundeven
|
| 129 |
+
roundevenf
|
| 130 |
+
roundevenf128
|
| 131 |
+
roundevenf16
|
| 132 |
+
roundf
|
| 133 |
+
roundf128
|
| 134 |
+
roundf16
|
| 135 |
+
scalbn
|
| 136 |
+
scalbnf
|
| 137 |
+
scalbnf128
|
| 138 |
+
scalbnf16
|
| 139 |
+
sin
|
| 140 |
+
sincos
|
| 141 |
+
sincosf
|
| 142 |
+
sinf
|
| 143 |
+
sinh
|
| 144 |
+
sinhf
|
| 145 |
+
sqrt
|
| 146 |
+
sqrtf
|
| 147 |
+
sqrtf128
|
| 148 |
+
sqrtf16
|
| 149 |
+
tan
|
| 150 |
+
tanf
|
| 151 |
+
tanh
|
| 152 |
+
tanhf
|
| 153 |
+
tgamma
|
| 154 |
+
tgammaf
|
| 155 |
+
trunc
|
| 156 |
+
truncf
|
| 157 |
+
truncf128
|
| 158 |
+
truncf16
|
| 159 |
+
y0
|
| 160 |
+
y0f
|
| 161 |
+
y1
|
| 162 |
+
y1f
|
| 163 |
+
yn
|
| 164 |
+
ynf
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/thumbv6-none-eabi.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"abi": "eabi",
|
| 3 |
+
"arch": "arm",
|
| 4 |
+
"asm-args": ["-mthumb-interwork", "-march=armv6", "-mlittle-endian"],
|
| 5 |
+
"c-enum-min-bits": 8,
|
| 6 |
+
"crt-objects-fallback": "false",
|
| 7 |
+
"data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
|
| 8 |
+
"emit-debug-gdb-scripts": false,
|
| 9 |
+
"features": "+soft-float,+strict-align,+v6k",
|
| 10 |
+
"frame-pointer": "always",
|
| 11 |
+
"has-thumb-interworking": true,
|
| 12 |
+
"linker": "rust-lld",
|
| 13 |
+
"linker-flavor": "gnu-lld",
|
| 14 |
+
"llvm-floatabi": "soft",
|
| 15 |
+
"llvm-target": "thumbv6-none-eabi",
|
| 16 |
+
"max-atomic-width": 32,
|
| 17 |
+
"panic-strategy": "abort",
|
| 18 |
+
"relocation-model": "static",
|
| 19 |
+
"target-pointer-width": 32
|
| 20 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/thumbv7em-none-eabi-renamed.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"abi": "eabi",
|
| 3 |
+
"arch": "arm",
|
| 4 |
+
"c-enum-min-bits": 8,
|
| 5 |
+
"crt-objects-fallback": "false",
|
| 6 |
+
"data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
|
| 7 |
+
"emit-debug-gdb-scripts": false,
|
| 8 |
+
"frame-pointer": "always",
|
| 9 |
+
"linker": "rust-lld",
|
| 10 |
+
"linker-flavor": "gnu-lld",
|
| 11 |
+
"llvm-floatabi": "soft",
|
| 12 |
+
"llvm-target": "thumbv7em-none-eabi",
|
| 13 |
+
"max-atomic-width": 32,
|
| 14 |
+
"metadata": {
|
| 15 |
+
"description": "Bare ARMv7E-M",
|
| 16 |
+
"host_tools": false,
|
| 17 |
+
"std": false,
|
| 18 |
+
"tier": 2
|
| 19 |
+
},
|
| 20 |
+
"panic-strategy": "abort",
|
| 21 |
+
"relocation-model": "static",
|
| 22 |
+
"target-pointer-width": 32
|
| 23 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/etc/update-api-list.py
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Create a text file listing all public API. This can be used to ensure that all
|
| 3 |
+
functions are covered by our macros.
|
| 4 |
+
|
| 5 |
+
This file additionally does tidy-esque checks that all functions are listed where
|
| 6 |
+
needed, or that lists are sorted.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import difflib
|
| 10 |
+
import json
|
| 11 |
+
import re
|
| 12 |
+
import subprocess as sp
|
| 13 |
+
import sys
|
| 14 |
+
from dataclasses import dataclass
|
| 15 |
+
from glob import glob
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
from typing import Any, Callable, TypeAlias
|
| 18 |
+
|
| 19 |
+
SELF_PATH = Path(__file__)
|
| 20 |
+
ETC_DIR = SELF_PATH.parent
|
| 21 |
+
ROOT_DIR = ETC_DIR.parent
|
| 22 |
+
|
| 23 |
+
# These files do not trigger a retest.
|
| 24 |
+
IGNORED_SOURCES = ["libm/src/libm_helper.rs", "libm/src/math/support/float_traits.rs"]
|
| 25 |
+
|
| 26 |
+
IndexTy: TypeAlias = dict[str, dict[str, Any]]
|
| 27 |
+
"""Type of the `index` item in rustdoc's JSON output"""
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def eprint(*args, **kwargs):
|
| 31 |
+
"""Print to stderr."""
|
| 32 |
+
print(*args, file=sys.stderr, **kwargs)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
@dataclass
|
| 36 |
+
class Crate:
|
| 37 |
+
"""Representation of public interfaces and function definition locations in
|
| 38 |
+
`libm`.
|
| 39 |
+
"""
|
| 40 |
+
|
| 41 |
+
public_functions: list[str]
|
| 42 |
+
"""List of all public functions."""
|
| 43 |
+
defs: dict[str, list[str]]
|
| 44 |
+
"""Map from `name->[source files]` to find all places that define a public
|
| 45 |
+
function. We track this to know which tests need to be rerun when specific files
|
| 46 |
+
get updated.
|
| 47 |
+
"""
|
| 48 |
+
types: dict[str, str]
|
| 49 |
+
"""Map from `name->type`."""
|
| 50 |
+
|
| 51 |
+
def __init__(self) -> None:
|
| 52 |
+
self.public_functions = []
|
| 53 |
+
self.defs = {}
|
| 54 |
+
self.types = {}
|
| 55 |
+
|
| 56 |
+
j = self.get_rustdoc_json()
|
| 57 |
+
index: IndexTy = j["index"]
|
| 58 |
+
self._init_function_list(index)
|
| 59 |
+
self._init_defs(index)
|
| 60 |
+
self._init_types()
|
| 61 |
+
|
| 62 |
+
@staticmethod
|
| 63 |
+
def get_rustdoc_json() -> dict[Any, Any]:
|
| 64 |
+
"""Get rustdoc's JSON output for the `libm` crate."""
|
| 65 |
+
|
| 66 |
+
j = sp.check_output(
|
| 67 |
+
[
|
| 68 |
+
"rustdoc",
|
| 69 |
+
"libm/src/lib.rs",
|
| 70 |
+
"--edition=2021",
|
| 71 |
+
"--document-private-items",
|
| 72 |
+
"--output-format=json",
|
| 73 |
+
"--cfg=f16_enabled",
|
| 74 |
+
"--cfg=f128_enabled",
|
| 75 |
+
"-Zunstable-options",
|
| 76 |
+
"-o-",
|
| 77 |
+
],
|
| 78 |
+
cwd=ROOT_DIR,
|
| 79 |
+
text=True,
|
| 80 |
+
)
|
| 81 |
+
j = json.loads(j)
|
| 82 |
+
return j
|
| 83 |
+
|
| 84 |
+
def _init_function_list(self, index: IndexTy) -> None:
|
| 85 |
+
"""Get a list of public functions from rustdoc JSON output.
|
| 86 |
+
|
| 87 |
+
Note that this only finds functions that are reexported in `lib.rs`, this will
|
| 88 |
+
need to be adjusted if we need to account for functions that are defined there, or
|
| 89 |
+
glob reexports in other locations.
|
| 90 |
+
"""
|
| 91 |
+
# Filter out items that are not public
|
| 92 |
+
public = [i for i in index.values() if i["visibility"] == "public"]
|
| 93 |
+
|
| 94 |
+
# Collect a list of source IDs for reexported items in `lib.rs` or `mod math`.
|
| 95 |
+
use = (i for i in public if "use" in i["inner"])
|
| 96 |
+
use = (
|
| 97 |
+
i
|
| 98 |
+
for i in use
|
| 99 |
+
if i["span"]["filename"] in ["libm/src/math/mod.rs", "libm/src/lib.rs"]
|
| 100 |
+
)
|
| 101 |
+
reexported_ids = [item["inner"]["use"]["id"] for item in use]
|
| 102 |
+
|
| 103 |
+
# Collect a list of reexported items that are functions
|
| 104 |
+
for id in reexported_ids:
|
| 105 |
+
srcitem = index.get(str(id))
|
| 106 |
+
# External crate
|
| 107 |
+
if srcitem is None:
|
| 108 |
+
continue
|
| 109 |
+
|
| 110 |
+
# Skip if not a function
|
| 111 |
+
if "function" not in srcitem["inner"]:
|
| 112 |
+
continue
|
| 113 |
+
|
| 114 |
+
self.public_functions.append(srcitem["name"])
|
| 115 |
+
self.public_functions.sort()
|
| 116 |
+
|
| 117 |
+
def _init_defs(self, index: IndexTy) -> None:
|
| 118 |
+
defs = {name: set() for name in self.public_functions}
|
| 119 |
+
funcs = (i for i in index.values() if "function" in i["inner"])
|
| 120 |
+
funcs = (f for f in funcs if f["name"] in self.public_functions)
|
| 121 |
+
for func in funcs:
|
| 122 |
+
defs[func["name"]].add(func["span"]["filename"])
|
| 123 |
+
|
| 124 |
+
# A lot of the `arch` module is often configured out so doesn't show up in docs. Use
|
| 125 |
+
# string matching as a fallback.
|
| 126 |
+
for fname in glob(
|
| 127 |
+
"libm/src/math/arch/**/*.rs", root_dir=ROOT_DIR, recursive=True
|
| 128 |
+
):
|
| 129 |
+
contents = (ROOT_DIR.joinpath(fname)).read_text()
|
| 130 |
+
|
| 131 |
+
for name in self.public_functions:
|
| 132 |
+
if f"fn {name}" in contents:
|
| 133 |
+
defs[name].add(fname)
|
| 134 |
+
|
| 135 |
+
for name, sources in defs.items():
|
| 136 |
+
base_sources = defs[base_name(name)[0]]
|
| 137 |
+
for src in (s for s in base_sources if "generic" in s):
|
| 138 |
+
sources.add(src)
|
| 139 |
+
|
| 140 |
+
for src in IGNORED_SOURCES:
|
| 141 |
+
sources.discard(src)
|
| 142 |
+
|
| 143 |
+
# Sort the set
|
| 144 |
+
self.defs = {k: sorted(v) for (k, v) in defs.items()}
|
| 145 |
+
|
| 146 |
+
def _init_types(self) -> None:
|
| 147 |
+
self.types = {name: base_name(name)[1] for name in self.public_functions}
|
| 148 |
+
|
| 149 |
+
def write_function_list(self, check: bool) -> None:
|
| 150 |
+
"""Collect the list of public functions to a simple text file."""
|
| 151 |
+
output = "# autogenerated by update-api-list.py\n"
|
| 152 |
+
for name in self.public_functions:
|
| 153 |
+
output += f"{name}\n"
|
| 154 |
+
|
| 155 |
+
out_file = ETC_DIR.joinpath("function-list.txt")
|
| 156 |
+
|
| 157 |
+
if check:
|
| 158 |
+
with open(out_file, "r") as f:
|
| 159 |
+
current = f.read()
|
| 160 |
+
diff_and_exit(current, output, "function list")
|
| 161 |
+
else:
|
| 162 |
+
with open(out_file, "w") as f:
|
| 163 |
+
f.write(output)
|
| 164 |
+
|
| 165 |
+
def write_function_defs(self, check: bool) -> None:
|
| 166 |
+
"""Collect the list of information about public functions to a JSON file ."""
|
| 167 |
+
comment = (
|
| 168 |
+
"Autogenerated by update-api-list.py. "
|
| 169 |
+
"List of files that define a function with a given name. "
|
| 170 |
+
"This file is checked in to make it obvious if refactoring breaks things"
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
+
d = {"__comment": comment}
|
| 174 |
+
d |= {
|
| 175 |
+
name: {"sources": self.defs[name], "type": self.types[name]}
|
| 176 |
+
for name in self.public_functions
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
out_file = ETC_DIR.joinpath("function-definitions.json")
|
| 180 |
+
output = json.dumps(d, indent=4) + "\n"
|
| 181 |
+
|
| 182 |
+
if check:
|
| 183 |
+
with open(out_file, "r") as f:
|
| 184 |
+
current = f.read()
|
| 185 |
+
diff_and_exit(current, output, "source list")
|
| 186 |
+
else:
|
| 187 |
+
with open(out_file, "w") as f:
|
| 188 |
+
f.write(output)
|
| 189 |
+
|
| 190 |
+
def tidy_lists(self) -> None:
|
| 191 |
+
"""In each file, check annotations indicating blocks of code should be sorted or should
|
| 192 |
+
include all public API.
|
| 193 |
+
"""
|
| 194 |
+
|
| 195 |
+
flist = sp.check_output(["git", "ls-files"], cwd=ROOT_DIR, text=True)
|
| 196 |
+
|
| 197 |
+
for path in flist.splitlines():
|
| 198 |
+
fpath = ROOT_DIR.joinpath(path)
|
| 199 |
+
if fpath.is_dir() or fpath == SELF_PATH:
|
| 200 |
+
continue
|
| 201 |
+
|
| 202 |
+
lines = fpath.read_text().splitlines()
|
| 203 |
+
|
| 204 |
+
validate_delimited_block(
|
| 205 |
+
fpath,
|
| 206 |
+
lines,
|
| 207 |
+
"verify-sorted-start",
|
| 208 |
+
"verify-sorted-end",
|
| 209 |
+
ensure_sorted,
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
validate_delimited_block(
|
| 213 |
+
fpath,
|
| 214 |
+
lines,
|
| 215 |
+
"verify-apilist-start",
|
| 216 |
+
"verify-apilist-end",
|
| 217 |
+
lambda p, n, lines: self.ensure_contains_api(p, n, lines),
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
def ensure_contains_api(self, fpath: Path, line_num: int, lines: list[str]):
|
| 221 |
+
"""Given a list of strings, ensure that each public function we have is named
|
| 222 |
+
somewhere.
|
| 223 |
+
"""
|
| 224 |
+
not_found = []
|
| 225 |
+
for func in self.public_functions:
|
| 226 |
+
# The function name may be on its own or somewhere in a snake case string.
|
| 227 |
+
pat = re.compile(rf"(\b|_){func}(\b|_)")
|
| 228 |
+
found = next((line for line in lines if pat.search(line)), None)
|
| 229 |
+
|
| 230 |
+
if found is None:
|
| 231 |
+
not_found.append(func)
|
| 232 |
+
|
| 233 |
+
if len(not_found) == 0:
|
| 234 |
+
return
|
| 235 |
+
|
| 236 |
+
relpath = fpath.relative_to(ROOT_DIR)
|
| 237 |
+
eprint(f"functions not found at {relpath}:{line_num}: {not_found}")
|
| 238 |
+
exit(1)
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def validate_delimited_block(
|
| 242 |
+
fpath: Path,
|
| 243 |
+
lines: list[str],
|
| 244 |
+
start: str,
|
| 245 |
+
end: str,
|
| 246 |
+
validate: Callable[[Path, int, list[str]], None],
|
| 247 |
+
) -> None:
|
| 248 |
+
"""Identify blocks of code wrapped within `start` and `end`, collect their contents
|
| 249 |
+
to a list of strings, and call `validate` for each of those lists.
|
| 250 |
+
"""
|
| 251 |
+
relpath = fpath.relative_to(ROOT_DIR)
|
| 252 |
+
block_lines = []
|
| 253 |
+
block_start_line: None | int = None
|
| 254 |
+
for line_num, line in enumerate(lines):
|
| 255 |
+
line_num += 1
|
| 256 |
+
|
| 257 |
+
if start in line:
|
| 258 |
+
block_start_line = line_num
|
| 259 |
+
continue
|
| 260 |
+
|
| 261 |
+
if end in line:
|
| 262 |
+
if block_start_line is None:
|
| 263 |
+
eprint(f"`{end}` without `{start}` at {relpath}:{line_num}")
|
| 264 |
+
exit(1)
|
| 265 |
+
|
| 266 |
+
validate(fpath, block_start_line, block_lines)
|
| 267 |
+
block_lines = []
|
| 268 |
+
block_start_line = None
|
| 269 |
+
continue
|
| 270 |
+
|
| 271 |
+
if block_start_line is not None:
|
| 272 |
+
block_lines.append(line)
|
| 273 |
+
|
| 274 |
+
if block_start_line is not None:
|
| 275 |
+
eprint(f"`{start}` without `{end}` at {relpath}:{block_start_line}")
|
| 276 |
+
exit(1)
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def ensure_sorted(fpath: Path, block_start_line: int, lines: list[str]) -> None:
|
| 280 |
+
"""Ensure that a list of lines is sorted, otherwise print a diff and exit."""
|
| 281 |
+
relpath = fpath.relative_to(ROOT_DIR)
|
| 282 |
+
diff_and_exit(
|
| 283 |
+
"\n".join(lines),
|
| 284 |
+
"\n".join(sorted(lines)),
|
| 285 |
+
f"sorted block at {relpath}:{block_start_line}",
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
def diff_and_exit(actual: str, expected: str, name: str):
|
| 290 |
+
"""If the two strings are different, print a diff between them and then exit
|
| 291 |
+
with an error.
|
| 292 |
+
"""
|
| 293 |
+
if actual == expected:
|
| 294 |
+
print(f"{name} output matches expected; success")
|
| 295 |
+
return
|
| 296 |
+
|
| 297 |
+
a = [f"{line}\n" for line in actual.splitlines()]
|
| 298 |
+
b = [f"{line}\n" for line in expected.splitlines()]
|
| 299 |
+
|
| 300 |
+
diff = difflib.unified_diff(a, b, "actual", "expected")
|
| 301 |
+
sys.stdout.writelines(diff)
|
| 302 |
+
print(f"mismatched {name}")
|
| 303 |
+
exit(1)
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
def base_name(name: str) -> tuple[str, str]:
|
| 307 |
+
"""Return the basename and type from a full function name. Keep in sync with Rust's
|
| 308 |
+
`fn base_name`.
|
| 309 |
+
"""
|
| 310 |
+
known_mappings = [
|
| 311 |
+
("erff", ("erf", "f32")),
|
| 312 |
+
("erf", ("erf", "f64")),
|
| 313 |
+
("modff", ("modf", "f32")),
|
| 314 |
+
("modf", ("modf", "f64")),
|
| 315 |
+
("lgammaf_r", ("lgamma_r", "f32")),
|
| 316 |
+
("lgamma_r", ("lgamma_r", "f64")),
|
| 317 |
+
]
|
| 318 |
+
|
| 319 |
+
found = next((base for (full, base) in known_mappings if full == name), None)
|
| 320 |
+
if found is not None:
|
| 321 |
+
return found
|
| 322 |
+
|
| 323 |
+
if name.endswith("f"):
|
| 324 |
+
return (name.rstrip("f"), "f32")
|
| 325 |
+
|
| 326 |
+
if name.endswith("f16"):
|
| 327 |
+
return (name.rstrip("f16"), "f16")
|
| 328 |
+
|
| 329 |
+
if name.endswith("f128"):
|
| 330 |
+
return (name.rstrip("f128"), "f128")
|
| 331 |
+
|
| 332 |
+
return (name, "f64")
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def ensure_updated_list(check: bool) -> None:
|
| 336 |
+
"""Runner to update the function list and JSON, or check that it is already up
|
| 337 |
+
to date.
|
| 338 |
+
"""
|
| 339 |
+
crate = Crate()
|
| 340 |
+
crate.write_function_list(check)
|
| 341 |
+
crate.write_function_defs(check)
|
| 342 |
+
|
| 343 |
+
crate.tidy_lists()
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
def main():
|
| 347 |
+
"""By default overwrite the file. If `--check` is passed, print a diff instead and
|
| 348 |
+
error if the files are different.
|
| 349 |
+
"""
|
| 350 |
+
match sys.argv:
|
| 351 |
+
case [_]:
|
| 352 |
+
ensure_updated_list(False)
|
| 353 |
+
case [_, "--check"]:
|
| 354 |
+
ensure_updated_list(True)
|
| 355 |
+
case _:
|
| 356 |
+
print("unrecognized arguments")
|
| 357 |
+
exit(1)
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
if __name__ == "__main__":
|
| 361 |
+
main()
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/libm-test/Cargo.toml
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "libm-test"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
publish = false
|
| 6 |
+
license = "MIT OR Apache-2.0"
|
| 7 |
+
|
| 8 |
+
[dependencies]
|
| 9 |
+
anyhow.workspace = true
|
| 10 |
+
# This is not directly used but is required so we can enable `gmp-mpfr-sys/force-cross`.
|
| 11 |
+
gmp-mpfr-sys = { workspace = true, optional = true }
|
| 12 |
+
gungraun = { workspace = true, optional = true }
|
| 13 |
+
indicatif.workspace = true
|
| 14 |
+
libm = { workspace = true, default-features = true, features = ["unstable-public-internals"] }
|
| 15 |
+
libm-macros.workspace = true
|
| 16 |
+
musl-math-sys = { workspace = true, optional = true }
|
| 17 |
+
paste.workspace = true
|
| 18 |
+
rand.workspace = true
|
| 19 |
+
rand_chacha.workspace = true
|
| 20 |
+
rayon.workspace = true
|
| 21 |
+
rug = { workspace = true, optional = true }
|
| 22 |
+
|
| 23 |
+
[target.'cfg(target_family = "wasm")'.dependencies]
|
| 24 |
+
getrandom = { workspace = true, features = ["wasm_js"] }
|
| 25 |
+
|
| 26 |
+
[build-dependencies]
|
| 27 |
+
rand = { workspace = true, optional = true }
|
| 28 |
+
|
| 29 |
+
[dev-dependencies]
|
| 30 |
+
criterion.workspace = true
|
| 31 |
+
libtest-mimic.workspace = true
|
| 32 |
+
|
| 33 |
+
[features]
|
| 34 |
+
default = ["build-mpfr", "unstable-float"]
|
| 35 |
+
|
| 36 |
+
# Propagated from libm because this affects which functions we test.
|
| 37 |
+
unstable-float = ["libm/unstable-float", "rug?/nightly-float"]
|
| 38 |
+
|
| 39 |
+
# Generate tests which are random inputs and the outputs are calculated with
|
| 40 |
+
# musl libc.
|
| 41 |
+
build-mpfr = ["dep:rug", "dep:gmp-mpfr-sys"]
|
| 42 |
+
|
| 43 |
+
# Build our own musl for testing and benchmarks
|
| 44 |
+
build-musl = ["dep:musl-math-sys"]
|
| 45 |
+
|
| 46 |
+
# Enable report generation without bringing in more dependencies by default
|
| 47 |
+
benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]
|
| 48 |
+
|
| 49 |
+
# Enable icount benchmarks (requires gungraun-runner and valgrind locally)
|
| 50 |
+
icount = ["dep:gungraun"]
|
| 51 |
+
|
| 52 |
+
# Run with a reduced set of benchmarks, such as for CI
|
| 53 |
+
short-benchmarks = []
|
| 54 |
+
|
| 55 |
+
[[bench]]
|
| 56 |
+
name = "icount"
|
| 57 |
+
harness = false
|
| 58 |
+
required-features = ["icount"]
|
| 59 |
+
|
| 60 |
+
[[bench]]
|
| 61 |
+
name = "random"
|
| 62 |
+
harness = false
|
| 63 |
+
|
| 64 |
+
[[test]]
|
| 65 |
+
# No harness so that we can skip tests at runtime based on env. Prefixed with
|
| 66 |
+
# `z` so these tests get run last.
|
| 67 |
+
name = "z_extensive"
|
| 68 |
+
harness = false
|
| 69 |
+
|
| 70 |
+
[lints.rust]
|
| 71 |
+
# Values from the chared config.rs used by `libm` but not the test crate
|
| 72 |
+
unexpected_cfgs = { level = "warn", check-cfg = [
|
| 73 |
+
'cfg(feature, values("arch", "force-soft-floats", "unstable-intrinsics"))',
|
| 74 |
+
] }
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/libm-test/benches/icount.rs
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Benchmarks that use `gungraun` to be reasonably CI-stable.
|
| 2 |
+
#![feature(f16)]
|
| 3 |
+
#![feature(f128)]
|
| 4 |
+
|
| 5 |
+
use std::hint::black_box;
|
| 6 |
+
|
| 7 |
+
use gungraun::{library_benchmark, library_benchmark_group, main};
|
| 8 |
+
use libm::support::{HInt, Hexf, hf16, hf32, hf64, hf128, u256};
|
| 9 |
+
use libm_test::generate::spaced;
|
| 10 |
+
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, OpRustArgs, TupleCall, op};
|
| 11 |
+
|
| 12 |
+
const BENCH_ITER_ITEMS: u64 = 500;
|
| 13 |
+
|
| 14 |
+
macro_rules! icount_benches {
|
| 15 |
+
(
|
| 16 |
+
fn_name: $fn_name:ident,
|
| 17 |
+
attrs: [$($_attr:meta),*],
|
| 18 |
+
) => {
|
| 19 |
+
paste::paste! {
|
| 20 |
+
// Construct benchmark inputs from the logspace generator.
|
| 21 |
+
fn [< setup_ $fn_name >]() -> Vec<OpRustArgs<op::$fn_name::Routine>> {
|
| 22 |
+
type Op = op::$fn_name::Routine;
|
| 23 |
+
let mut ctx = CheckCtx::new(
|
| 24 |
+
Op::IDENTIFIER,
|
| 25 |
+
CheckBasis::None,
|
| 26 |
+
GeneratorKind::Spaced
|
| 27 |
+
);
|
| 28 |
+
ctx.override_iterations(BENCH_ITER_ITEMS);
|
| 29 |
+
let ret = spaced::get_test_cases::<Op>(&ctx).0.collect::<Vec<_>>();
|
| 30 |
+
println!("operation {}, {} steps", Op::NAME, ret.len());
|
| 31 |
+
ret
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
// Run benchmarks with the above inputs.
|
| 35 |
+
#[library_benchmark]
|
| 36 |
+
#[bench::logspace([< setup_ $fn_name >]())]
|
| 37 |
+
fn [< icount_bench_ $fn_name >](cases: Vec<OpRustArgs<op::$fn_name::Routine>>) {
|
| 38 |
+
type Op = op::$fn_name::Routine;
|
| 39 |
+
let f = black_box(Op::ROUTINE);
|
| 40 |
+
for input in cases.iter().copied() {
|
| 41 |
+
input.call(f);
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
library_benchmark_group!(
|
| 46 |
+
name = [< icount_bench_ $fn_name _group >];
|
| 47 |
+
benchmarks = [< icount_bench_ $fn_name >]
|
| 48 |
+
);
|
| 49 |
+
}
|
| 50 |
+
};
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
libm_macros::for_each_function! {
|
| 54 |
+
callback: icount_benches,
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
fn setup_u128_mul() -> Vec<(u128, u128)> {
|
| 58 |
+
let step = u128::MAX / 300;
|
| 59 |
+
let mut x = 0u128;
|
| 60 |
+
let mut y = 0u128;
|
| 61 |
+
let mut v = Vec::new();
|
| 62 |
+
|
| 63 |
+
loop {
|
| 64 |
+
'inner: loop {
|
| 65 |
+
match y.checked_add(step) {
|
| 66 |
+
Some(new) => y = new,
|
| 67 |
+
None => break 'inner,
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
v.push((x, y))
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
match x.checked_add(step) {
|
| 74 |
+
Some(new) => x = new,
|
| 75 |
+
None => break,
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
v
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
fn setup_u256_add() -> Vec<(u256, u256)> {
|
| 83 |
+
let mut v = Vec::new();
|
| 84 |
+
for (x, y) in setup_u128_mul() {
|
| 85 |
+
// square the u128 inputs to cover most of the u256 range
|
| 86 |
+
v.push((x.widen_mul(x), y.widen_mul(y)));
|
| 87 |
+
}
|
| 88 |
+
// Doesn't get covered by `u128:MAX^2`
|
| 89 |
+
v.push((u256::MAX, u256::MAX));
|
| 90 |
+
v
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
fn setup_u256_shift() -> Vec<(u256, u32)> {
|
| 94 |
+
let mut v = Vec::new();
|
| 95 |
+
|
| 96 |
+
for (x, _) in setup_u128_mul() {
|
| 97 |
+
let x2 = x.widen_mul(x);
|
| 98 |
+
for y in 0u32..256 {
|
| 99 |
+
v.push((x2, y));
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
v
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
#[library_benchmark]
|
| 107 |
+
#[bench::linspace(setup_u128_mul())]
|
| 108 |
+
fn icount_bench_u128_widen_mul(cases: Vec<(u128, u128)>) {
|
| 109 |
+
for (x, y) in cases.iter().copied() {
|
| 110 |
+
black_box(black_box(x).zero_widen_mul(black_box(y)));
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
#[library_benchmark]
|
| 115 |
+
#[bench::linspace(setup_u128_mul())]
|
| 116 |
+
fn icount_bench_u256_narrowing_div(cases: Vec<(u128, u128)>) {
|
| 117 |
+
use libm::support::NarrowingDiv;
|
| 118 |
+
for (x, y) in cases.iter().copied() {
|
| 119 |
+
let x = black_box(x.widen_hi());
|
| 120 |
+
let y = black_box(y);
|
| 121 |
+
black_box(x.checked_narrowing_div_rem(y));
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
#[library_benchmark]
|
| 126 |
+
#[bench::linspace(setup_u256_add())]
|
| 127 |
+
fn icount_bench_u256_add(cases: Vec<(u256, u256)>) {
|
| 128 |
+
for (x, y) in cases.iter().copied() {
|
| 129 |
+
black_box(black_box(x) + black_box(y));
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
#[library_benchmark]
|
| 134 |
+
#[bench::linspace(setup_u256_add())]
|
| 135 |
+
fn icount_bench_u256_sub(cases: Vec<(u256, u256)>) {
|
| 136 |
+
for (x, y) in cases.iter().copied() {
|
| 137 |
+
black_box(black_box(x) - black_box(y));
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
#[library_benchmark]
|
| 142 |
+
#[bench::linspace(setup_u256_shift())]
|
| 143 |
+
fn icount_bench_u256_shl(cases: Vec<(u256, u32)>) {
|
| 144 |
+
for (x, y) in cases.iter().copied() {
|
| 145 |
+
black_box(black_box(x) << black_box(y));
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
#[library_benchmark]
|
| 150 |
+
#[bench::linspace(setup_u256_shift())]
|
| 151 |
+
fn icount_bench_u256_shr(cases: Vec<(u256, u32)>) {
|
| 152 |
+
for (x, y) in cases.iter().copied() {
|
| 153 |
+
black_box(black_box(x) >> black_box(y));
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
library_benchmark_group!(
|
| 158 |
+
name = icount_bench_u128_group;
|
| 159 |
+
benchmarks =
|
| 160 |
+
icount_bench_u128_widen_mul,
|
| 161 |
+
icount_bench_u256_narrowing_div,
|
| 162 |
+
icount_bench_u256_add,
|
| 163 |
+
icount_bench_u256_sub,
|
| 164 |
+
icount_bench_u256_shl,
|
| 165 |
+
icount_bench_u256_shr
|
| 166 |
+
);
|
| 167 |
+
|
| 168 |
+
#[library_benchmark]
|
| 169 |
+
#[bench::short("0x12.34p+8")]
|
| 170 |
+
#[bench::max("0x1.ffcp+15")]
|
| 171 |
+
fn icount_bench_hf16(s: &str) -> f16 {
|
| 172 |
+
black_box(hf16(s))
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
#[library_benchmark]
|
| 176 |
+
#[bench::short("0x12.34p+8")]
|
| 177 |
+
#[bench::max("0x1.fffffep+127")]
|
| 178 |
+
fn icount_bench_hf32(s: &str) -> f32 {
|
| 179 |
+
black_box(hf32(s))
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
#[library_benchmark]
|
| 183 |
+
#[bench::short("0x12.34p+8")]
|
| 184 |
+
#[bench::max("0x1.fffffffffffffp+1023")]
|
| 185 |
+
fn icount_bench_hf64(s: &str) -> f64 {
|
| 186 |
+
black_box(hf64(s))
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
#[library_benchmark]
|
| 190 |
+
#[bench::short("0x12.34p+8")]
|
| 191 |
+
#[bench::max("0x1.ffffffffffffffffffffffffffffp+16383")]
|
| 192 |
+
fn icount_bench_hf128(s: &str) -> f128 {
|
| 193 |
+
black_box(hf128(s))
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
library_benchmark_group!(
|
| 197 |
+
name = icount_bench_hf_parse_group;
|
| 198 |
+
benchmarks =
|
| 199 |
+
icount_bench_hf16,
|
| 200 |
+
icount_bench_hf32,
|
| 201 |
+
icount_bench_hf64,
|
| 202 |
+
icount_bench_hf128
|
| 203 |
+
);
|
| 204 |
+
|
| 205 |
+
#[library_benchmark]
|
| 206 |
+
#[bench::short(1.015625)]
|
| 207 |
+
#[bench::max(f16::MAX)]
|
| 208 |
+
fn icount_bench_print_hf16(x: f16) -> String {
|
| 209 |
+
black_box(Hexf(x).to_string())
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
#[library_benchmark]
|
| 213 |
+
#[bench::short(1.015625)]
|
| 214 |
+
#[bench::max(f32::MAX)]
|
| 215 |
+
fn icount_bench_print_hf32(x: f32) -> String {
|
| 216 |
+
black_box(Hexf(x).to_string())
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
#[library_benchmark]
|
| 220 |
+
#[bench::short(1.015625)]
|
| 221 |
+
#[bench::max(f64::MAX)]
|
| 222 |
+
fn icount_bench_print_hf64(x: f64) -> String {
|
| 223 |
+
black_box(Hexf(x).to_string())
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
#[library_benchmark]
|
| 227 |
+
#[bench::short(1.015625)]
|
| 228 |
+
#[bench::max(f128::MAX)]
|
| 229 |
+
fn icount_bench_print_hf128(x: f128) -> String {
|
| 230 |
+
black_box(Hexf(x).to_string())
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
library_benchmark_group!(
|
| 234 |
+
name = icount_bench_hf_print_group;
|
| 235 |
+
benchmarks =
|
| 236 |
+
icount_bench_print_hf16,
|
| 237 |
+
icount_bench_print_hf32,
|
| 238 |
+
icount_bench_print_hf64,
|
| 239 |
+
icount_bench_print_hf128
|
| 240 |
+
);
|
| 241 |
+
|
| 242 |
+
main!(
|
| 243 |
+
library_benchmark_groups =
|
| 244 |
+
// Benchmarks not related to public libm math
|
| 245 |
+
icount_bench_u128_group,
|
| 246 |
+
icount_bench_hf_parse_group,
|
| 247 |
+
icount_bench_hf_print_group,
|
| 248 |
+
// verify-apilist-start
|
| 249 |
+
// verify-sorted-start
|
| 250 |
+
icount_bench_acos_group,
|
| 251 |
+
icount_bench_acosf_group,
|
| 252 |
+
icount_bench_acosh_group,
|
| 253 |
+
icount_bench_acoshf_group,
|
| 254 |
+
icount_bench_asin_group,
|
| 255 |
+
icount_bench_asinf_group,
|
| 256 |
+
icount_bench_asinh_group,
|
| 257 |
+
icount_bench_asinhf_group,
|
| 258 |
+
icount_bench_atan2_group,
|
| 259 |
+
icount_bench_atan2f_group,
|
| 260 |
+
icount_bench_atan_group,
|
| 261 |
+
icount_bench_atanf_group,
|
| 262 |
+
icount_bench_atanh_group,
|
| 263 |
+
icount_bench_atanhf_group,
|
| 264 |
+
icount_bench_cbrt_group,
|
| 265 |
+
icount_bench_cbrtf_group,
|
| 266 |
+
icount_bench_ceil_group,
|
| 267 |
+
icount_bench_ceilf128_group,
|
| 268 |
+
icount_bench_ceilf16_group,
|
| 269 |
+
icount_bench_ceilf_group,
|
| 270 |
+
icount_bench_copysign_group,
|
| 271 |
+
icount_bench_copysignf128_group,
|
| 272 |
+
icount_bench_copysignf16_group,
|
| 273 |
+
icount_bench_copysignf_group,
|
| 274 |
+
icount_bench_cos_group,
|
| 275 |
+
icount_bench_cosf_group,
|
| 276 |
+
icount_bench_cosh_group,
|
| 277 |
+
icount_bench_coshf_group,
|
| 278 |
+
icount_bench_erf_group,
|
| 279 |
+
icount_bench_erfc_group,
|
| 280 |
+
icount_bench_erfcf_group,
|
| 281 |
+
icount_bench_erff_group,
|
| 282 |
+
icount_bench_exp10_group,
|
| 283 |
+
icount_bench_exp10f_group,
|
| 284 |
+
icount_bench_exp2_group,
|
| 285 |
+
icount_bench_exp2f_group,
|
| 286 |
+
icount_bench_exp_group,
|
| 287 |
+
icount_bench_expf_group,
|
| 288 |
+
icount_bench_expm1_group,
|
| 289 |
+
icount_bench_expm1f_group,
|
| 290 |
+
icount_bench_fabs_group,
|
| 291 |
+
icount_bench_fabsf128_group,
|
| 292 |
+
icount_bench_fabsf16_group,
|
| 293 |
+
icount_bench_fabsf_group,
|
| 294 |
+
icount_bench_fdim_group,
|
| 295 |
+
icount_bench_fdimf128_group,
|
| 296 |
+
icount_bench_fdimf16_group,
|
| 297 |
+
icount_bench_fdimf_group,
|
| 298 |
+
icount_bench_floor_group,
|
| 299 |
+
icount_bench_floorf128_group,
|
| 300 |
+
icount_bench_floorf16_group,
|
| 301 |
+
icount_bench_floorf_group,
|
| 302 |
+
icount_bench_fma_group,
|
| 303 |
+
icount_bench_fmaf128_group,
|
| 304 |
+
icount_bench_fmaf_group,
|
| 305 |
+
icount_bench_fmax_group,
|
| 306 |
+
icount_bench_fmaxf128_group,
|
| 307 |
+
icount_bench_fmaxf16_group,
|
| 308 |
+
icount_bench_fmaxf_group,
|
| 309 |
+
icount_bench_fmaximum_group,
|
| 310 |
+
icount_bench_fmaximum_num_group,
|
| 311 |
+
icount_bench_fmaximum_numf128_group,
|
| 312 |
+
icount_bench_fmaximum_numf16_group,
|
| 313 |
+
icount_bench_fmaximum_numf_group,
|
| 314 |
+
icount_bench_fmaximumf128_group,
|
| 315 |
+
icount_bench_fmaximumf16_group,
|
| 316 |
+
icount_bench_fmaximumf_group,
|
| 317 |
+
icount_bench_fmin_group,
|
| 318 |
+
icount_bench_fminf128_group,
|
| 319 |
+
icount_bench_fminf16_group,
|
| 320 |
+
icount_bench_fminf_group,
|
| 321 |
+
icount_bench_fminimum_group,
|
| 322 |
+
icount_bench_fminimum_num_group,
|
| 323 |
+
icount_bench_fminimum_numf128_group,
|
| 324 |
+
icount_bench_fminimum_numf16_group,
|
| 325 |
+
icount_bench_fminimum_numf_group,
|
| 326 |
+
icount_bench_fminimumf128_group,
|
| 327 |
+
icount_bench_fminimumf16_group,
|
| 328 |
+
icount_bench_fminimumf_group,
|
| 329 |
+
icount_bench_fmod_group,
|
| 330 |
+
icount_bench_fmodf128_group,
|
| 331 |
+
icount_bench_fmodf16_group,
|
| 332 |
+
icount_bench_fmodf_group,
|
| 333 |
+
icount_bench_frexp_group,
|
| 334 |
+
icount_bench_frexpf_group,
|
| 335 |
+
icount_bench_hypot_group,
|
| 336 |
+
icount_bench_hypotf_group,
|
| 337 |
+
icount_bench_ilogb_group,
|
| 338 |
+
icount_bench_ilogbf_group,
|
| 339 |
+
icount_bench_j0_group,
|
| 340 |
+
icount_bench_j0f_group,
|
| 341 |
+
icount_bench_j1_group,
|
| 342 |
+
icount_bench_j1f_group,
|
| 343 |
+
icount_bench_jn_group,
|
| 344 |
+
icount_bench_jnf_group,
|
| 345 |
+
icount_bench_ldexp_group,
|
| 346 |
+
icount_bench_ldexpf128_group,
|
| 347 |
+
icount_bench_ldexpf16_group,
|
| 348 |
+
icount_bench_ldexpf_group,
|
| 349 |
+
icount_bench_lgamma_group,
|
| 350 |
+
icount_bench_lgamma_r_group,
|
| 351 |
+
icount_bench_lgammaf_group,
|
| 352 |
+
icount_bench_lgammaf_r_group,
|
| 353 |
+
icount_bench_log10_group,
|
| 354 |
+
icount_bench_log10f_group,
|
| 355 |
+
icount_bench_log1p_group,
|
| 356 |
+
icount_bench_log1pf_group,
|
| 357 |
+
icount_bench_log2_group,
|
| 358 |
+
icount_bench_log2f_group,
|
| 359 |
+
icount_bench_log_group,
|
| 360 |
+
icount_bench_logf_group,
|
| 361 |
+
icount_bench_modf_group,
|
| 362 |
+
icount_bench_modff_group,
|
| 363 |
+
icount_bench_nextafter_group,
|
| 364 |
+
icount_bench_nextafterf_group,
|
| 365 |
+
icount_bench_pow_group,
|
| 366 |
+
icount_bench_powf_group,
|
| 367 |
+
icount_bench_remainder_group,
|
| 368 |
+
icount_bench_remainderf_group,
|
| 369 |
+
icount_bench_remquo_group,
|
| 370 |
+
icount_bench_remquof_group,
|
| 371 |
+
icount_bench_rint_group,
|
| 372 |
+
icount_bench_rintf128_group,
|
| 373 |
+
icount_bench_rintf16_group,
|
| 374 |
+
icount_bench_rintf_group,
|
| 375 |
+
icount_bench_round_group,
|
| 376 |
+
icount_bench_roundeven_group,
|
| 377 |
+
icount_bench_roundevenf128_group,
|
| 378 |
+
icount_bench_roundevenf16_group,
|
| 379 |
+
icount_bench_roundevenf_group,
|
| 380 |
+
icount_bench_roundf128_group,
|
| 381 |
+
icount_bench_roundf16_group,
|
| 382 |
+
icount_bench_roundf_group,
|
| 383 |
+
icount_bench_scalbn_group,
|
| 384 |
+
icount_bench_scalbnf128_group,
|
| 385 |
+
icount_bench_scalbnf16_group,
|
| 386 |
+
icount_bench_scalbnf_group,
|
| 387 |
+
icount_bench_sin_group,
|
| 388 |
+
icount_bench_sincos_group,
|
| 389 |
+
icount_bench_sincosf_group,
|
| 390 |
+
icount_bench_sinf_group,
|
| 391 |
+
icount_bench_sinh_group,
|
| 392 |
+
icount_bench_sinhf_group,
|
| 393 |
+
icount_bench_sqrt_group,
|
| 394 |
+
icount_bench_sqrtf128_group,
|
| 395 |
+
icount_bench_sqrtf16_group,
|
| 396 |
+
icount_bench_sqrtf_group,
|
| 397 |
+
icount_bench_tan_group,
|
| 398 |
+
icount_bench_tanf_group,
|
| 399 |
+
icount_bench_tanh_group,
|
| 400 |
+
icount_bench_tanhf_group,
|
| 401 |
+
icount_bench_tgamma_group,
|
| 402 |
+
icount_bench_tgammaf_group,
|
| 403 |
+
icount_bench_trunc_group,
|
| 404 |
+
icount_bench_truncf128_group,
|
| 405 |
+
icount_bench_truncf16_group,
|
| 406 |
+
icount_bench_truncf_group,
|
| 407 |
+
icount_bench_y0_group,
|
| 408 |
+
icount_bench_y0f_group,
|
| 409 |
+
icount_bench_y1_group,
|
| 410 |
+
icount_bench_y1f_group,
|
| 411 |
+
icount_bench_yn_group,
|
| 412 |
+
icount_bench_ynf_group,
|
| 413 |
+
// verify-sorted-end
|
| 414 |
+
// verify-apilist-end
|
| 415 |
+
);
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/compiler-builtins/libm-test/benches/random.rs
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
| 5 |
+
use libm_test::generate::random;
|
| 6 |
+
use libm_test::generate::random::RandomInput;
|
| 7 |
+
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, TupleCall};
|
| 8 |
+
|
| 9 |
+
/// Benchmark with this many items to get a variety
|
| 10 |
+
const BENCH_ITER_ITEMS: usize = if cfg!(feature = "short-benchmarks") {
|
| 11 |
+
50
|
| 12 |
+
} else {
|
| 13 |
+
500
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
/// Extra parameters we only care about if we are benchmarking against musl.
|
| 17 |
+
#[allow(dead_code)]
|
| 18 |
+
struct MuslExtra<F> {
|
| 19 |
+
musl_fn: Option<F>,
|
| 20 |
+
skip_on_i586: bool,
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
macro_rules! musl_rand_benches {
|
| 24 |
+
(
|
| 25 |
+
fn_name: $fn_name:ident,
|
| 26 |
+
attrs: [$($attr:meta),*],
|
| 27 |
+
fn_extra: ($skip_on_i586:expr, $musl_fn:expr),
|
| 28 |
+
) => {
|
| 29 |
+
paste::paste! {
|
| 30 |
+
$(#[$attr])*
|
| 31 |
+
fn [< musl_bench_ $fn_name >](c: &mut Criterion) {
|
| 32 |
+
type Op = libm_test::op::$fn_name::Routine;
|
| 33 |
+
|
| 34 |
+
#[cfg(feature = "build-musl")]
|
| 35 |
+
let musl_extra = MuslExtra::<libm_test::OpCFn<Op>> {
|
| 36 |
+
musl_fn: $musl_fn,
|
| 37 |
+
skip_on_i586: $skip_on_i586,
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
#[cfg(not(feature = "build-musl"))]
|
| 41 |
+
let musl_extra = MuslExtra {
|
| 42 |
+
musl_fn: None,
|
| 43 |
+
skip_on_i586: $skip_on_i586,
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
bench_one::<Op>(c, musl_extra);
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
};
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
fn bench_one<Op>(c: &mut Criterion, musl_extra: MuslExtra<Op::CFn>)
|
| 53 |
+
where
|
| 54 |
+
Op: MathOp,
|
| 55 |
+
Op::RustArgs: RandomInput,
|
| 56 |
+
{
|
| 57 |
+
let name = Op::NAME;
|
| 58 |
+
|
| 59 |
+
let ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Musl, GeneratorKind::Random);
|
| 60 |
+
let benchvec: Vec<_> = random::get_test_cases::<Op::RustArgs>(&ctx)
|
| 61 |
+
.0
|
| 62 |
+
.take(BENCH_ITER_ITEMS)
|
| 63 |
+
.collect();
|
| 64 |
+
|
| 65 |
+
// Perform a sanity check that we are benchmarking the same thing
|
| 66 |
+
// Don't test against musl if it is not available
|
| 67 |
+
#[cfg(feature = "build-musl")]
|
| 68 |
+
for input in benchvec.iter().copied() {
|
| 69 |
+
use anyhow::Context;
|
| 70 |
+
use libm_test::CheckOutput;
|
| 71 |
+
|
| 72 |
+
if cfg!(x86_no_sse) && musl_extra.skip_on_i586 {
|
| 73 |
+
break;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
let Some(musl_fn) = musl_extra.musl_fn else {
|
| 77 |
+
continue;
|
| 78 |
+
};
|
| 79 |
+
let musl_res = input.call(musl_fn);
|
| 80 |
+
let crate_res = input.call(Op::ROUTINE);
|
| 81 |
+
|
| 82 |
+
crate_res
|
| 83 |
+
.validate(musl_res, input, &ctx)
|
| 84 |
+
.context(name)
|
| 85 |
+
.unwrap();
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
#[cfg(not(feature = "build-musl"))]
|
| 89 |
+
let _ = musl_extra; // silence unused warnings
|
| 90 |
+
|
| 91 |
+
/* Option pointers are black boxed to avoid inlining in the benchmark loop */
|
| 92 |
+
|
| 93 |
+
let mut group = c.benchmark_group(name);
|
| 94 |
+
group.bench_function("crate", |b| {
|
| 95 |
+
b.iter(|| {
|
| 96 |
+
let f = black_box(Op::ROUTINE);
|
| 97 |
+
for input in benchvec.iter().copied() {
|
| 98 |
+
input.call(f);
|
| 99 |
+
}
|
| 100 |
+
})
|
| 101 |
+
});
|
| 102 |
+
|
| 103 |
+
// Don't test against musl if it is not available
|
| 104 |
+
#[cfg(feature = "build-musl")]
|
| 105 |
+
{
|
| 106 |
+
if let Some(musl_fn) = musl_extra.musl_fn {
|
| 107 |
+
group.bench_function("musl", |b| {
|
| 108 |
+
b.iter(|| {
|
| 109 |
+
let f = black_box(musl_fn);
|
| 110 |
+
for input in benchvec.iter().copied() {
|
| 111 |
+
input.call(f);
|
| 112 |
+
}
|
| 113 |
+
})
|
| 114 |
+
});
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
libm_macros::for_each_function! {
|
| 120 |
+
callback: musl_rand_benches,
|
| 121 |
+
skip: [],
|
| 122 |
+
fn_extra: match MACRO_FN_NAME {
|
| 123 |
+
// We pass a tuple of `(skip_on_i586, musl_fn)`
|
| 124 |
+
|
| 125 |
+
// FIXME(correctness): exp functions have the wrong result on i586
|
| 126 |
+
exp10 | exp10f | exp2 | exp2f => (true, Some(musl_math_sys::MACRO_FN_NAME)),
|
| 127 |
+
|
| 128 |
+
// Musl does not provide `f16` and `f128` functions, as well as a handful of others
|
| 129 |
+
fmaximum
|
| 130 |
+
| fmaximum_num
|
| 131 |
+
| fmaximum_numf
|
| 132 |
+
| fmaximumf
|
| 133 |
+
| fminimum
|
| 134 |
+
| fminimum_num
|
| 135 |
+
| fminimum_numf
|
| 136 |
+
| fminimumf
|
| 137 |
+
| roundeven
|
| 138 |
+
| roundevenf
|
| 139 |
+
| ALL_F16
|
| 140 |
+
| ALL_F128 => (false, None),
|
| 141 |
+
|
| 142 |
+
// By default we never skip (false) and always have a musl function available
|
| 143 |
+
_ => (false, Some(musl_math_sys::MACRO_FN_NAME))
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
macro_rules! run_callback {
|
| 148 |
+
(
|
| 149 |
+
fn_name: $fn_name:ident,
|
| 150 |
+
attrs: [$($attr:meta),*],
|
| 151 |
+
extra: [$criterion:ident],
|
| 152 |
+
) => {
|
| 153 |
+
paste::paste! {
|
| 154 |
+
$(#[$attr])*
|
| 155 |
+
[< musl_bench_ $fn_name >](&mut $criterion)
|
| 156 |
+
}
|
| 157 |
+
};
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
pub fn musl_random() {
|
| 161 |
+
let mut criterion = Criterion::default();
|
| 162 |
+
|
| 163 |
+
// For CI, run a short 0.5s warmup and 1.0s tests. This makes benchmarks complete in
|
| 164 |
+
// about the same time as other tests.
|
| 165 |
+
if cfg!(feature = "short-benchmarks") {
|
| 166 |
+
criterion = criterion
|
| 167 |
+
.warm_up_time(Duration::from_millis(200))
|
| 168 |
+
.measurement_time(Duration::from_millis(600));
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
criterion = criterion.configure_from_args();
|
| 172 |
+
|
| 173 |
+
libm_macros::for_each_function! {
|
| 174 |
+
callback: run_callback,
|
| 175 |
+
extra: [criterion],
|
| 176 |
+
};
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
criterion_main!(musl_random);
|