-
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
Steps towards support for musl-unknown-linux-uclibc #578
Conversation
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.
Awesome thanks for the work here! I know you're probably not the only one waiting for better uclibc support :)
I think that uclibc is different enough from glibc/musl that we may want to start a whole separate hierarchy for uclibc? Something like src/unix/notbsd/linux/uclibc/*.rs
which is dispatched to from src/unix/notbsd/linux/mod.rs
. That should cut down on the #[cfg]
traffic I think and alleviate a lot of the changes to libc-test/build.rs
.
libc-test/build.rs
Outdated
"LC_CTYPE_MASK" | "LC_NUMERIC_MASK" | "LC_TIME_MASK" | "LC_COLLATE_MASK" | "LC_MONETARY_MASK" | "LC_MESSAGES_MASK" | | ||
"MADV_MERGEABLE" | "MADV_UNMERGEABLE" | "MADV_HWPOISON" | "IPV6_ADD_MEMBERSHIP" | "IPV6_DROP_MEMBERSHIP" | "IPV6_MULTICAST_LOOP" | "IPV6_V6ONLY" | | ||
"MAP_STACK" | "MAP_HUGETLB" | "RTLD_DEEPBIND" | | ||
"SOL_IPV6" | "SOL_ICMPV6" | "SOL_TIPC" if uclibc => true, |
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.
Shouldn't these just all be omitted on uclibc?
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.
Fixed (most of them)! The couple that are left appear to exist in the uClibc source code, but they're either optional or I'm missing some compiler flags to trigger their inclusion. I'm pretty sure at least the ones related to locale are optional
libc-test/build.rs
Outdated
@@ -309,6 +316,11 @@ fn main() { | |||
// This is actually a union, not a struct | |||
"sigval" => true, | |||
|
|||
// These structs have changed since uClibc was developed | |||
"stat" | "stat64" | "dqblk" if uclibc => true, |
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.
Shouldn't these be corrected to match what uclibc has internally?
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.
Fixed!
libc-test/build.rs
Outdated
// These structs have changed since uClibc was developed | ||
"stat" | "stat64" | "dqblk" if uclibc => true, | ||
// These structs didn't exist when uClibc was developed | ||
"aiocb" if uclibc => true, |
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.
Should this be removed from the libc crate on uclibc if it doesn't exist?
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.
Would you have any advice on how to remove aiocb
? Just sticking a #cfg[]
above it breaks because of s!
macro wrapping it
libc-test/build.rs
Outdated
@@ -290,6 +295,8 @@ fn main() { | |||
// sighandler_t is crazy across platforms | |||
"sighandler_t" => true, | |||
|
|||
"locale_t" if uclibc => true, |
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 add a short comment to why this is ignored?
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.
My bad, it looks like it builds fine with this removed!
libc-test/build.rs
Outdated
"mkostemp" | "mkostemps" | "mkstemps" | "futimes" | "setns" | "sysinfo" | "fallocate" | "posix_fallocate" | "preadv" | "pwritev" | "dup3" | "openpty" | "forkpty" | | ||
"getloadavg" | "process_vm_readv" | "process_vm_writev" | "backtrace" | "posix_madvise" | | ||
"aio_read" | "aio_write" | "aio_fsync" | "aio_error" | "aio_return" | "aio_suspend" | "aio_cancel" | "lio_listio" | | ||
"newlocale" | "duplocale" | "freelocale" | "uselocale" | "nl_langinfo_l" | "wcslen" | "getnameinfo" | "wcstombs" if uclibc && linux => true, |
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 wonder, should most of these just not be present in the libc crate? Especially the unimplemented ones seem like they shouldn't exist, but including the optional ones is likely ok. It'd be great though if we could verify against a build of uclibc with all optional extensions compiled in.
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.
Fixed (except for the locale ones and backtrace (which I think is also an optional add on?))
libc-test/build.rs
Outdated
// uClibc differs in signedness | ||
(uclibc && struct_ == "sigaction" && field == "sa_flags") || | ||
// same here | ||
(uclibc && struct_ == "msghdr" && field == "msg_iovlen") |
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 be corrected in the uclibc definitions to have the corresponding signededness according to the uclibc header files?
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.
My bad, fixed!
Thank you for the fast reply :)! Would you have any advice on how to separate it out more cleanly? |
Also it looks like |
Oh I'd just start a brand new I'd probably just add a clause to ignore |
In general libc avoids To reiterate, though, duplication is totally ok. The only risk is that when moving things around something accidentally gets lost, but it's at least all verified to be correct! |
Okay, I think I understand now :)! Is adding a |
Yeah adding a |
libc-test/build.rs
Outdated
"LC_CTYPE_MASK" | "LC_NUMERIC_MASK" | "LC_TIME_MASK" | "LC_COLLATE_MASK" | "LC_MONETARY_MASK" | "LC_MESSAGES_MASK" | | ||
"MADV_MERGEABLE" | "MADV_UNMERGEABLE" | "MADV_HWPOISON" | "IPV6_ADD_MEMBERSHIP" | "IPV6_DROP_MEMBERSHIP" | "IPV6_MULTICAST_LOOP" | "IPV6_V6ONLY" | | ||
"MAP_STACK" | "RTLD_DEEPBIND" | "MAP_HUGETLB" | | ||
"SOL_IPV6" | "SOL_ICMPV6" if uclibc => true, |
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.
Since uclibc has its own module now, most of these can be removed, right?
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.
Good catch! I'm still trying to work out how to enable the second set of ignored constants, but I unimplemented the first set at least
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 you want to work on removing this clause as well as the one below that were added?
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'm pretty sure these need to be ignored, because you can grep them in the codebase, but compiling fails, so I'm assuming these are optional features that my test case (OpenWRT) doesn't have built in. At least to me it seems like ignoring them is the best solution for now
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.
Shouldn't these constants just be deleted from uclibc files in this crate? If they don't actually exist in uclibc it seems like we shouldn't define them?
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.
Agh, sorry, I'm guessing I wasn't being as clear as I should've been. These do exist in uclibc, but they appear to be optionally enabled, because my test case with the OpenWRT toolchain doesn't have them, and they're in #ifdef guards in the headers. The ones that were a few lines above these that were removed definitely didn't exist
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.
Oh ok, that's fine yeah. Should we delete the ones that definitely don't exist, update the comment to match the one below, and then merge?
src/unix/mod.rs
Outdated
if #[cfg(target_env = "uclibc")] { | ||
mod uclibc; | ||
pub use self::uclibc::*; | ||
} else if #[cfg(any(target_os = "linux", | ||
target_os = "android", |
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 touch up the indentation on this line while you're at it?
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 I think
This is looking great to me, thanks for doing the legwork here! How confident are you in all the various definitions for each architecture? Should this only add i686/x86_64 for now? |
So I've actually been cross compiling this for mips to use with an OpenWRT router, so I'm fairly confident that it works for that one at least! I just spent some time trying to test against |
Ok maybe we should start out with just the mips targets in that case then? I figure we can add the others in over time, running tests as they come in. |
Sounds good to me! Is that something that I should try to add in this pull request? |
Yeah let's update this PR as I think it'd be deleting the non-musl modules, right? |
Sorry, I don't understand what you mean |
Oh sure I'll clarify. So this PR adds "support" for a ton of uclibc architectures, but only tested on one. Could all untested architectres be removed from this PR? |
Okay, I think I got it. So basically just delete the unsupported modules? |
☔ The latest upstream changes (presumably #585) made this pull request unmergeable. Please resolve the merge conflicts. |
@cactorium wanna update the comment and otherwise get ready to merge? |
Hey! Sorry for the delay, I was busy with my sister's graduation. Stuff should be good now I think! |
@bors: r+ Thanks! |
📌 Commit c0bec43 has been approved by |
Steps towards support for musl-unknown-linux-uclibc Hello! I've been working towards resolving #361 , this PR compiles successfully with a newish compiler (with some minor fixes in `gcc`, `ctest`), and all the tests pass for `libc-ctest`. Basically most of the undefined functions, constants, and structs were just removed from the ctest, and then any constants that weren't correct were fixed. Would it make more sense to conditionally remove them from libc? I wasn't sure when it was appropriate to skip the test for it instead of removing the function/constants, so I just removed all the tests for now because that was a little easier than hunting them down. I'm also guessing the way some of the constants were conditionally set wasn't the correct style, would you guys have any advice on how to do it more correctly? Lemme know how it looks!
☀️ Test successful - status-appveyor, status-travis |
Bump to 0.2.23 I've added a bunch of constants and xattr support for macos. We've also got preliminary support for uclibc with #578.
Hello! I've been working towards resolving #361 , this PR compiles successfully with a newish compiler (with some minor fixes in
gcc
,ctest
), and all the tests pass forlibc-ctest
. Basically most of the undefined functions, constants, and structs were just removed from the ctest, and then any constants that weren't correct were fixed. Would it make more sense to conditionally remove them from libc? I wasn't sure when it was appropriate to skip the test for it instead of removing the function/constants, so I just removed all the tests for now because that was a little easier than hunting them down. I'm also guessing the way some of the constants were conditionally set wasn't the correct style, would you guys have any advice on how to do it more correctly? Lemme know how it looks!