Skip to content

Commit efd300b

Browse files
committed
Enable const extern "C" fn definitions on Rust 1.62.0 and above
This was recently stabilized in rust-lang/rust#95346, and will be included in the 1.62.0 release. This `const-extern-fn` feature can still be used to enable these definitions on older compiler versions.
1 parent a72d300 commit efd300b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

build.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ fn main() {
66
// Avoid unnecessary re-building.
77
println!("cargo:rerun-if-changed=build.rs");
88

9-
let (rustc_minor_ver, is_nightly) = rustc_minor_nightly().expect("Failed to get rustc version");
9+
let (rustc_minor_ver, _is_nightly) =
10+
rustc_minor_nightly().expect("Failed to get rustc version");
1011
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
1112
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
1213
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
@@ -97,10 +98,8 @@ fn main() {
9798
println!("cargo:rustc-cfg=libc_thread_local");
9899
}
99100

100-
if const_extern_fn_cargo_feature {
101-
if !is_nightly || rustc_minor_ver < 40 {
102-
panic!("const-extern-fn requires a nightly compiler >= 1.40")
103-
}
101+
// Rust >= 1.62.0 allows `const extern "C" fn`
102+
if const_extern_fn_cargo_feature || rustc_minor_ver >= 62 || rustc_dep_of_std {
104103
println!("cargo:rustc-cfg=libc_const_extern_fn");
105104
}
106105
}

0 commit comments

Comments
 (0)