Skip to content

Gnu time bits 64 #4433

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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 .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,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 @@ -195,13 +201,21 @@ 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
# FIXME(ppc): SIGILL running tests, see
# https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713
# - target: powerpc-unknown-linux-gnu
# - target: powerpc-unknown-linux-gnu
# 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
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 @@ -91,23 +93,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
4 changes: 3 additions & 1 deletion ci/verify-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ test_target() {
case "$target" in
# Test with the equivalent of __FILE_OFFSET_BITS=64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment could use a small adjustment

arm*-gnu*|i*86*-gnu|powerpc-*-gnu*|mips*-gnu|sparc-*-gnu|thumb-*gnu*)
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd;;
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd
RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd
;;
esac
fi

Expand Down
39 changes: 27 additions & 12 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3604,22 +3604,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
18 changes: 18 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,35 @@ s! {

pub struct stat64 {
pub st_dev: crate::dev_t,
#[cfg(not(gnu_time_bits64))]
__pad1: c_uint,
#[cfg(not(gnu_time_bits64))]
__st_ino: c_ulong,
#[cfg(gnu_time_bits64)]
pub st_ino: crate::ino_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
#[cfg(not(gnu_time_bits64))]
__pad2: c_uint,
pub st_size: off64_t,
pub st_blksize: crate::blksize_t,
pub st_blocks: crate::blkcnt64_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
#[cfg(gnu_time_bits64)]
_atime_pad: c_int,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
#[cfg(gnu_time_bits64)]
_mtime_pad: c_int,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
#[cfg(gnu_time_bits64)]
_ctime_pad: c_int,
#[cfg(not(gnu_time_bits64))]
pub st_ino: crate::ino64_t,
}

Expand Down Expand Up @@ -115,10 +127,13 @@ s! {
pub shm_perm: crate::ipc_perm,
pub shm_segsz: size_t,
pub shm_atime: crate::time_t,
#[cfg(not(gnu_time_bits64))]
__unused1: c_ulong,
pub shm_dtime: crate::time_t,
#[cfg(not(gnu_time_bits64))]
__unused2: c_ulong,
pub shm_ctime: crate::time_t,
#[cfg(not(gnu_time_bits64))]
__unused3: c_ulong,
pub shm_cpid: crate::pid_t,
pub shm_lpid: crate::pid_t,
Expand All @@ -130,10 +145,13 @@ s! {
pub struct msqid_ds {
pub msg_perm: crate::ipc_perm,
pub msg_stime: crate::time_t,
#[cfg(not(gnu_time_bits64))]
__glibc_reserved1: c_ulong,
pub msg_rtime: crate::time_t,
#[cfg(not(gnu_time_bits64))]
__glibc_reserved2: c_ulong,
pub msg_ctime: crate::time_t,
#[cfg(not(gnu_time_bits64))]
__glibc_reserved3: c_ulong,
pub __msg_cbytes: c_ulong,
pub msg_qnum: crate::msgqnum_t,
Expand Down
67 changes: 59 additions & 8 deletions src/unix/linux_like/linux/gnu/b32/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ pub type wchar_t = i32;

s! {
pub struct stat {
#[cfg(not(gnu_time_bits64))]
pub st_dev: c_ulong,
#[cfg(gnu_time_bits64)]
pub st_dev: crate::dev_t,

#[cfg(not(gnu_time_bits64))]
st_pad1: [c_long; 3],

pub st_ino: crate::ino_t,
Expand All @@ -16,52 +20,99 @@ s! {
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,

#[cfg(not(gnu_time_bits64))]
pub st_rdev: c_ulong,
#[cfg(gnu_time_bits64)]
pub st_rdev: crate::dev_t,

#[cfg(not(gnu_file_offset_bits64))]
st_pad2: [c_long; 2],
#[cfg(gnu_file_offset_bits64)]
#[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))]
st_pad2: [c_long; 3],

pub st_size: off_t,

#[cfg(not(gnu_file_offset_bits64))]
st_pad3: c_long,

#[cfg(gnu_time_bits64)]
pub st_blksize: crate::blksize_t,
#[cfg(gnu_time_bits64)]
pub st_blocks: crate::blkcnt_t,

pub st_atime: crate::time_t,
#[cfg(gnu_time_bits64)]
_atime_pad: c_int,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
#[cfg(gnu_time_bits64)]
_mtime_pad: c_int,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
#[cfg(gnu_time_bits64)]
_ctime_pad: c_int,
pub st_ctime_nsec: c_long,

#[cfg(not(gnu_time_bits64))]
pub st_blksize: crate::blksize_t,
#[cfg(gnu_file_offset_bits64)]
#[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))]
st_pad4: c_long,
#[cfg(not(gnu_time_bits64))]
pub st_blocks: crate::blkcnt_t,
#[cfg(not(gnu_time_bits64))]
st_pad5: [c_long; 14],
}

pub struct stat64 {
#[cfg(not(gnu_time_bits64))]
pub st_dev: c_ulong,
#[cfg(gnu_time_bits64)]
pub st_dev: crate::dev_t,

#[cfg(not(gnu_time_bits64))]
st_pad1: [c_long; 3],

pub st_ino: crate::ino64_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,

#[cfg(not(gnu_time_bits64))]
pub st_rdev: c_ulong,
#[cfg(gnu_time_bits64)]
pub st_rdev: crate::dev_t,

#[cfg(not(gnu_time_bits64))]
st_pad2: [c_long; 3],

pub st_size: off64_t,

#[cfg(gnu_time_bits64)]
pub st_blksize: crate::blksize_t,
#[cfg(gnu_time_bits64)]
pub st_blocks: crate::blkcnt_t,

pub st_atime: crate::time_t,
#[cfg(gnu_time_bits64)]
_atime_pad: c_int,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
#[cfg(gnu_time_bits64)]
_mtime_pad: c_int,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
#[cfg(gnu_time_bits64)]
_ctime_pad: c_int,
pub st_ctime_nsec: c_long,

#[cfg(not(gnu_time_bits64))]
pub st_blksize: crate::blksize_t,
#[cfg(not(gnu_time_bits64))]
st_pad3: c_long,
#[cfg(not(gnu_time_bits64))]
pub st_blocks: crate::blkcnt64_t,
#[cfg(not(gnu_time_bits64))]
st_pad5: [c_long; 14],
}

Expand Down Expand Up @@ -161,22 +212,22 @@ s! {

pub struct msqid_ds {
pub msg_perm: crate::ipc_perm,
#[cfg(target_endian = "big")]
#[cfg(all(not(gnu_time_bits64), target_endian = "big"))]
__glibc_reserved1: c_ulong,
pub msg_stime: crate::time_t,
#[cfg(target_endian = "little")]
#[cfg(all(not(gnu_time_bits64), target_endian = "little"))]
__glibc_reserved1: c_ulong,
#[cfg(target_endian = "big")]
#[cfg(all(not(gnu_time_bits64), target_endian = "big"))]
__glibc_reserved2: c_ulong,
pub msg_rtime: crate::time_t,
#[cfg(target_endian = "little")]
#[cfg(all(not(gnu_time_bits64), target_endian = "little"))]
__glibc_reserved2: c_ulong,
#[cfg(target_endian = "big")]
#[cfg(all(not(gnu_time_bits64), target_endian = "big"))]
__glibc_reserved3: c_ulong,
pub msg_ctime: crate::time_t,
#[cfg(target_endian = "little")]
__glibc_reserved3: c_ulong,
pub __msg_cbytes: c_ulong,
__msg_cbytes: c_ulong,
pub msg_qnum: crate::msgqnum_t,
pub msg_qbytes: crate::msglen_t,
pub msg_lspid: crate::pid_t,
Expand Down
Loading
Loading