summaryrefslogtreecommitdiff
path: root/libc/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'libc/build.rs')
-rw-r--r--libc/build.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/libc/build.rs b/libc/build.rs
index 8452940..efc95b6 100644
--- a/libc/build.rs
+++ b/libc/build.rs
@@ -5,21 +5,27 @@ use std::str;
fn main() {
let rustc_minor_ver =
rustc_minor_version().expect("Failed to get rustc version");
- let rustc_dep_of_std =
- std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
- let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok();
+ let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
+ let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
+ #[allow(unused)]
+ let libc_ci = env::var("LIBC_CI").is_ok();
- if std::env::var("CARGO_FEATURE_USE_STD").is_ok() {
+ if env::var("CARGO_FEATURE_USE_STD").is_ok() {
println!(
"cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \
please consider using the `std` cargo feature instead\""
);
}
- if std::env::var("LIBC_CI").is_ok() {
- if let Some(12) = which_freebsd() {
- println!("cargo:rustc-cfg=freebsd12");
- }
+ // The ABI of libc is backward compatible with FreeBSD 11.
+ //
+ // On CI, we detect the actual FreeBSD version and match its ABI exactly,
+ // running tests to ensure that the ABI is correct.
+ match which_freebsd() {
+ Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"),
+ Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"),
+ Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"),
+ Some(_) | None => println!("cargo:rustc-cfg=freebsd11"),
}
// Rust >= 1.15 supports private module use:
@@ -53,6 +59,11 @@ fn main() {
if rustc_minor_ver >= 33 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_packedN");
}
+
+ // #[thread_local] is currently unstable
+ if rustc_dep_of_std {
+ println!("cargo:rustc-cfg=libc_thread_local");
+ }
}
fn rustc_minor_version() -> Option<u32> {
@@ -96,6 +107,7 @@ fn which_freebsd() -> Option<i32> {
match &stdout {
s if s.starts_with("11") => Some(11),
s if s.starts_with("12") => Some(12),
+ s if s.starts_with("13") => Some(13),
_ => None,
}
}