Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
task:
name: nightly x86_64-unknown-freebsd-10
freebsd_instance:
image: freebsd-10-4-release-amd64
setup_script:
- pkg install -y curl
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh --default-toolchain nightly -y
- . $HOME/.cargo/env
- rustup default nightly
test_script:
- . $HOME/.cargo/env
- LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd

task:
name: stable x86_64-unknown-freebsd-11
freebsd_instance:
Expand Down
7 changes: 6 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ fn main() {
);
}

// The ABI of libc is backward compatible with FreeBSD 11.
// The ABI of libc used by libstd is backward compatible with FreeBSD 10.
// The ABI of libc from crates.io 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(10) if libc_ci || rustc_dep_of_std => {
println!("cargo:rustc-cfg=freebsd10")
}
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"),
Expand Down Expand Up @@ -109,6 +113,7 @@ fn which_freebsd() -> Option<i32> {
let stdout = stdout.unwrap();

match &stdout {
s if s.starts_with("10") => Some(10),
s if s.starts_with("11") => Some(11),
s if s.starts_with("12") => Some(12),
s if s.starts_with("13") => Some(13),
Expand Down
77 changes: 73 additions & 4 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,7 @@ fn test_freebsd(target: &str) {
let freebsd_ver = which_freebsd();

match freebsd_ver {
Some(10) => cfg.cfg("freebsd10", None),
Some(11) => cfg.cfg("freebsd11", None),
Some(12) => cfg.cfg("freebsd12", None),
Some(13) => cfg.cfg("freebsd13", None),
Expand All @@ -1466,7 +1467,10 @@ fn test_freebsd(target: &str) {
// Required for `getline`:
cfg.define("_WITH_GETLINE", None);
// Required for making freebsd11_stat available in the headers
cfg.define("_WANT_FREEBSD11_STAT", None);
match freebsd_ver {
Some(10) => &mut cfg,
_ => cfg.define("_WANT_FREEBSD11_STAT", None),
};

headers! { cfg:
"aio.h",
Expand Down Expand Up @@ -1594,6 +1598,34 @@ fn test_freebsd(target: &str) {
true
}

// These constants were introduced in FreeBSD 11:
"SF_USER_READAHEAD"
| "SF_NOCACHE"
| "RLIMIT_KQUEUES"
| "RLIMIT_UMTXP"
| "EVFILT_PROCDESC"
| "EVFILT_SENDFILE"
| "EVFILT_EMPTY"
| "SO_REUSEPORT_LB"
| "TCP_CCALGOOPT"
| "TCP_PCAP_OUT"
| "TCP_PCAP_IN"
| "IP_BINDMULTI"
| "IP_ORIGDSTADDR"
| "IP_RECVORIGDSTADDR"
| "IPV6_ORIGDSTADDR"
| "IPV6_RECVORIGDSTADDR"
| "PD_CLOEXEC"
| "PD_ALLOWED_AT_FORK"
| "IP_RSS_LISTEN_BUCKET"
if Some(10) == freebsd_ver =>
{
true
}

// FIXME: This constant has a different value in FreeBSD 10:
"RLIM_NLIMITS" if Some(10) == freebsd_ver => true,

// FIXME: There are deprecated - remove in a couple of releases.
// These constants were removed in FreeBSD 11 (svn r273250) but will
// still be accepted and ignored at runtime.
Expand All @@ -1609,12 +1641,32 @@ fn test_freebsd(target: &str) {
}
});

cfg.skip_struct(move |ty| {
match ty {
// `mmsghdr` is not available in FreeBSD 10
"mmsghdr" if Some(10) == freebsd_ver => true,

_ => false,
}
});

cfg.skip_fn(move |name| {
// skip those that are manually verified
match name {
// FIXME: https://github.com/rust-lang/libc/issues/1272
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,

// These functions were added in FreeBSD 11:
"fdatasync" | "mq_getfd_np" | "sendmmsg" | "recvmmsg"
if Some(10) == freebsd_ver =>
{
true
}

// This function changed its return type from `int` in FreeBSD10 to
// `ssize_t` in FreeBSD11:
"aio_waitcomplete" if Some(10) == freebsd_ver => true,

// The `uname` function in the `utsname.h` FreeBSD header is a C
// inline function (has no symbol) that calls the `__xuname` symbol.
// Therefore the function pointer comparison does not make sense for it.
Expand All @@ -1630,6 +1682,14 @@ fn test_freebsd(target: &str) {
}
});

cfg.skip_signededness(move |c| {
match c {
// FIXME: has a different sign in FreeBSD10
"blksize_t" if Some(10) == freebsd_ver => true,
_ => false,
}
});

cfg.volatile_item(|i| {
use ctest::VolatileItemKind::*;
match i {
Expand All @@ -1643,9 +1703,17 @@ fn test_freebsd(target: &str) {
});

cfg.skip_field(move |struct_, field| {
// FIXME: `sa_sigaction` has type `sighandler_t` but that type is
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
(struct_ == "sigaction" && field == "sa_sigaction")
match (struct_, field) {
// FIXME: `sa_sigaction` has type `sighandler_t` but that type is
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
("sigaction", "sa_sigaction") => true,

// FIXME: in FreeBSD10 this field has type `char*` instead of
// `void*`:
("stack_t", "ss_sp") if Some(10) == freebsd_ver => true,

_ => false,
}
});

cfg.skip_roundtrip(move |s| match s {
Expand Down Expand Up @@ -2473,6 +2541,7 @@ fn which_freebsd() -> Option<i32> {
let stdout = String::from_utf8(output.stdout).ok()?;

match &stdout {
s if s.starts_with("10") => Some(10),
s if s.starts_with("11") => Some(11),
s if s.starts_with("12") => Some(12),
s if s.starts_with("13") => Some(13),
Expand Down
2 changes: 1 addition & 1 deletion src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ cfg_if! {
} else if #[cfg(freebsd13)] {
mod freebsd12;
pub use self::freebsd12::*;
} else if #[cfg(freebsd11)] {
} else if #[cfg(any(freebsd10, freebsd11))] {
mod freebsd11;
pub use self::freebsd11::*;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ extern "C" {
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int;
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "kevent@FBSD_1.0"
)]
pub fn kevent(
Expand Down Expand Up @@ -1223,7 +1223,7 @@ extern "C" {
mode: ::mode_t,
) -> ::c_int;
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "mknodat@FBSD_1.1"
)]
pub fn mknodat(
Expand Down
4 changes: 2 additions & 2 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ extern "C" {
#[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "glob@FBSD_1.0"
)]
pub fn glob(
Expand All @@ -571,7 +571,7 @@ extern "C" {
) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "globfree@FBSD_1.0"
)]
pub fn globfree(pglob: *mut ::glob_t);
Expand Down
14 changes: 7 additions & 7 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ extern "C" {
#[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "fstat@FBSD_1.0"
)]
pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
Expand All @@ -678,7 +678,7 @@ extern "C" {
#[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "stat@FBSD_1.0"
)]
pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
Expand Down Expand Up @@ -721,7 +721,7 @@ extern "C" {
#[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "readdir@FBSD_1.0"
)]
pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
Expand Down Expand Up @@ -756,7 +756,7 @@ extern "C" {
) -> ::c_int;
#[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "fstatat@FBSD_1.1"
)]
pub fn fstatat(
Expand Down Expand Up @@ -988,7 +988,7 @@ extern "C" {
#[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "lstat@FBSD_1.0"
)]
pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
Expand Down Expand Up @@ -1241,7 +1241,7 @@ extern "C" {

#[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "mknod@FBSD_1.0"
)]
pub fn mknod(
Expand Down Expand Up @@ -1457,7 +1457,7 @@ cfg_if! {
#[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
#[cfg_attr(
all(target_os = "freebsd", freebsd11),
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "readdir_r@FBSD_1.0"
)]
/// The 64-bit libc on Solaris and illumos only has readdir_r. If a
Expand Down