-
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 cygwin support #4279
base: main
Are you sure you want to change the base?
Add cygwin support #4279
Conversation
Co-authored-by: Ookiineko <[email protected]>
Co-authored-by: Ookiineko <[email protected]>
Stable compilers failed because |
If it's just check-cfg failing, then it needs an update in Line 25 in 3695157
|
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.
Most of this looks pretty good but there are a handful of changes to get this more in line with the other OSs.
Does cygwin only ever use newlib, or are there other libc implementations?
|
||
cfg.skip_const(move |name| { | ||
match name { | ||
// FIXME: these constants do not exist on Cygwin |
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 add a tag like FIXME(cygwin)
for all FIXMEs? We're trying to get everything greppable.
@@ -136,9 +136,18 @@ s! { | |||
} | |||
|
|||
pub struct hostent { |
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.
hostent
and linger
seem to have pretty different definitions between Cygwin and the rest of Unix. Would it be possible to move the existing structures into a cfg(not(target_os = "cygwin"))
block, then redefine them in cygwin/mod.rs
instead?
pub type c_char = i8; | ||
pub type c_long = i64; | ||
pub type c_ulong = u64; |
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.
These shouldn't be needed, the types are now defined in primitives.rs
cfg_if! { | ||
if #[cfg(doc)] { | ||
pub(crate) type Ioctl = c_int; | ||
} else { | ||
#[doc(hidden)] | ||
pub type Ioctl = 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.
Why is this config needed?
#[cfg_attr(feature = "extra_traits", derive(Debug))] | ||
pub enum timezone {} | ||
impl Copy for timezone {} | ||
impl Clone for timezone { | ||
fn clone(&self) -> timezone { | ||
*self | ||
} | ||
} |
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.
Can this go in an e!
macro so it gets these derived? Same for enum sem
.
} | ||
} | ||
|
||
s_no_extra_traits! { |
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.
Do all of the items here need to be in s_no_extra_traits
? It looks like at least a few of them don't have an alignment requirement or contain a union so could probably go in s!
.
} | ||
} | ||
|
||
impl PartialEq for __c_anonymous_ifr_ifru { |
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 aren't doing any traits that read values for unions anymore, or anything that contains them, since the implementations are too often unsound (as is the case here, possible uninitialized data read). So please drop these, the unions should still get a default debug impl from
Lines 163 to 168 in 268e1b3
#[cfg(feature = "extra_traits")] | |
impl ::core::fmt::Debug for $i { | |
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { | |
f.debug_struct(::core::stringify!($i)).finish_non_exhaustive() | |
} | |
} |
// intentionally not public, only used for fd_set | ||
cfg_if! { | ||
if #[cfg(target_pointer_width = "32")] { | ||
const ULONG_SIZE: usize = 32; | ||
} else if #[cfg(target_pointer_width = "64")] { | ||
const ULONG_SIZE: usize = 64; | ||
} else { | ||
// Unknown target_pointer_width | ||
} | ||
} |
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 these use core::mem::size_of::<c_ulong>()
instead?
let _dummy: cpu_set_t = core::mem::zeroed(); | ||
let size_in_bits = 8 * core::mem::size_of_val(&_dummy.bits[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.
core::mem::zeroed()
is advised against nowadays. Could this just be cpu_set_t { bits: [0; 16] }
?
Applies a couple of other places.
pub struct siginfo_t { | ||
pub si_signo: c_int, | ||
pub si_code: c_int, | ||
pub si_pid: pid_t, | ||
pub si_uid: uid_t, | ||
pub si_errno: c_int, | ||
__pad: [u32; 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.
Do you have a link to the header this is defined in? It doesn't seem to match https://github.com/cygwin/cygwin/blob/4bcc6adec765ee8354bfc9e6c060c9d1c0c7bf46/newlib/libc/include/sys/signal.h#L69-L73.
Description
rust-lang/rust#134999
Most changes are ported from https://github.com/ookiineko-cygport/libc
Sources
https://github.com/cygwin/cygwin/tree/main/winsup/cygwin/include
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'm not sure how to test a no_std target. Actually I need these changes to implement std for cygwin target.