Skip to content

Commit

Permalink
emit rustc-check-cfg in the build script when LIBC_CHECK_CFG=1
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Mar 6, 2023
1 parent f8a12ee commit b636da0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b636da0

Please sign in to comment.