Skip to content

Separate L4Re from Linux code, add aarch64 and enable tests #4479

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

farao
Copy link

@farao farao commented Jun 9, 2025

The L4Re code was previously attached to the Linux code which was not correct in many ways. This commit separates the L4Re code and enables the libc-tests and includes the fixes for the failing tests. Aarch64 is added as a second supported architecture (more to come).

Sources

L4Re-adapted version of uclibc: https://github.com/kernkonzept/l4re-core/tree/master/uclibc/lib.

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot
Copy link
Collaborator

rustbot commented Jun 9, 2025

Some changes occurred in the Android module

cc @maurer

@farao farao force-pushed the revert branch 11 times, most recently from 92284e5 to 40a082a Compare June 12, 2025 16:33
@farao
Copy link
Author

farao commented Jun 13, 2025

Hi @tgross35, this is the refactoring of the recent L4Re PR: #4383 (which is kept around just in case).

I think the failure of the freebsd nightly checks is not my fault. The rest succeeds now.

I did most of what you requested in your comment on the old PR, I just kept the linux/mod.rs file around since there is a massive part of code that is linux-only and is not supported by L4Re and it did not seem to make sense to put it all in shared.rs.

Also, I put some more code that's shared from the sub modules (emscripten, android, linux, l4re) up in linux_like/mod.rs. In theory, I think there's potential to do that with more code, that's just the one that I would have put in shared.rs but realized that it could go into linux_like/mod.rs instead.

@farao farao force-pushed the revert branch 2 times, most recently from 26e9993 to 5b60e70 Compare June 23, 2025 09:15
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this has taken a while to get to, but thank you for all the changes here! The shape of this one looks much better. I have a handful of small comments but will need to take a deeper look at the big refactor portions again.

ci/run-docker.sh Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this isn't directly related to l4re, mind splitting it to a separate commit? (same PR is fine of course)

Copy link
Author

@farao farao Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -3990,6 +4007,10 @@ fn test_linux(target: &str) {
});

cfg.skip_struct(move |ty| {
if ty.starts_with("l4_") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these anonymous on l4re?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually turned out to be not necessary. I removed this and similar lines.

@@ -4169,6 +4190,12 @@ fn test_linux(target: &str) {
});

cfg.skip_const(move |name| {
// L4Re requires a min stack size of 64k; that isn't defined in uClibc, but
// somewhere in the core libraries. uClibc wants 16k, but that's not enough.
if name == "PTHREAD_STACK_MIN" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be l4re && ... right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, done.

@@ -3716,11 +3728,12 @@ fn test_linux(target: &str) {
"libgen.h",
"limits.h",
"link.h",
"linux/sysctl.h",
[uclibc]: "linux/if_ether.h",
[linux]: "linux/sysctl.h",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is probably safer to flip the logic here. That is, rather than [linux], make these [!l4re] so any other OS that happens to reuse some of this function gets the same defaults.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, that's better! I changed it.

@@ -4920,7 +4949,9 @@ fn test_linux(target: &str) {

cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs");

test_linux_like_apis(target);
if linux {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, if !l4re here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 234 to 247
(*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
}

pub unsafe fn si_value(&self) -> crate::sigval {
#[repr(C)]
struct siginfo_si_value {
_si_signo: c_int,
_si_errno: c_int,
_si_code: c_int,
_si_timerid: c_int,
_si_overrun: c_int,
si_value: crate::sigval,
}
(*(self as *const siginfo_t as *const siginfo_si_value)).si_value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is preexisting, but mind updating to the slightly safer newer casting APIs? So ptr::from_ref(self).cast::<siginfo_sigfault>()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 123 to 124
// FIXME(1.0): this is actually a union
pub struct sem_t {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ulibc was broken before this right? If so, might as well make it correct here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was broken before. I fixed it now.

@@ -0,0 +1,2127 @@
//! Shared definitions between Linux and L4Re

// TODO: check if there is more overlap with emscripten and android
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME(linux) if this comment is meant to be left in the codebase

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the FIXME. There are actually a lot of cases where the same struct that is shared between l4re and linux is also shared with one of the other targets (android or emscripten) and one might think about adding all these cases to linux_like/mod.rs instead (with the exception of the differing target as #[cfg..].

@tgross35
Copy link
Contributor

tgross35 commented Jul 7, 2025

@rustbot author, for the above review and a rebase

@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@farao
Copy link
Author

farao commented Jul 7, 2025

Thanks for the comments! Unfortunately, I'll only be able to get to them beginning of next week but I'll make it a priority then!

@farao farao force-pushed the revert branch 3 times, most recently from 237f630 to c2490f3 Compare July 14, 2025 14:44
The L4Re code was previously attached to the Linux code which was not
correct in many ways. This commit separates the L4Re code and enables
the libc-tests and includes the fixes for the failing tests. Aarch64 is
added as a second supported architecture (more to come).
@farao
Copy link
Author

farao commented Jul 14, 2025

@tgross35 Should be all fixed now. CI runs through (the failing freebsd checks are again not due to my change). Anything else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants