-
Notifications
You must be signed in to change notification settings - Fork 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
Rebase of "Upgrade musl supported version to 1.2.3" #3791
base: main
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
FYI, no problem on OpenBSD side |
c45a829
to
0185395
Compare
☔ The latest upstream changes (presumably #3797) made this pull request unmergeable. Please resolve the merge conflicts. |
@rustbot author |
musl 1.1 maintenance has for all practical purposes ended. Accordingly, there is no point in supporting both 1.1 and 1.2 in the libc crate, so follow the time_t type transition to 64-bit.
- add padding members for musl 1.2 - ensure the padding members have an appropriate type (always c_int)
Only some 32-bit targets use the time64 family of functions and that set will not change going forward (new 32-bit targets added will use Y2038 compliant syscalls and types by default). This patch introduces a cfg flag that controls when the time64 abi related changes are enabled and sets that flag from libc and libc-tests' build.rs files.
By using set_cfg() helper.
Glad to see most pass! The only failure of Line 2744 in fc28283
Not sure how to resolve it. |
☔ The latest upstream changes (presumably #3869) made this pull request unmergeable. Please resolve the merge conflicts. |
Are you able to just skip the type with a fixme? I think we have emscripten-specific ignores already. Also not sure why this would be happening, but I am really hoping we don't need to block this on |
Also @kaniini I think you had some ideas about how to do musl better here. If you get a chance, would you mind taking a look at this? |
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 didn't check all the types in depth yet but this looks good at first glance. Please address the feedback (specifically linux_time_bits64
) and then I think we can get this in soon.
@@ -17,6 +17,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ | |||
"libc_const_extern_fn", | |||
"libc_const_extern_fn_unstable", | |||
"libc_deny_warnings", | |||
"musl_time64_abi", |
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 this be renamed to musl_redir_time64
?
Musl uses _REDIR_TIME64
in their source, I think the name is a bit more intuitive because only 32-bit does these hacks (64-bit always has the 64-bit time interface).
fn is_musl_time64_abi() -> bool { | ||
match env::var("TARGET") { | ||
Ok(target) => match &target[..] { | ||
"arm-unknown-linux-musleabi" | ||
| "arm-unknown-linux-musleabihf" | ||
| "armv5te-unknown-linux-musleabi" | ||
| "armv7-unknown-linux-musleabi" | ||
| "armv7-unknown-linux-musleabihf" | ||
| "i586-unknown-linux-musl" | ||
| "i686-unknown-linux-musl" | ||
| "mips-unknown-linux-musl" | ||
| "mipsel-unknown-linux-musl" | ||
| "powerpc-unknown-linux-musl" => true, | ||
_ => false, | ||
}, | ||
Err(_) => false, | ||
} | ||
} |
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.
We probably shouldn't match literal targets here since we only care about the prefix and the suffix. Instead could we:
- Add
const TARGET_PREFIXES_32BIT: &[&str] = &[/* ... */];
that containsarm-
,i586-
, etc - Add
const MUSL_SUFFIXES : &[&str] = &[/* ... */];
with-musleabi
,-musl
, etc - Add
fn target_is_32bit(target: &str) -> bool
that checks if it starts iftarget
starts with any ofTARGET_PREFIXES_32BIT
. Then we can reuse it with the GNU change. - Add
fn target_is_musl(target: &str) -> bool
that does the same with the suffixes - Add
fn target_is_linux(target: &str) -> bool
that checks if it contains-linux-
- Check these three functions in order to set
musl_redir_time64
/musl_time64_abi
// Some targets use time64 symbols so set the musl_time64_abi appropriately. | ||
// See #2088 and #1848 for more information. | ||
match target { | ||
"arm-unknown-linux-musleabi" | ||
| "arm-unknown-linux-musleabihf" | ||
| "armv5te-unknown-linux-musleabi" | ||
| "armv7-unknown-linux-musleabi" | ||
| "armv7-unknown-linux-musleabihf" | ||
| "i586-unknown-linux-musl" | ||
| "i686-unknown-linux-musl" | ||
| "mips-unknown-linux-musl" | ||
| "mipsel-unknown-linux-musl" | ||
| "powerpc-unknown-linux-musl" => { | ||
cfg.cfg("musl_time64_abi", None); | ||
} | ||
_ => {} | ||
} |
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 do we need this in build.rs
if it's set automatically by our crate's build script?
// Some ABIs need to redirect time related symbols to their time64 | ||
// equivalents. See #2088 and #1848 for more information. | ||
if is_musl_time64_abi() { | ||
set_cfg("musl_time64_abi"); |
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.
We should set two separate configs here:
musl_redir_time64
(musl_time64_abi
) which corresponds to musl's _REDIR_TIME64linux_time_bits64
which corresponds to__USE_TIME_BITS64
in uapi
We need this to be split because musl and glibc share the kernel uapi
#[cfg(musl_time64_abi)] | ||
pub input_event_sec: ::c_ulong, | ||
#[cfg(musl_time64_abi)] | ||
pub input_event_usec: ::c_ulong, | ||
#[cfg(not(musl_time64_abi))] | ||
pub time: ::timeval, |
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.
As mentioned above this should make use of linux_time_bits64
. Specifically to match https://github.com/torvalds/linux/blob/bf9aa14fc523d2763fc9a10672a709224e8fcaf4/include/uapi/linux/input.h#L29 it could be:
#[cfg(any(target_pointer_width = "64", not(linux_time_bits64))]
pub time: ::timeval,
#[cfg(not(any(target_pointer_width = "64", not(linux_time_bits64)))]
pub input_event_sec: ::c_ulong,
#[cfg(all(not(any(target_pointer_width = "64", not(linux_time_bits64))), target_arch = "sparc64")]
pub input_event_usec: ::c_uint,
#[cfg(all(not(any(target_pointer_width = "64", not(linux_time_bits64))), target_arch = "sparc64")]
pub __pad: ::c_uint,
#[cfg(all(not(any(target_pointer_width = "64", not(linux_time_bits64))), not(target_arch = "sparc64"))]
pub input_event_usec: ::c_ulong,
unfortunately a bit messy but I think that's accurate
pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; | ||
pub fn mq_close(mqd: ::mqd_t) -> ::c_int; | ||
pub fn mq_unlink(name: *const ::c_char) -> ::c_int; | ||
pub fn mq_receive( | ||
mqd: ::mqd_t, | ||
msg_ptr: *mut ::c_char, | ||
msg_len: ::size_t, | ||
msg_prio: *mut ::c_uint, | ||
) -> ::ssize_t; | ||
pub fn mq_timedreceive( | ||
mqd: ::mqd_t, | ||
msg_ptr: *mut ::c_char, | ||
msg_len: ::size_t, | ||
msg_prio: *mut ::c_uint, | ||
abs_timeout: *const ::timespec, | ||
) -> ::ssize_t; | ||
pub fn mq_send( | ||
mqd: ::mqd_t, | ||
msg_ptr: *const ::c_char, | ||
msg_len: ::size_t, | ||
msg_prio: ::c_uint, | ||
) -> ::c_int; | ||
pub fn mq_timedsend( | ||
mqd: ::mqd_t, | ||
msg_ptr: *const ::c_char, | ||
msg_len: ::size_t, | ||
msg_prio: ::c_uint, | ||
abs_timeout: *const ::timespec, | ||
) -> ::c_int; | ||
pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; | ||
pub fn mq_setattr( | ||
mqd: ::mqd_t, | ||
newattr: *const ::mq_attr, | ||
oldattr: *mut ::mq_attr | ||
) -> ::c_int; | ||
|
||
pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int; |
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.
Did these functions move because they are now available on openharmony? If so, that should go in a different commit preferably.
Possible solution to "how to distinguish 32 and 64" problem: rust-lang/rfcs#3716 ("[RFC] Target Modifiers") |
Also discussed in GSoC Zulip. Related: GSoC Idea OSPP Idea OSPP Zulip.
This PR is mainly the rebase of #3068 . So closes #3068 fixes #1848 closes #2088 .
Some other changes are made:
#[allow(unused_imports)]
.For the checklist for review or CI, as the original PR should have passed it, this PR only makes sure
ci/style.sh
andcd libc-test && cargo test
pass