summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorgnzlbg <gonzalobg88@gmail.com>2019-08-14 07:30:15 +0200
committergnzlbg <gonzalobg88@gmail.com>2019-08-14 07:30:15 +0200
commit4f1966f5c54220d2f83bf917e91f54129651f654 (patch)
treed133c0dd69d697840c60d529043acdaf7e61783c /build.rs
parentd7907c00e1a5061b4701e3d4aefca0ce4a181974 (diff)
downloadrust-libc-4f1966f5c54220d2f83bf917e91f54129651f654.tar.gz
Fix FreeBSD build
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/build.rs b/build.rs
index f355447a67..339eb19556 100644
--- a/build.rs
+++ b/build.rs
@@ -7,6 +7,8 @@ fn main() {
rustc_minor_version().expect("Failed to get rustc version");
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 env::var("CARGO_FEATURE_USE_STD").is_ok() {
println!(
@@ -15,15 +17,20 @@ fn main() {
);
}
- if env::var("LIBC_CI").is_ok() {
- if let Some(11) = which_freebsd() {
- println!("cargo:rustc-cfg=freebsd11");
- }
- if let Some(12) = which_freebsd() {
- println!("cargo:rustc-cfg=freebsd12");
- }
- if let Some(13) = which_freebsd() {
- println!("cargo:rustc-cfg=freebsd13");
+ // 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.
+ #[cfg(target_os = "freebsd")]
+ 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(_) => println!("cargo:rustc-cfg=freebsd11"),
+ None =>
+ /* not FreeBSD - nothing to do here */
+ {
+ ()
}
}
@@ -87,6 +94,7 @@ fn rustc_minor_version() -> Option<u32> {
otry!(pieces.next()).parse().ok()
}
+#[cfg(target_os = "freebsd")]
fn which_freebsd() -> Option<i32> {
let output = std::process::Command::new("freebsd-version").output().ok();
if output.is_none() {