-
Notifications
You must be signed in to change notification settings - Fork 1.1k
musl: 64-bit time support #4463
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
base: main
Are you sure you want to change the base?
Conversation
Hmm, seems like the style checker isn't happy with mixing |
Since #4433 seems close to merging, I can rebase on top of it once merged. |
This feature is enabled with independently from musl_v1_2_3 to support time64. This also sets a musl_not_time64 feature to make `cfg` statements easier to read. Defining linux_time_bits64 makes this roughly equivalent to upstream commit bminor/musl@f12bd8e.
This is equivalent to upstream commit bminor/musl@9b2921b.
This corresponds to upstream commit bminor/musl@1febd21 (most symbols) and bminor/musl@22daaea (only dlsym)
A bunch of properties were removed upstream and set to reserved. This matches upstream commit bminor/musl@827aa8f and bminor/musl@2d69fcf
44fe8c9
to
8b32bb3
Compare
Change time_t type to i64 Change struct stat, msqid_ds and shmid_ds to reflect This commit follows upstream bminor/musl@3814333 and bminor/musl@d6dcfe4 It also implements a fix from bminor/musl@0fbd7d6
This is primarily based on a small part of bminor/musl@3814333. This also integrates bminor/musl@3c02bac, which update MSG_STAT, SEM_STAT, SEM_STAT_ANY. These are based on the value of IPC_STAT, however we can just use `cfg` as it is effectively the same.
This fixes test failures on musl.
This was incorrectly named in upstream musl and fixed in bminor/musl@cabc369
This is because the struct is different depending on whether time64 is enabled.
Rebased on top of the GNU changes :) |
Thanks! Sorry it's taken me a while, I'll try to look at this very soon |
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.
Thanks for working on this! Left a few comments here.
For the style check, are the changes it is suggesting possible? If not, that will probably have to be updated unfortunately (hopefully we will be able to reorganize things at some point so it's less annoying...)
if ((musl_v1_2_3 || target_os == "loongarch64") && target_env == "musl") || target_env == "ohos" | ||
{ | ||
set_cfg("musl_v1_2_3"); | ||
if musl_time64 && MUSL_TIME64_ARCHS.contains(&target_arch.as_str()) { | ||
set_cfg("musl_time64"); | ||
set_cfg("linux_time_bits64"); | ||
} else { | ||
set_cfg("musl_not_time64"); | ||
} | ||
} else if target_env == "musl" || target_env == "ohos" { | ||
set_cfg("musl_not_time64"); |
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.
Why is musl_not_time64
needed? not(musl_time64)
should be usable everywhere.
--env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \ | ||
--env RUST_LIBC_UNSTABLE_GNU_TIME_BITS \ | ||
--env RUST_LIBC_UNSTABLE_MUSL_V1_2_3 \ | ||
--env RUST_LIBC_UNSTABLE_MUSL_TIME64 \ | ||
--env CARGO_HOME=/cargo \ | ||
--env CARGO_TARGET_DIR=/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.
Nit: this should match the indentation
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 musl_time64
as it is used should be named something like musl_time64_on_32
. We probably don't need an env to set this independently, build.rs
should just set it when musl_time64
is set and target_ptr_width
is 32.
#[cfg(musl_time64)] | ||
pub const IPC_STAT: c_int = 0x102; | ||
#[cfg(not(musl_time64))] | ||
pub const IPC_STAT: c_int = 2; |
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.
Style nit: these should be writeable as pub const IPC_STAT: c_int = if cfg!(musl_time64) { 0x102 } else { 2 }
to get the else
fallback and reduce the amount of code that is cfg
ed out on some platforms.
Description
This change includes time64 support for applicable architectures (x86, arm, mips and powerpc). This is based on the previous PRs to this repo as well as the musl changelog from 1.1.24 -> 1.2. It can be enabled with the environment variable
RUST_LIBC_UNSTABLE_MUSL_TIME64
only when musl_v1_2_3 is enabled and the architecture is supported.A lot of structures, especially ones with mixed endian became excessively complicated, so I used
cfg_if
to separate them. It looks like you can only nests! {}
incfg_if! {}
, but not vice versa.As a note, I'm considering removing
musl_not_time64
, and just keeping the old logic of allowing deprecated for function definitions involvingtime_t
as it introduces necessary complexity.When libc 1.0 is released, I believe the best path would be to remove the
musl_v1_2_3
feature, making it unconditionally enabled, keepingmusl_time64
which will expand to(musl && time64_arch)
.Tested through QEMU for all architectures.
Sources
Sources are located on each commit, in the form of upstream commits
Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see rust-lang/libc#3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI
@rustbot label +stable-nominated