diff options
author | Yuki Okushi <jtitor@2k36.org> | 2022-06-08 17:40:08 +0900 |
---|---|---|
committer | Yuki Okushi <jtitor@2k36.org> | 2022-06-08 17:42:05 +0900 |
commit | 576f77814cff61d0ed7e30f2a7d0f0f696001bd5 (patch) | |
tree | e59d16110d1a88a04ae4955c8bdd25a8b4a98226 /build.rs | |
parent | e534fd88e3b33f45937700b7f50ab02a34fffe2a (diff) | |
download | rust-libc-576f77814cff61d0ed7e30f2a7d0f0f696001bd5.tar.gz |
Enable `libc_const_extern_fn` implicitly from Rust 1.62
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -97,11 +97,18 @@ fn main() { println!("cargo:rustc-cfg=libc_thread_local"); } - if const_extern_fn_cargo_feature { - if !is_nightly || rustc_minor_ver < 40 { - panic!("const-extern-fn requires a nightly compiler >= 1.40") - } + // Rust >= 1.62.0 allows to use `const_extern_fn` for "Rust" and "C". + if rustc_minor_ver >= 62 { println!("cargo:rustc-cfg=libc_const_extern_fn"); + } else { + // Rust < 1.62.0 requires a crate feature and feature gate. + if const_extern_fn_cargo_feature { + if !is_nightly || rustc_minor_ver < 40 { + panic!("const-extern-fn requires a nightly compiler >= 1.40"); + } + println!("cargo:rustc-cfg=libc_const_extern_fn_unstable"); + println!("cargo:rustc-cfg=libc_const_extern_fn"); + } } } |