fuchsia: clean up module#5127
Conversation
399a0a5 to
cc9e351
Compare
cc9e351 to
ddbf270
Compare
This comment has been minimized.
This comment has been minimized.
ddbf270 to
3783462
Compare
This comment has been minimized.
This comment has been minimized.
|
CI actually passes. There seems to be an issue with a glob import that is not used, but this has not |
3783462 to
53b65df
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot blocked Like other deprecations, holding off until we can actually give the users an alternative. |
|
(https://snoozeth.is/db3wDy9dFKA) I will wait until Wed, 19 Aug 2026 08:31:22 UTC and then add label S-waiting-on-review and remove label S-blocked. @rustbot claim. |
53b65df to
b8d548c
Compare
This comment has been minimized.
This comment has been minimized.
|
There's some problems in Fuchsia. Each vendored libc implementation has a different implementation. Sometimes they can be unified. Other times it's not possible. An example of the latter is Should I also expose |
5d7d0ae to
48d5e6a
Compare
This comment has been minimized.
This comment has been minimized.
66e4bed to
dd07b99
Compare
off64_t type in Fuchsia70bef1c to
48d1e3d
Compare
|
@tgross35 The PR has been remade. It now cleans up the The description is hopefully clearer. The details of the changes are included there. There should be no need for additional One deprecation causes CI to fail. Its uses are Style checks for reasons unknown. The indentation is right. The diagnosed code does not fit the code in my branch. That's likely related to macro expansion issues. @rustbot ready review |
There was a problem hiding this comment.
There is a lot of orthogonal changes going on here. Could you split it into separate commits to make this more clear? Each section of the PR description could be its own commit, but at a minimum please be sure to separate things like non-functional cleanup and deprecations from anything that's a behavior change. All of this in the same PR is completely fine of course.
(Splitting changes that can stand on their own is good practice in general, see https://www.kernel.org/doc/html/v7.0/process/submitting-patches.html#separate-your-changes for some of the canonical guidelines. Any descriptions/links can also live in the commit messages, it's fine to say "see commit messages for details" in the top post.)
Paths are relative to the downloadable SDK. Look under the
objdirectory. Changes have been made relative to allNEXTrelease
In case you haven't come across it, web sources are at https://cs.opensource.google/fuchsia/fuchsia.
Testing is pending. This time testing is required. Two supported Fuchsia targets are tier 2. There's no CI job for them.
It's not required - T2 targets are only "guaranteed to build", which the "verify build" jobs do. We do test a handful of T2 targets, but that's out of convenience rather than requirement.
That said, of course testing everything is ideal. I'll ping the Fuschia maintainers after history gets split.
| // FIXME(i128): __reserved is meant to be an array of `long double`s. That | ||
| // requires native support for `i128`. This is currently missing. |
There was a problem hiding this comment.
If you have a source for long double being f128, mind posting it at rust-lang/rust#140417? I would have assumed f64.
Also this comment says i128 but should be f128.
There was a problem hiding this comment.
I looked it up in the libc crate. There's a comment in https://github.com/rust-lang/libc/blob/main/src/unix/nto/mod.rs#L799-L810. f128 has equivalent alignment and size constraints to __int128 in gcc.
I read the RFC for f128. It didn't comment on this. I have assumed the comment correct. But it could be wrong.
|
Reminder, once the PR becomes ready for a review, use |
Each fuchsia target should only support a single libc. I don't see that listed in https://doc.rust-lang.org/rustc/platform-support/fuchsia.html but perhaps it should be? You could probably open a r-l/r PR updating that if there is a straightforward answer, or an issue if there isn't. |
48d1e3d to
3bd66a6
Compare
This comment has been minimized.
This comment has been minimized.
I did come across the source browser. That's were I got confused by the vendored libc implementations. The SDK provides a single set of headers. This makes searches more "coherent." The testing part was not meant for others. It was a personal reminder. But I understood the testing policy wrong. Just reread "Platform Support" in the rustc book. Thanks. |
2c2cb1d to
d615de8
Compare
There are type definitions that do not exist upstream. There are records with wrong fields. There are records with wrong alignment. There are incorrect pollyfils for macros. This patch fixes most of it. But there's stuff I've missed.
There was some infrastructure built for `fd_set`. This was not necessary. This patch simplifies that. It possibley also fixes the definition.
Existing type aliases are equivalent or wrong. This patch mirrors the Fuchsia SDK definitions. There was ambiguity between modules. This has been simplified.
This was pending. Solves a `FIXME`.
They are not shipped in the Fuchsia SDK.
32-bit target conditional compilation was sometimes used. This is unnecessary. Fuchsia does not support 32-bit targets. There were fields with the wrong types. There was some missing padding. This have been fixed.
Architecture-specific types were wrongly defined. This is fixed now.
d615de8 to
d1e7799
Compare
|
Fuchsia maintainers @erickt @Nashenas88 could you clarify which libc headers we should be looking at in the Fuchsia sources? |
| pub struct pthread_attr_t { | ||
| __size: [u64; 7], | ||
| pub __name: *const c_char, | ||
| pub __c11: c_int, | ||
| pub _a_stacksize: crate::size_t, | ||
| pub _a_guardsize: crate::size_t, | ||
| pub _a_stackaddr: *mut c_void, | ||
| pub _a_detach: c_int, | ||
| pub _a_sched: c_int, | ||
| pub _a_policy: c_int, | ||
| pub _a_prio: c_int, | ||
| } |
There was a problem hiding this comment.
Commit 1: we prefer to keep these opaque. At least the fields should be private, but doesn't the libc just define a repr like this?
| pub const SIG_DFL: sighandler_t = 0 as sighandler_t; | ||
| pub const SIG_IGN: sighandler_t = 1 as sighandler_t; | ||
| pub const SIG_ERR: sighandler_t = !0 as sighandler_t; | ||
| pub const INT_MIN: c_int = -1 - 0x7fffffff; | ||
| pub const INT_MAX: c_int = 0x7fffffff; | ||
|
|
||
| pub const SIG_ERR: Option<sighandler_t> = None; | ||
| pub const SIG_DFL: Option<sighandler_t> = None; | ||
| pub const SIG_IGN: Option<sighandler_t> = None; |
There was a problem hiding this comment.
Commit 1: can you clarify the sighandler_t change? If sighandler_t is size_t, this doesn't seem right.
| pub const SIGIOT: c_int = 6; | ||
| pub const SIGIOT: c_int = crate::SIGABRT; | ||
|
|
||
| pub const S_ISUID: mode_t = 0o4000; | ||
| pub const S_ISGID: mode_t = 0o2000; | ||
| pub const S_ISVTX: mode_t = 0o1000; | ||
|
|
||
| pub const IF_NAMESIZE: size_t = 16; | ||
| pub const IFNAMSIZ: size_t = IF_NAMESIZE; | ||
| pub const IFNAMSIZ: size_t = crate::IF_NAMESIZE; |
There was a problem hiding this comment.
Commit 1: don't these work fine as-is?
|
|
||
| pub struct fd_set { | ||
| fds_bits: [c_ulong; FD_SETSIZE as usize / ULONG_SIZE], | ||
| pub fds_bits: [c_ulong; FD_SETSIZE as usize / 8 / size_of::<c_long>()], |
There was a problem hiding this comment.
Commit 2: if there hasn't been demand for these fields to be public, make them private.
Commit message has a typo in "It possibley also fixes the definition.", but I'm not sure what that is referring to?
| pub union __c_anonymous_sigaction___sa_handler { | ||
| sa_handler: Option<extern "C" fn(c_int)>, | ||
| sa_sigaction: Option<extern "C" fn(c_int, *mut siginfo_t, *mut c_void)>, | ||
| } | ||
|
|
||
| pub struct sigaction { | ||
| pub __sa_handler: crate::__c_anonymous_sigaction___sa_handler, | ||
| pub sa_mask: crate::sigset_t, | ||
| pub sa_flags: c_int, | ||
| pub sa_restorer: Option<extern "C" fn()>, | ||
| } |
There was a problem hiding this comment.
Commit 3: sigaction is broken on all platforms and we should probably fix them all at once, so this commit should be split out. See also:
| pub uc_stack: crate::stack_t, | ||
| pub uc_mcontext: crate::mcontext_t, | ||
| pub uc_sigmask: crate::sigset_t, | ||
| pub __fpregs_mem: [c_ulong; 64], |
There was a problem hiding this comment.
Commit "fuchsia: fix bits/signal.h types": probably can leave this field private
| pub struct __c_anonymous__fpstate__st { | ||
| pub significand: [c_ushort; 4], | ||
| pub exponent: c_ushort, | ||
| pub padding: [c_ushort; 3], | ||
| } | ||
|
|
||
| pub struct __c_anonymous__fpstate__xmm { | ||
| element: [c_uint; 4], | ||
| } | ||
|
|
||
| pub struct _fpstate { |
There was a problem hiding this comment.
Commit "fuchsia: fix bits/signal.h types": nit, put __c_anonymous_* types after the struct they're a part of, which is what we do most places.
| pub struct ucontext_t { | ||
| uc_flags: c_ulong, | ||
| uc_link: *mut crate::ucontext_t, | ||
| uc_stack: crate::stack_t, | ||
| uc_sigmask: crate::sigset_t, | ||
| uc_mcontext: crate::mcontext_t, | ||
| } |
There was a problem hiding this comment.
Commit "fuchsia: fix bits/signal.h types": Should these fields be public?
There was a problem hiding this comment.
Commit "fuchsia: fix bits/signal.h types": the aarch64 and riscv64 definitions look new, please make sure the commit message is accurate
There was a problem hiding this comment.
Commit "fuchsia: fix bits/signal.h types": the commit message says "Architecture-specific types were wrongly defined. This is fixed now.", and a few other commits do something similar. That doesn't really say what changed - a message that describes the action helps review so we know what to look for, e.g.
Replace the x86_64
mcontext_topaque field withgregs/fregs, matching upstream definitions.
(https://docs.kernel.org/process/submitting-patches.html#describe-your-changes has some good guidelines here. Not all of it is relevant here of course, but at least the "Describe user-visible impact" and "Describe your changes in imperative mood" bits are great guidelines for all commit messages.)
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Description
This is a clean-up patch. Changes are concerned with the
fuchsiamodule.There were lacking definitions. There were records with the wrong alignment. There were types that don't exist upstream. This has been fixed. But there's more stuff to fix.
Testing is pending. This time testing is required. Two supported Fuchsia targets are tier 2. There's no CI job for them.
Sources
Paths are relative to the downloadable SDK. Look under the
objdirectory. Changes have been made relative to allNEXTreleases.wchar_tis not different across architectures. No specific definition was found. Verifying the current definition was not possible.nlink_tis not different across architectures.blksize_tis not different across architectures.ssizet_thad a wrong definition. Other_t-terminated types had similar issues. Those will not be further repeated in this list.cs.opensource.google. This includes suffixed offset types. These are omitted from further mention.stathad a mismatched definition.glob_thad a mismatched definition.signal.htypes often had a mismatched definition. This header file appears later on in this source list. They refer to different paths. They contain different definitions.siginfo_t.sigevent.sigaction.SIG_DFLand others are function pointers. They are cast to function pointers from integers. They are sometimesNULL. This is not allowed in Rust. I have wrapped them inOption. They are allNonenow. They should not all beNone. Transmutation from a pointer without provenance to a function pointer is required. This causes compile-time errors.stat64doesn't exist.ipc_permdoesn't exist.epoll_datadoesn't exist. Deprecation lints here keep popping up. I've attempted to silence them. My attempts have been futile.epoll_eventdoesn't exist.ff_effectdoesn't exist.termios2doesn't exist.sysinfodoesn't exist.mq_attrdoesn't exist.sockaddr_nldoesn't exist.RLIM_SAVED_MAXdoesn't exist.RLIM_SAVED_CURdoesn't exist.RLIM_INFINITYdoesn't exist.RLIMIT_RTTIMEdoesn't exist.RLIMIT_NLIMITSdoesn't exist.There were conditional checks against 32-bit targets. Rust does not support 32-bit Fuchsia targets. The Fuchsia project does not support 32-bit machine word targets.
There was an oddity with
pthread.htypes. They were defined with a single field. This field sometimes had size equivalent to the sum of upstream fields. This has been replaced with the real fields. This has also fixed some size and alignment mismatches.This has required changes in macros. An attempt has been made to fit the POSIX definitions. This means expanding
staticinitializers to{ 0 }. The new type definitions get all their fields zeroed. Some are made into null pointers. Should they be made intoOption::Nones? They are not function pointer fields.Macros needed fixing. Their definition did not return a value. But a value was returned upstream. Some types needed small fixes.
m_contexthad a mismatched definition. Some modules didn't have a definition.u_contexthad a mismatched definition. Some modules didn't have a definition.Checklist
libc-test/semverhave been updated*LASTor*MAXare included (see #3131)cd libc-test && cargo test --target mytarget); especially relevant for platforms that may not be checked in CI@rustbot label +stable-nominated