From 9a963e80260f8fc26c502e30ffca43661e454ad0 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sat, 5 Aug 2023 16:15:05 +0100 Subject: [PATCH 1/2] std: freebsd build update. since freebsd 11 had been removed, minimum is now 12. --- library/std/build.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/std/build.rs b/library/std/build.rs index 046ac488b1ff1..2521ad8efc06f 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -4,10 +4,8 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); let target = env::var("TARGET").expect("TARGET was not set"); if target.contains("freebsd") { - if env::var("RUST_STD_FREEBSD_12_ABI").is_ok() { - println!("cargo:rustc-cfg=freebsd12"); - } else if env::var("RUST_STD_FREEBSD_13_ABI").is_ok() { - println!("cargo:rustc-cfg=freebsd12"); + println!("cargo:rustc-cfg=freebsd12"); + if env::var("RUST_STD_FREEBSD_13_ABI").is_ok() { println!("cargo:rustc-cfg=freebsd13"); } } else if target.contains("linux") From f4791420abb907471e693ed7de5e7763f412c6cc Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 20 Oct 2023 15:12:02 +0100 Subject: [PATCH 2/2] changes from feedback --- library/std/build.rs | 8 ++------ library/std/src/os/freebsd/fs.rs | 10 ---------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/library/std/build.rs b/library/std/build.rs index 2521ad8efc06f..ad0a82eab8ca1 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -3,15 +3,11 @@ use std::env; fn main() { println!("cargo:rerun-if-changed=build.rs"); let target = env::var("TARGET").expect("TARGET was not set"); - if target.contains("freebsd") { - println!("cargo:rustc-cfg=freebsd12"); - if env::var("RUST_STD_FREEBSD_13_ABI").is_ok() { - println!("cargo:rustc-cfg=freebsd13"); - } - } else if target.contains("linux") + if target.contains("linux") || target.contains("netbsd") || target.contains("dragonfly") || target.contains("openbsd") + || target.contains("freebsd") || target.contains("solaris") || target.contains("illumos") || target.contains("apple-darwin") diff --git a/library/std/src/os/freebsd/fs.rs b/library/std/src/os/freebsd/fs.rs index 8db3a950c40ff..5689a82e00a34 100644 --- a/library/std/src/os/freebsd/fs.rs +++ b/library/std/src/os/freebsd/fs.rs @@ -76,12 +76,7 @@ impl MetadataExt for Metadata { fn as_raw_stat(&self) -> &raw::stat { // The methods below use libc::stat, so they work fine when libc is built with FreeBSD 12 ABI. // This method would just return nonsense. - #[cfg(freebsd12)] panic!("as_raw_stat not supported with FreeBSD 12 ABI"); - #[cfg(not(freebsd12))] - unsafe { - &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) - } } fn st_dev(&self) -> u64 { self.as_inner().as_inner().st_dev as u64 @@ -143,12 +138,7 @@ impl MetadataExt for Metadata { fn st_flags(&self) -> u32 { self.as_inner().as_inner().st_flags as u32 } - #[cfg(freebsd12)] fn st_lspare(&self) -> u32 { panic!("st_lspare not supported with FreeBSD 12 ABI"); } - #[cfg(not(freebsd12))] - fn st_lspare(&self) -> u32 { - self.as_inner().as_inner().st_lspare as u32 - } }