-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add new cfg gnu_file_offset_bits64 corresponding to _FILE_OFFSET_BITS=64 #4345
base: main
Are you sure you want to change the base?
Conversation
Less commands makes for a cleaner `set -x` log. And it is more efficient.
Variables set with `env` in the matrix never propagated into the environment. Add a step in test_tier1 and test_tier2 that reads the env context from the matrix and adds the variables to the environment used by later steps.
The `Create I artifacts` step is always run, whether earlier steps succeeds or not. But the upload step would only run if all preceeding steps wer successfull. Add a conditional to always run except if artifact creation failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked the type changes in detail but this looks pretty good to me. Left a handful of comments mostly related to configuration.
Thank you so much for working on this!
build.rs
Outdated
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); | ||
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); | ||
let target_ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap(); | ||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, could you move these out of this block and toward the top of main
? Something else may want to use them.
unwrap_or_default()
may be better too, I doubt anybody is building this without Cargo but it's probably good to be careful just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
build.rs
Outdated
Ok(val) => { | ||
if val == "1" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok(val) => { | |
if val == "1" { | |
Ok(val) => if val == "1" { |
Nit to remove an indent level. The next arm needs to change to Ok(_v) | Err(_e)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
build.rs
Outdated
&& target_arch != "riscv32" | ||
&& target_arch != "x86_64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x86_64
won't ever get matched here since target_ptr_width
is checked right? And then, what is special about riscv32?
It would probably be good to add a riscv32 test in CI since unfortunately we don't have one yet (not here of course)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x86_64-unknown-linux-gnux32
have 32bit pointer but always 64 bit time_t
.
riscv32
also always have 64-bit time_t
.
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS64: 1 | ||
artifact-tag: offset-bits64 | ||
# - target: powerpc-unknown-linux-gnu | ||
# - target: powerpc-unknown-linux-gnu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you keep the FIXME(ppc): SIGILL running tests ...
note?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I meant to include that.
--volume "$(pwd)":/checkout:ro \ | ||
--volume "$(pwd)"/target:/checkout/target \ | ||
--volume "$PWD":/checkout:ro \ | ||
--volume "$PWD"/target:/checkout/target \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just style (fine if so) or did some platform not work with PWD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not just style, running the script under set -x
will give prints for the execution of the $(pwd)
subprocess.
At the moment I was having a hard time getting the CI to do what I wanted and the extra prints were annoying.
libc-test/build.rs
Outdated
Ok(val) => { | ||
if val == "1" { | ||
if target.contains("gnu") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok(val) => { | |
if val == "1" { | |
if target.contains("gnu") | |
Ok(val) if val == "1" && target.contains("gnu") && ... |
Same nit as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
target_env = "gnu", | ||
gnu_file_offset_bits64 | ||
))] { | ||
pub const RLIM_INFINITY: crate::rlim_t = !0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be the same as the above block? If so, the conditions could be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditions tend to be complicated, but I'll push an updated variant.
// #[cfg(not(gnu_file_offset_bits64))] | ||
// __st_ino: crate::ino_t, | ||
// #[cfg(gnu_file_offset_bits64)] | ||
__st_ino: c_ulong, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this to be commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was included by mistake. I'll remove it.
build.rs
Outdated
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS64"); | ||
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS64") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may want to use RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS
and then have it be set to =32
or =64
. Reason being, I think in 1.0 we will default to 64-bit but need to provide an environment variable to use 32.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, doesn't this need to set edit: nope, mixing my time and fileslinux_time_bits64
as well?
if #[cfg(not(target_env = "gnu"))] { | ||
missing! { | ||
#[cfg_attr(feature = "extra_traits", derive(Debug))] | ||
pub enum fpos_t {} // FIXME(unix): fill this out with a struct | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not provided at all for glibc? Or only with 64-bit time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was only provided as an enum before, this PR provides it for gnu/glibc. The definition for glibc is in src/unix/linux_like/linux/gnu/mod.rs.
The fpos_t
definition in src/unix/mod.rs and fpos64_t
definition in src/unix/linux_like/linux/mod.rs are now only for non-gnu libcs.
Add new jobs for i686 in test_tier1 and arm and powerpc in test_tier2 where RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64. Use artifact-tag to avoid artifact name collisions.
Set the basic types correctly for gnu_file_offset_bits64 (_FILE_OFFSET_BITS=64).
gnu_file_offset_bits64 means _FILE_OFFSET_BITS=64.
When _FILE_OFFSET_BITS=64, glibc redirects some function calls to 64 bit versions. These symbols are sometimes the public LFS variants, sometimes hidden variants.
Like mips, the stat struct will become different once support for gnu_file_offset_bits64 is added.
Like mips and powerpc, the stat struct will become different once support for gnu_file_offset_bits64 is added.
Change the __padX members in b32/mod.rs from short to uint even though they are actually unsigned short in C. Using unsigned int will give the same alignment, and make the struct equivalent to stat64 when gnu_file_offset_bits64 is set.
Struct stat and stat64 needs to match when gnu_file_offset_bits64 is set.
The __f_unused field should be the same in statvfs and statvfs64 (where it was already included) as can be seen in https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/statvfs.h;h=1aed2f54aa86e43ac1c1d3a33197b3232be76580;hb=HEAD
aba1e20
to
cf9c316
Compare
@rustbot ready |
Description
Add a new cfg
gnu_file_offset_bits64
corresponding to-D_FILE_OFFSET_BITS=64
.The cfg can also be enabled by setting the environment variable
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS64=1
.This is the second part of what was #3175 .
Sources
off_t
ino_t
blkcnt_t
fsblkcnt_t
fsfilcnt_t
rlim_t
F_GETLK
F_SETLK
andF_SETLKW
RLIM_INFINITY
getrlimit
,setrlimit
,prlimit
pread
,pwrite
,preadv2
,pwritev2
aio_read
,aio_write
,aio_error
,aio_return
,aio_cancel
,lio_listio
fallocate
,posix_fallocate
,posix_fadvise
,open
,creat
,fcntl
,lockf
,openat
glob
,globfree
mkstemps
,mkostemp
,mkostemps
,mkstemp
sendfile
statfs
,fstatfs
fopen
,freopen
,tmpfile
,fgetpos
,fsetpos
,fseeko
,ftello
stat
,fstat
,fstatat
,lstat
statfs
,fstatfs
readdir
,readdir_r
lseek
,pread
,pwrite
, truncate,ftruncate
mmap
struct statvfs
,struct fstatvfs
struct stat
,struct stat64
struct statfs
,struct statfs64
struct fpos_t
,struct fpos64_t
struct aiocb
struct flock
Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see #3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI
I've tested this as widely as possible, but I have not been able to
run the sparc tests. mips and powerpc tests have been run on rust
1.85 using the yocto project, but it's not a fully compatible
environment for some reason.