Add f16 and f128 configuration from compiler-builtins

In preparation of adding routines from these two types, duplicate the
`compiler-builtins` configuration here.
This commit is contained in:
Trevor Gross
2024-10-26 00:44:50 -05:00
committed by Trevor Gross
parent b9871da445
commit f2e16b6ac1
9 changed files with 208 additions and 83 deletions

View File

@@ -5,7 +5,10 @@ edition = "2021"
publish = false
[features]
default = []
default = ["unstable-float"]
# Propagated from libm because this affects which functions we test.
unstable-float = ["libm/unstable-float"]
# Generate tests which are random inputs and the outputs are calculated with
# musl libc.
@@ -44,3 +47,9 @@ criterion = { version = "0.5.1", default-features = false, features = ["cargo_be
[[bench]]
name = "random"
harness = false
[lints.rust]
# Values from the chared config.rs used by `libm` but not the test crate
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(feature, values("arch", "force-soft-floats", "unstable-intrinsics"))',
] }

View File

@@ -1,66 +1,16 @@
use std::fmt::Write;
use std::path::PathBuf;
use std::{env, fs};
use std::fs;
#[path = "../../configure.rs"]
mod configure;
use configure::Config;
fn main() {
let cfg = Config::from_env();
emit_optimization_cfg(&cfg);
emit_cfg_shorthands(&cfg);
list_all_tests(&cfg);
}
#[allow(dead_code)]
struct Config {
manifest_dir: PathBuf,
out_dir: PathBuf,
opt_level: u8,
target_arch: String,
target_env: String,
target_family: Option<String>,
target_os: String,
target_string: String,
target_vendor: String,
target_features: Vec<String>,
}
impl Config {
fn from_env() -> Self {
let target_features = env::var("CARGO_CFG_TARGET_FEATURE")
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
.unwrap_or_default();
Self {
manifest_dir: PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()),
out_dir: PathBuf::from(env::var("OUT_DIR").unwrap()),
opt_level: env::var("OPT_LEVEL").unwrap().parse().unwrap(),
target_arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
target_env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),
target_family: env::var("CARGO_CFG_TARGET_FAMILY").ok(),
target_os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
target_string: env::var("TARGET").unwrap(),
target_vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),
target_features,
}
}
}
/// Some tests are extremely slow. Emit a config option based on optimization level.
fn emit_optimization_cfg(cfg: &Config) {
println!("cargo::rustc-check-cfg=cfg(optimizations_enabled)");
if cfg.opt_level >= 2 {
println!("cargo::rustc-cfg=optimizations_enabled");
}
}
/// Provide an alias for common longer config combinations.
fn emit_cfg_shorthands(cfg: &Config) {
println!("cargo::rustc-check-cfg=cfg(x86_no_sse)");
if cfg.target_arch == "x86" && !cfg.target_features.iter().any(|f| f == "sse") {
// Shorthand to detect i586 targets
println!("cargo::rustc-cfg=x86_no_sse");
}
configure::emit_test_config(&cfg);
}
/// Create a list of all source files in an array. This can be used for making sure that