Skip to content

[0.2] Backports #4476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4e7a641
gnu: build settings for _TIME_BITS=64
snogge Mar 25, 2025
52035e1
gnu: Set up the CI for _TIME_BITS=64
snogge Mar 25, 2025
e9f0ad2
gnu: Handle basic time types for 32bit with _TIME_BITS=64
snogge Mar 25, 2025
8f3da76
gnu: Use _TIME_BITS=64 versions of glibc symbols
snogge Nov 21, 2024
e2f0562
gnu: Update struct shmid_ds for 64-bit time
snogge Mar 20, 2023
85f205b
gnu: Update struct msqid_ds for 64-bit time
snogge Mar 27, 2023
70dcf6d
gnu: Update struct semid_ds for 64-bit time
snogge Mar 20, 2023
dfcfcf8
gnu: Update struct timespec for GNU _TIME_BITS=64
snogge Mar 27, 2023
516e529
gnu: Move struct timex from gnu to gnu/b32 and gnu/b64
snogge Mar 25, 2025
37f0073
gnu: Adapt struct timex for gnu_time_bits64
snogge Mar 25, 2025
21e5e3d
gnu: Handle timeval.tv_usec for glibc 64-bit time_t
snogge Mar 17, 2023
36b2e48
gnu: Adapt struct stat for gnu_time_bits64
snogge Mar 25, 2025
f4619be
gnu: Adapt struct stat64 for gnu_time_bits64
snogge Mar 25, 2025
44b29ed
openbsd: ignore some constants in CI (removed in upcoming OpenBSD 7.8)
semarie May 25, 2025
c04c92e
Replace handwritten `Debug` impls with derives
tgross35 Jun 2, 2025
9810e4b
hurd: Fix build from missing `fpos_t`
tgross35 Jun 2, 2025
2a04153
ci: Disable the i686 Android job
tgross35 Jun 2, 2025
a8e40d7
build(deps): bump vmactions/solaris-vm from 1.1.3 to 1.1.4
dependabot[bot] Jun 2, 2025
600d8ad
Add ctest-next stub and expected dependencies
mbyx Jun 1, 2025
6595c61
Add AIX triple to Cargo.toml for doc.
Jun 3, 2025
53301c2
lints: Warn rather than deny by default
tgross35 Jun 2, 2025
7be1a7a
lints: Remove `allow(redundant_semicolons)`
tgross35 Jun 2, 2025
1a418ed
lints: Remove `allow(dead_code)`
tgross35 Jun 2, 2025
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
19 changes: 17 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ jobs:
artifact-tag: offset-bits64
env:
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
- target: i686-unknown-linux-gnu
docker: true
os: ubuntu-24.04
artifact-tag: time-bits64
env:
RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
- target: x86_64-unknown-linux-gnu
docker: true
os: ubuntu-24.04
Expand Down Expand Up @@ -172,7 +178,8 @@ jobs:
- aarch64-unknown-linux-musl
- arm-linux-androideabi
- arm-unknown-linux-musleabihf
- i686-linux-android
# FIXME(#4297): Disabled due to spurious failueSome android jobs are disabled because of high rates of
# - i686-linux-android
- i686-unknown-linux-musl
- loongarch64-unknown-linux-gnu
- loongarch64-unknown-linux-musl
Expand All @@ -196,6 +203,10 @@ jobs:
env:
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
artifact-tag: offset-bits64
- target: arm-unknown-linux-gnueabihf
env:
RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
artifact-tag: time-bits64
- target: aarch64-unknown-linux-musl
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
Expand All @@ -215,6 +226,10 @@ jobs:
# env:
# RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
# artifact-tag: offset-bits64
# - target: powerpc-unknown-linux-gnu
# env:
# RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
# artifact-tag: time-bits64
timeout-minutes: 25
env:
TARGET: ${{ matrix.target }}
Expand Down Expand Up @@ -260,7 +275,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: test on Solaris
uses: vmactions/solaris-vm@v1.1.3
uses: vmactions/solaris-vm@v1.1.4
with:
release: "11.4-gcc"
usesh: true
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ targets = [
"powerpc-unknown-netbsd",
"powerpc-wrs-vxworks",
"powerpc-wrs-vxworks-spe",
"powerpc64-ibm-aix",
"powerpc64-unknown-freebsd",
"powerpc64-unknown-linux-gnu",
"powerpc64-wrs-vxworks",
Expand Down Expand Up @@ -148,6 +149,7 @@ use_std = ['std']
[workspace]
members = [
"ctest",
"ctest-next",
"libc-test",
]

Expand Down
40 changes: 27 additions & 13 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const ALLOWED_CFGS: &[&str] = &[
"freebsd15",
// Corresponds to `_FILE_OFFSET_BITS=64` in glibc
"gnu_file_offset_bits64",
// Corresponds to `_TIME_BITS=64` in glibc
"gnu_time_bits64",
// FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn`
"libc_const_extern_fn",
"libc_deny_warnings",
Expand Down Expand Up @@ -103,23 +105,35 @@ fn main() {
set_cfg("linux_time_bits64");
}
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS");
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
Ok(val) if val == "64" => {
if target_env == "gnu"
&& target_os == "linux"
&& target_ptr_width == "32"
&& target_arch != "riscv32"
&& target_arch != "x86_64"
{
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_TIME_BITS");
if target_env == "gnu"
&& target_os == "linux"
&& target_ptr_width == "32"
&& target_arch != "riscv32"
&& target_arch != "x86_64"
{
match env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") {
Ok(val) if val == "64" => {
set_cfg("gnu_file_offset_bits64");
set_cfg("linux_time_bits64");
set_cfg("gnu_time_bits64");
}
Ok(val) if val != "32" => {
panic!("RUST_LIBC_UNSTABLE_GNU_TIME_BITS may only be set to '32' or '64'")
}
_ => {
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
Ok(val) if val == "64" => {
set_cfg("gnu_file_offset_bits64");
}
Ok(val) if val != "32" => {
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
}
_ => {}
}
}
}
Ok(val) if val != "32" => {
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
}
_ => {}
}

// On CI: deny all warnings
if libc_ci {
set_cfg("libc_deny_warnings");
Expand Down
1 change: 1 addition & 0 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ run() {
--env LIBC_CI \
--env LIBC_CI_ZBUILD_STD \
--env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \
--env RUST_LIBC_UNSTABLE_GNU_TIME_BITS \
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--volume "$CARGO_HOME":/cargo \
Expand Down
7 changes: 5 additions & 2 deletions ci/verify-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ test_target() {
# Test with the equivalent of __USE_TIME_BITS64
RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd
case "$target" in
# Test with the equivalent of __FILE_OFFSET_BITS=64
arm*-gnu*|i*86*-gnu|powerpc-*-gnu*|mips*-gnu|sparc-*-gnu|thumb-*gnu*)
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd;;
# Test with the equivalent of _FILE_OFFSET_BITS=64
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd
# Test with the equivalent of _TIME_BITS=64
RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd
;;
esac
fi

Expand Down
8 changes: 8 additions & 0 deletions ctest-next/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "ctest-next"
version = "0.1.0"
edition = "2021"
rust-version = "1.77"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/libc"
publish = false
14 changes: 14 additions & 0 deletions ctest-next/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
57 changes: 37 additions & 20 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,12 @@ fn test_openbsd(target: &str) {
"KERN_MAXID" | "NET_RT_MAXID" => true,
"EV_SYSFLAGS" => true,

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

// Removed in OpenBSD 7.8
"CTL_FS" | "SO_NETPROC" => true,

_ => false,
}
});
Expand Down Expand Up @@ -3689,22 +3692,37 @@ fn test_vxworks(target: &str) {
}

fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) {
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
Ok(val) if val == "64" => {
if target.contains("gnu")
&& target.contains("linux")
&& !target.ends_with("x32")
&& !target.contains("riscv32")
&& env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
{
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default();
if target.contains("gnu")
&& target.contains("linux")
&& !target.ends_with("x32")
&& !target.contains("riscv32")
&& pointer_width == "32"
{
match env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") {
Ok(val) if val == "64" => {
cfg.define("_FILE_OFFSET_BITS", Some("64"));
cfg.define("_TIME_BITS", Some("64"));
cfg.cfg("gnu_file_offset_bits64", None);
cfg.cfg("linux_time_bits64", None);
cfg.cfg("gnu_time_bits64", None);
}
Ok(val) if val != "32" => {
panic!("RUST_LIBC_UNSTABLE_GNU_TIME_BITS may only be set to '32' or '64'")
}
_ => {
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
Ok(val) if val == "64" => {
cfg.define("_FILE_OFFSET_BITS", Some("64"));
cfg.cfg("gnu_file_offset_bits64", None);
}
Ok(val) if val != "32" => {
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
}
_ => {}
}
}
}
Ok(val) if val != "32" => {
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
}
_ => {}
}
}

Expand Down Expand Up @@ -5607,9 +5625,9 @@ fn test_aix(target: &str) {
});

cfg.type_name(move |ty, is_struct, is_union| match ty {
"DIR" => ty.to_string(),
"FILE" => ty.to_string(),
"ACTION" => ty.to_string(),
"DIR" => ty.to_string(),
"FILE" => ty.to_string(),
"ACTION" => ty.to_string(),

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

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


cfg.volatile_item(|i| {
use ctest::VolatileItemKind::*;
match i {
Expand Down
2 changes: 1 addition & 1 deletion libc-test/test/cmsg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod t {
for cmsg_len in 0..64 {
// Address must be a multiple of 0x4 for testing on AIX.
if cfg!(target_os = "aix") && cmsg_len % std::mem::size_of::<cmsghdr>() != 0 {
continue;
continue;
}
for next_cmsg_len in 0..32 {
unsafe {
Expand Down
Loading
Loading