Skip to content

Commit 58b2706

Browse files
committed
Auto merge of #1518 - gnzlbg:freebsd10support, r=gnzlbg
Add FreeBSD10 support This adds libc-test support for Freebsd10 and a CI build job that tests FreeBSD10 with LIBC_CI only. cc @asomers this is a follow up to #1491 .
2 parents 77aa3e5 + 3843c7d commit 58b2706

File tree

7 files changed

+105
-17
lines changed

7 files changed

+105
-17
lines changed

.cirrus.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
task:
2+
name: nightly x86_64-unknown-freebsd-10
3+
freebsd_instance:
4+
image: freebsd-10-4-release-amd64
5+
setup_script:
6+
- pkg install -y curl
7+
- curl https://sh.rustup.rs -sSf --output rustup.sh
8+
- sh rustup.sh --default-toolchain nightly -y
9+
- . $HOME/.cargo/env
10+
- rustup default nightly
11+
test_script:
12+
- . $HOME/.cargo/env
13+
- LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd
14+
115
task:
216
name: stable x86_64-unknown-freebsd-11
317
freebsd_instance:

build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ fn main() {
1616
);
1717
}
1818

19-
// The ABI of libc is backward compatible with FreeBSD 11.
19+
// The ABI of libc used by libstd is backward compatible with FreeBSD 10.
20+
// The ABI of libc from crates.io is backward compatible with FreeBSD 11.
2021
//
2122
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
2223
// running tests to ensure that the ABI is correct.
2324
match which_freebsd() {
25+
Some(10) if libc_ci || rustc_dep_of_std => {
26+
println!("cargo:rustc-cfg=freebsd10")
27+
}
2428
Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"),
2529
Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"),
2630
Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"),
@@ -109,6 +113,7 @@ fn which_freebsd() -> Option<i32> {
109113
let stdout = stdout.unwrap();
110114

111115
match &stdout {
116+
s if s.starts_with("10") => Some(10),
112117
s if s.starts_with("11") => Some(11),
113118
s if s.starts_with("12") => Some(12),
114119
s if s.starts_with("13") => Some(13),

libc-test/build.rs

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ fn test_freebsd(target: &str) {
14571457
let freebsd_ver = which_freebsd();
14581458

14591459
match freebsd_ver {
1460+
Some(10) => cfg.cfg("freebsd10", None),
14601461
Some(11) => cfg.cfg("freebsd11", None),
14611462
Some(12) => cfg.cfg("freebsd12", None),
14621463
Some(13) => cfg.cfg("freebsd13", None),
@@ -1466,7 +1467,10 @@ fn test_freebsd(target: &str) {
14661467
// Required for `getline`:
14671468
cfg.define("_WITH_GETLINE", None);
14681469
// Required for making freebsd11_stat available in the headers
1469-
cfg.define("_WANT_FREEBSD11_STAT", None);
1470+
match freebsd_ver {
1471+
Some(10) => &mut cfg,
1472+
_ => cfg.define("_WANT_FREEBSD11_STAT", None),
1473+
};
14701474

14711475
headers! { cfg:
14721476
"aio.h",
@@ -1594,6 +1598,34 @@ fn test_freebsd(target: &str) {
15941598
true
15951599
}
15961600

1601+
// These constants were introduced in FreeBSD 11:
1602+
"SF_USER_READAHEAD"
1603+
| "SF_NOCACHE"
1604+
| "RLIMIT_KQUEUES"
1605+
| "RLIMIT_UMTXP"
1606+
| "EVFILT_PROCDESC"
1607+
| "EVFILT_SENDFILE"
1608+
| "EVFILT_EMPTY"
1609+
| "SO_REUSEPORT_LB"
1610+
| "TCP_CCALGOOPT"
1611+
| "TCP_PCAP_OUT"
1612+
| "TCP_PCAP_IN"
1613+
| "IP_BINDMULTI"
1614+
| "IP_ORIGDSTADDR"
1615+
| "IP_RECVORIGDSTADDR"
1616+
| "IPV6_ORIGDSTADDR"
1617+
| "IPV6_RECVORIGDSTADDR"
1618+
| "PD_CLOEXEC"
1619+
| "PD_ALLOWED_AT_FORK"
1620+
| "IP_RSS_LISTEN_BUCKET"
1621+
if Some(10) == freebsd_ver =>
1622+
{
1623+
true
1624+
}
1625+
1626+
// FIXME: This constant has a different value in FreeBSD 10:
1627+
"RLIM_NLIMITS" if Some(10) == freebsd_ver => true,
1628+
15971629
// FIXME: There are deprecated - remove in a couple of releases.
15981630
// These constants were removed in FreeBSD 11 (svn r273250) but will
15991631
// still be accepted and ignored at runtime.
@@ -1609,12 +1641,32 @@ fn test_freebsd(target: &str) {
16091641
}
16101642
});
16111643

1644+
cfg.skip_struct(move |ty| {
1645+
match ty {
1646+
// `mmsghdr` is not available in FreeBSD 10
1647+
"mmsghdr" if Some(10) == freebsd_ver => true,
1648+
1649+
_ => false,
1650+
}
1651+
});
1652+
16121653
cfg.skip_fn(move |name| {
16131654
// skip those that are manually verified
16141655
match name {
16151656
// FIXME: https://github.com/rust-lang/libc/issues/1272
16161657
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
16171658

1659+
// These functions were added in FreeBSD 11:
1660+
"fdatasync" | "mq_getfd_np" | "sendmmsg" | "recvmmsg"
1661+
if Some(10) == freebsd_ver =>
1662+
{
1663+
true
1664+
}
1665+
1666+
// This function changed its return type from `int` in FreeBSD10 to
1667+
// `ssize_t` in FreeBSD11:
1668+
"aio_waitcomplete" if Some(10) == freebsd_ver => true,
1669+
16181670
// The `uname` function in the `utsname.h` FreeBSD header is a C
16191671
// inline function (has no symbol) that calls the `__xuname` symbol.
16201672
// Therefore the function pointer comparison does not make sense for it.
@@ -1630,6 +1682,14 @@ fn test_freebsd(target: &str) {
16301682
}
16311683
});
16321684

1685+
cfg.skip_signededness(move |c| {
1686+
match c {
1687+
// FIXME: has a different sign in FreeBSD10
1688+
"blksize_t" if Some(10) == freebsd_ver => true,
1689+
_ => false,
1690+
}
1691+
});
1692+
16331693
cfg.volatile_item(|i| {
16341694
use ctest::VolatileItemKind::*;
16351695
match i {
@@ -1643,9 +1703,17 @@ fn test_freebsd(target: &str) {
16431703
});
16441704

16451705
cfg.skip_field(move |struct_, field| {
1646-
// FIXME: `sa_sigaction` has type `sighandler_t` but that type is
1647-
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
1648-
(struct_ == "sigaction" && field == "sa_sigaction")
1706+
match (struct_, field) {
1707+
// FIXME: `sa_sigaction` has type `sighandler_t` but that type is
1708+
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
1709+
("sigaction", "sa_sigaction") => true,
1710+
1711+
// FIXME: in FreeBSD10 this field has type `char*` instead of
1712+
// `void*`:
1713+
("stack_t", "ss_sp") if Some(10) == freebsd_ver => true,
1714+
1715+
_ => false,
1716+
}
16491717
});
16501718

16511719
cfg.generate("../src/lib.rs", "main.rs");
@@ -2457,6 +2525,7 @@ fn which_freebsd() -> Option<i32> {
24572525
let stdout = String::from_utf8(output.stdout).ok()?;
24582526

24592527
match &stdout {
2528+
s if s.starts_with("10") => Some(10),
24602529
s if s.starts_with("11") => Some(11),
24612530
s if s.starts_with("12") => Some(12),
24622531
s if s.starts_with("13") => Some(13),

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ cfg_if! {
14561456
} else if #[cfg(freebsd13)] {
14571457
mod freebsd12;
14581458
pub use self::freebsd12::*;
1459-
} else if #[cfg(freebsd11)] {
1459+
} else if #[cfg(any(freebsd10, freebsd11))] {
14601460
mod freebsd11;
14611461
pub use self::freebsd11::*;
14621462
} else {

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ extern "C" {
11931193
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
11941194
pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int;
11951195
#[cfg_attr(
1196-
all(target_os = "freebsd", freebsd11),
1196+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
11971197
link_name = "kevent@FBSD_1.0"
11981198
)]
11991199
pub fn kevent(
@@ -1223,7 +1223,7 @@ extern "C" {
12231223
mode: ::mode_t,
12241224
) -> ::c_int;
12251225
#[cfg_attr(
1226-
all(target_os = "freebsd", freebsd11),
1226+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
12271227
link_name = "mknodat@FBSD_1.1"
12281228
)]
12291229
pub fn mknodat(

src/unix/bsd/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ extern "C" {
558558
#[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
559559
#[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
560560
#[cfg_attr(
561-
all(target_os = "freebsd", freebsd11),
561+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
562562
link_name = "glob@FBSD_1.0"
563563
)]
564564
pub fn glob(
@@ -571,7 +571,7 @@ extern "C" {
571571
) -> ::c_int;
572572
#[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
573573
#[cfg_attr(
574-
all(target_os = "freebsd", freebsd11),
574+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
575575
link_name = "globfree@FBSD_1.0"
576576
)]
577577
pub fn globfree(pglob: *mut ::glob_t);

src/unix/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ extern "C" {
669669
#[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
670670
#[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
671671
#[cfg_attr(
672-
all(target_os = "freebsd", freebsd11),
672+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
673673
link_name = "fstat@FBSD_1.0"
674674
)]
675675
pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
@@ -679,7 +679,7 @@ extern "C" {
679679
#[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
680680
#[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
681681
#[cfg_attr(
682-
all(target_os = "freebsd", freebsd11),
682+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
683683
link_name = "stat@FBSD_1.0"
684684
)]
685685
pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
@@ -722,7 +722,7 @@ extern "C" {
722722
#[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")]
723723
#[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
724724
#[cfg_attr(
725-
all(target_os = "freebsd", freebsd11),
725+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
726726
link_name = "readdir@FBSD_1.0"
727727
)]
728728
pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
@@ -757,7 +757,7 @@ extern "C" {
757757
) -> ::c_int;
758758
#[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")]
759759
#[cfg_attr(
760-
all(target_os = "freebsd", freebsd11),
760+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
761761
link_name = "fstatat@FBSD_1.1"
762762
)]
763763
pub fn fstatat(
@@ -989,7 +989,7 @@ extern "C" {
989989
#[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
990990
#[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
991991
#[cfg_attr(
992-
all(target_os = "freebsd", freebsd11),
992+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
993993
link_name = "lstat@FBSD_1.0"
994994
)]
995995
pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
@@ -1242,7 +1242,7 @@ extern "C" {
12421242

12431243
#[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
12441244
#[cfg_attr(
1245-
all(target_os = "freebsd", freebsd11),
1245+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
12461246
link_name = "mknod@FBSD_1.0"
12471247
)]
12481248
pub fn mknod(
@@ -1458,7 +1458,7 @@ cfg_if! {
14581458
#[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
14591459
#[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
14601460
#[cfg_attr(
1461-
all(target_os = "freebsd", freebsd11),
1461+
all(target_os = "freebsd", any(freebsd11, freebsd10)),
14621462
link_name = "readdir_r@FBSD_1.0"
14631463
)]
14641464
/// The 64-bit libc on Solaris and illumos only has readdir_r. If a

0 commit comments

Comments
 (0)