Skip to content
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 getregs()/setregs()/getregset()/setregset() for Linux/musl/aarch64 #2502

Merged
merged 4 commits into from
Sep 15, 2024

Conversation

orhun
Copy link
Contributor

@orhun orhun commented Sep 14, 2024

What does this PR do

I needed this specific API for packaging my project for Alpine Linux distribution:

I added support for aarch64-unknown-linux-musl for getregs() function and it builds fine now, but I don't have a way to test it.
Also, I'm not sure if this is the correct way to add support for this architecture - but should be fine!

Let me know what you think and I can try adding support for other functions (such as setregs()) as well.

BTW this is my first PR to the nix crate so please let me know if I'm doing something wrong 🐻

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

@orhun orhun force-pushed the getregs/aarch64-unknown-linux-musl branch from 37f409a to eb6acf0 Compare September 14, 2024 08:11
@SteveLauC SteveLauC self-requested a review September 14, 2024 08:17
@SteveLauC
Copy link
Member

but I don't have a way to test it.

Here is a test, maybe you can take a look and try enabling it for musl as well:)

@orhun orhun changed the title Support getregs() for aarch64-unknown-linux-musl Add getregs()/getregset()/setregset() for Linux/musl/aarch64 Sep 14, 2024
@orhun
Copy link
Contributor Author

orhun commented Sep 14, 2024

I expanded the scope of this PR a bit and enable the tests. Thought I still wonder why Linux/musl/aarch64 wasn't enabled in the initial implementation in #2044

@orhun
Copy link
Contributor Author

orhun commented Sep 14, 2024

The tests seem to be passing 🤔

@SteveLauC
Copy link
Member

Thought I still wonder why Linux/musl/aarch64 wasn't enabled in the initial implementation in #2044

I think it is because the author's use case does not target aarch64-unknown-linux-musl.

I expanded the scope of this PR a bit and enable the tests.

Looks like setregs() is also added, let me edit the PR title (as it will be used as the commit message, we use squash merge).

@SteveLauC SteveLauC changed the title Add getregs()/getregset()/setregset() for Linux/musl/aarch64 Add getregs()/setregs()/getregset()/setregset() for Linux/musl/aarch64 Sep 15, 2024
Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the patch!

@SteveLauC SteveLauC added this pull request to the merge queue Sep 15, 2024
Merged via the queue into nix-rust:master with commit 062211b Sep 15, 2024
38 checks passed
@orhun
Copy link
Contributor Author

orhun commented Sep 15, 2024

Awesome, thanks for the merge!

When should we expect a new release? 😇

@SteveLauC
Copy link
Member

When should we expect a new release? 😇

Probably not soon, the I/O safety port is still not done, even though we finish it quickly, we still need to test it. Can you guys use a git dependency, though this would stop you from releasing to crates.io, I am not sure if this will block lurk from being included in Alpine Linux

@orhun
Copy link
Contributor Author

orhun commented Sep 15, 2024

Thanks for letting me know!

Can you guys use a git dependency, though this would stop you from releasing to crates.io,

Yeah, weekly alpha/rc releases would be really useful for these cases. Both for accessing the versions quickly and testing it :)

I am not sure if this will block lurk from being included in Alpine Linux

I'm not sure as well, just asked them 👀

target_arch = "riscv64"
)
),
all(target_env = "musl", target_arch = "aarch64")
)
))]
pub fn getregset<S: RegisterSet>(pid: Pid) -> Result<S::Regs> {
Copy link
Member

@SteveLauC SteveLauC Sep 22, 2024

Choose a reason for hiding this comment

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

We forgot to enable the RegisterSet trait and enum RegisterSetValue for linux/aarch64/musl in this PR, I found this while reviewing #2507, the CI does not catch it as well because we don't have CI for this triple:<

Copy link
Member

Choose a reason for hiding this comment

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

I added support for aarch64-unknown-linux-musl for getregs() function and it builds fine now, but I don't have a way to test it.

I am kinda surprised that Rust does not catch this at compile time. 🤔

@orhun, could you please give this a fix and if possible, give this a try with lurk?

Copy link
Member

Choose a reason for hiding this comment

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

I try to fix this issue and add the CI for aarch64/musl in #2510, but it looks like the constants needed by enum RegisterSetValue have not been defined in the libc crate, so we need to add them there first.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah damn, good catch, these arch stuff goes deep!

Do you want me to test it out with lurk? Is there any other thing that I can help here?

Copy link
Member

Choose a reason for hiding this comment

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

these arch stuff goes deep!

Exactly 😪

Do you want me to test it out with lurk?

Yeah, that would be great! Once #2510 is merged, we can start the test:)

Is there any other thing that I can help here?

Currently, no, I may ping you when I do need you 😁

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

Successfully merging this pull request may close these issues.

2 participants