Skip to content

Commit 92347ec

Browse files
authored
Merge pull request #4476 from tgross35/backport-scotch-bonnet
[0.2] Backports
2 parents c56fd04 + 1a418ed commit 92347ec

File tree

81 files changed

+614
-3560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+614
-3560
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ jobs:
9999
artifact-tag: offset-bits64
100100
env:
101101
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
102+
- target: i686-unknown-linux-gnu
103+
docker: true
104+
os: ubuntu-24.04
105+
artifact-tag: time-bits64
106+
env:
107+
RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
102108
- target: x86_64-unknown-linux-gnu
103109
docker: true
104110
os: ubuntu-24.04
@@ -172,7 +178,8 @@ jobs:
172178
- aarch64-unknown-linux-musl
173179
- arm-linux-androideabi
174180
- arm-unknown-linux-musleabihf
175-
- i686-linux-android
181+
# FIXME(#4297): Disabled due to spurious failueSome android jobs are disabled because of high rates of
182+
# - i686-linux-android
176183
- i686-unknown-linux-musl
177184
- loongarch64-unknown-linux-gnu
178185
- loongarch64-unknown-linux-musl
@@ -196,6 +203,10 @@ jobs:
196203
env:
197204
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
198205
artifact-tag: offset-bits64
206+
- target: arm-unknown-linux-gnueabihf
207+
env:
208+
RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
209+
artifact-tag: time-bits64
199210
- target: aarch64-unknown-linux-musl
200211
env:
201212
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
@@ -215,6 +226,10 @@ jobs:
215226
# env:
216227
# RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
217228
# artifact-tag: offset-bits64
229+
# - target: powerpc-unknown-linux-gnu
230+
# env:
231+
# RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
232+
# artifact-tag: time-bits64
218233
timeout-minutes: 25
219234
env:
220235
TARGET: ${{ matrix.target }}
@@ -260,7 +275,7 @@ jobs:
260275
steps:
261276
- uses: actions/checkout@v4
262277
- name: test on Solaris
263-
uses: vmactions/solaris-vm@v1.1.3
278+
uses: vmactions/solaris-vm@v1.1.4
264279
with:
265280
release: "11.4-gcc"
266281
usesh: true

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ targets = [
7373
"powerpc-unknown-netbsd",
7474
"powerpc-wrs-vxworks",
7575
"powerpc-wrs-vxworks-spe",
76+
"powerpc64-ibm-aix",
7677
"powerpc64-unknown-freebsd",
7778
"powerpc64-unknown-linux-gnu",
7879
"powerpc64-wrs-vxworks",
@@ -148,6 +149,7 @@ use_std = ['std']
148149
[workspace]
149150
members = [
150151
"ctest",
152+
"ctest-next",
151153
"libc-test",
152154
]
153155

build.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const ALLOWED_CFGS: &[&str] = &[
1515
"freebsd15",
1616
// Corresponds to `_FILE_OFFSET_BITS=64` in glibc
1717
"gnu_file_offset_bits64",
18+
// Corresponds to `_TIME_BITS=64` in glibc
19+
"gnu_time_bits64",
1820
// FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn`
1921
"libc_const_extern_fn",
2022
"libc_deny_warnings",
@@ -103,23 +105,35 @@ fn main() {
103105
set_cfg("linux_time_bits64");
104106
}
105107
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS");
106-
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
107-
Ok(val) if val == "64" => {
108-
if target_env == "gnu"
109-
&& target_os == "linux"
110-
&& target_ptr_width == "32"
111-
&& target_arch != "riscv32"
112-
&& target_arch != "x86_64"
113-
{
108+
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_TIME_BITS");
109+
if target_env == "gnu"
110+
&& target_os == "linux"
111+
&& target_ptr_width == "32"
112+
&& target_arch != "riscv32"
113+
&& target_arch != "x86_64"
114+
{
115+
match env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") {
116+
Ok(val) if val == "64" => {
114117
set_cfg("gnu_file_offset_bits64");
118+
set_cfg("linux_time_bits64");
119+
set_cfg("gnu_time_bits64");
120+
}
121+
Ok(val) if val != "32" => {
122+
panic!("RUST_LIBC_UNSTABLE_GNU_TIME_BITS may only be set to '32' or '64'")
123+
}
124+
_ => {
125+
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
126+
Ok(val) if val == "64" => {
127+
set_cfg("gnu_file_offset_bits64");
128+
}
129+
Ok(val) if val != "32" => {
130+
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
131+
}
132+
_ => {}
133+
}
115134
}
116135
}
117-
Ok(val) if val != "32" => {
118-
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
119-
}
120-
_ => {}
121136
}
122-
123137
// On CI: deny all warnings
124138
if libc_ci {
125139
set_cfg("libc_deny_warnings");

ci/run-docker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ run() {
4444
--env LIBC_CI \
4545
--env LIBC_CI_ZBUILD_STD \
4646
--env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \
47+
--env RUST_LIBC_UNSTABLE_GNU_TIME_BITS \
4748
--env CARGO_HOME=/cargo \
4849
--env CARGO_TARGET_DIR=/checkout/target \
4950
--volume "$CARGO_HOME":/cargo \

ci/verify-build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ test_target() {
7676
# Test with the equivalent of __USE_TIME_BITS64
7777
RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd
7878
case "$target" in
79-
# Test with the equivalent of __FILE_OFFSET_BITS=64
8079
arm*-gnu*|i*86*-gnu|powerpc-*-gnu*|mips*-gnu|sparc-*-gnu|thumb-*gnu*)
81-
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd;;
80+
# Test with the equivalent of _FILE_OFFSET_BITS=64
81+
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd
82+
# Test with the equivalent of _TIME_BITS=64
83+
RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd
84+
;;
8285
esac
8386
fi
8487

ctest-next/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "ctest-next"
3+
version = "0.1.0"
4+
edition = "2021"
5+
rust-version = "1.77"
6+
license = "MIT OR Apache-2.0"
7+
repository = "https://github.com/rust-lang/libc"
8+
publish = false

ctest-next/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: usize, right: usize) -> usize {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

libc-test/build.rs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,12 @@ fn test_openbsd(target: &str) {
622622
"KERN_MAXID" | "NET_RT_MAXID" => true,
623623
"EV_SYSFLAGS" => true,
624624

625-
// Removed in OpenBSD 7.7 (unused since 1991)
625+
// Removed in OpenBSD 7.7
626626
"ATF_COM" | "ATF_PERM" | "ATF_PUBL" | "ATF_USETRAILERS" => true,
627627

628+
// Removed in OpenBSD 7.8
629+
"CTL_FS" | "SO_NETPROC" => true,
630+
628631
_ => false,
629632
}
630633
});
@@ -3689,22 +3692,37 @@ fn test_vxworks(target: &str) {
36893692
}
36903693

36913694
fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) {
3692-
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
3693-
Ok(val) if val == "64" => {
3694-
if target.contains("gnu")
3695-
&& target.contains("linux")
3696-
&& !target.ends_with("x32")
3697-
&& !target.contains("riscv32")
3698-
&& env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
3699-
{
3695+
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default();
3696+
if target.contains("gnu")
3697+
&& target.contains("linux")
3698+
&& !target.ends_with("x32")
3699+
&& !target.contains("riscv32")
3700+
&& pointer_width == "32"
3701+
{
3702+
match env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") {
3703+
Ok(val) if val == "64" => {
37003704
cfg.define("_FILE_OFFSET_BITS", Some("64"));
3705+
cfg.define("_TIME_BITS", Some("64"));
37013706
cfg.cfg("gnu_file_offset_bits64", None);
3707+
cfg.cfg("linux_time_bits64", None);
3708+
cfg.cfg("gnu_time_bits64", None);
3709+
}
3710+
Ok(val) if val != "32" => {
3711+
panic!("RUST_LIBC_UNSTABLE_GNU_TIME_BITS may only be set to '32' or '64'")
3712+
}
3713+
_ => {
3714+
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
3715+
Ok(val) if val == "64" => {
3716+
cfg.define("_FILE_OFFSET_BITS", Some("64"));
3717+
cfg.cfg("gnu_file_offset_bits64", None);
3718+
}
3719+
Ok(val) if val != "32" => {
3720+
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
3721+
}
3722+
_ => {}
3723+
}
37023724
}
37033725
}
3704-
Ok(val) if val != "32" => {
3705-
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
3706-
}
3707-
_ => {}
37083726
}
37093727
}
37103728

@@ -5607,9 +5625,9 @@ fn test_aix(target: &str) {
56075625
});
56085626

56095627
cfg.type_name(move |ty, is_struct, is_union| match ty {
5610-
"DIR" => ty.to_string(),
5611-
"FILE" => ty.to_string(),
5612-
"ACTION" => ty.to_string(),
5628+
"DIR" => ty.to_string(),
5629+
"FILE" => ty.to_string(),
5630+
"ACTION" => ty.to_string(),
56135631

56145632
// 'sigval' is a struct in Rust, but a union in C.
56155633
"sigval" => format!("union sigval"),
@@ -5696,9 +5714,9 @@ fn test_aix(target: &str) {
56965714
// POSIX-compliant versions in the system libc. As a result,
56975715
// function pointer comparisons between the C and Rust sides
56985716
// would fail.
5699-
"getpwuid_r" | "getpwnam_r" | "getgrgid_r" | "getgrnam_r"
5700-
| "aio_cancel" | "aio_error" | "aio_fsync" | "aio_read"
5701-
| "aio_return" | "aio_suspend" | "aio_write" | "select" => true,
5717+
"getpwuid_r" | "getpwnam_r" | "getgrgid_r" | "getgrnam_r" | "aio_cancel"
5718+
| "aio_error" | "aio_fsync" | "aio_read" | "aio_return" | "aio_suspend"
5719+
| "aio_write" | "select" => true,
57025720

57035721
// 'getdtablesize' is a constant in the AIX header but it is
57045722
// a real function in libc which the Rust side is resolved to.
@@ -5715,7 +5733,6 @@ fn test_aix(target: &str) {
57155733
}
57165734
});
57175735

5718-
57195736
cfg.volatile_item(|i| {
57205737
use ctest::VolatileItemKind::*;
57215738
match i {

libc-test/test/cmsg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mod t {
7070
for cmsg_len in 0..64 {
7171
// Address must be a multiple of 0x4 for testing on AIX.
7272
if cfg!(target_os = "aix") && cmsg_len % std::mem::size_of::<cmsghdr>() != 0 {
73-
continue;
73+
continue;
7474
}
7575
for next_cmsg_len in 0..32 {
7676
unsafe {

0 commit comments

Comments
 (0)