summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Albini <pietro.albini@ferrous-systems.com>2023-02-24 11:05:44 +0100
committerPietro Albini <pietro.albini@ferrous-systems.com>2023-03-06 09:39:30 +0100
commitb636da0a67185598bbe739ed2c20910e51514e4d (patch)
tree393a65873b417ceb86b8fd99dd2225d325a1379c
parentf8a12ee0a4e96f830cdc765343aa60cbe27c5a4a (diff)
downloadrust-libc-b636da0a67185598bbe739ed2c20910e51514e4d.tar.gz
emit rustc-check-cfg in the build script when LIBC_CHECK_CFG=1
-rw-r--r--build.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/build.rs b/build.rs
index ab299b70ba..cb70d6e238 100644
--- a/build.rs
+++ b/build.rs
@@ -38,6 +38,7 @@ fn main() {
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
let libc_ci = env::var("LIBC_CI").is_ok();
+ let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok();
if env::var("CARGO_FEATURE_USE_STD").is_ok() {
println!(
@@ -140,6 +141,17 @@ fn main() {
set_cfg("libc_const_extern_fn");
}
}
+
+ // check-cfg is a nightly cargo/rustc feature to warn when unknown cfgs are used across the
+ // codebase. libc can configure it if the appropriate environment variable is passed. Since
+ // rust-lang/rust enforces it, this is useful when using a custom libc fork there.
+ //
+ // https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg
+ if libc_check_cfg {
+ for cfg in ALLOWED_CFGS {
+ println!("cargo:rustc-check-cfg=values({})", cfg);
+ }
+ }
}
fn rustc_minor_nightly() -> (u32, bool) {