Skip to content
Snippets Groups Projects
Commit 4f1966f5 authored by gnzlbg's avatar gnzlbg
Browse files

Fix FreeBSD build

parent d7907c00
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ fn main() { ...@@ -7,6 +7,8 @@ fn main() {
rustc_minor_version().expect("Failed to get rustc version"); 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 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(); 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() { if env::var("CARGO_FEATURE_USE_STD").is_ok() {
println!( println!(
...@@ -15,15 +17,20 @@ fn main() { ...@@ -15,15 +17,20 @@ fn main() {
); );
} }
if env::var("LIBC_CI").is_ok() { // The ABI of libc is backward compatible with FreeBSD 11.
if let Some(11) = which_freebsd() { //
println!("cargo:rustc-cfg=freebsd11"); // On CI, we detect the actual FreeBSD version and match its ABI exactly,
} // running tests to ensure that the ABI is correct.
if let Some(12) = which_freebsd() { #[cfg(target_os = "freebsd")]
println!("cargo:rustc-cfg=freebsd12"); match which_freebsd() {
} Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"),
if let Some(13) = which_freebsd() { Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"),
println!("cargo:rustc-cfg=freebsd13"); 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> { ...@@ -87,6 +94,7 @@ fn rustc_minor_version() -> Option<u32> {
otry!(pieces.next()).parse().ok() otry!(pieces.next()).parse().ok()
} }
#[cfg(target_os = "freebsd")]
fn which_freebsd() -> Option<i32> { fn which_freebsd() -> Option<i32> {
let output = std::process::Command::new("freebsd-version").output().ok(); let output = std::process::Command::new("freebsd-version").output().ok();
if output.is_none() { if output.is_none() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment