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 loongarch64 support #53

Merged
merged 5 commits into from
Aug 20, 2024
Merged

Add loongarch64 support #53

merged 5 commits into from
Aug 20, 2024

Conversation

k0tran
Copy link
Contributor

@k0tran k0tran commented Aug 13, 2024

PR implementing loongarch64 support

Tested on loongarch64 rust 1.80.0
Builds with debug and release flags
Passes all the tests with debug and release flags

Notes to maintainer:

  • loongarch32 is not supported by rust
  • loongarch has 7-argument syscall. I was able to come up with some implementation but it's rather ugly in my opinion
  • no clobber_abi because it clobbers more than we need

Might be useful:

Copy link
Owner

@jasonwhite jasonwhite left a comment

Choose a reason for hiding this comment

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

Awesome! I'm very skeptical that we actually need the 7 argument syscall at all. I did a little searching through the Linux kernel and didn't find a single syscall that takes 7 arguments (for any architecture). Am I missing something? I know that man syscall(2) says this architecture can have 7 arguments, but I don't see that actually happening in practice (in the Linux kernel). Is this a relic of old kernel versions?

I'd like to keep SyscallArgs at 6 arguments, since this is the common case. If I'm wrong about there not being a real life 7 argument syscall, then I would only expose it via a direct call to syscall7.

Also, it looks like loongarch64-unknown-linux-gnu is supported by cross-rs. Can you try to enable it in .github/workflows/ci.yml?

@jasonwhite
Copy link
Owner

NOTE: The CI failures for thumb mode are unrelated to this PR. It looks like a recent Rust version broke this.

@k0tran
Copy link
Contributor Author

k0tran commented Aug 15, 2024

I found that for now there is no macro for defining 7-arg syscall
https://github.com/torvalds/linux/blob/1fb918967b56df3262ee984175816f0acb310501/include/linux/syscalls.h#L227

Will redo and force loongarch to not using syscall7

@jasonwhite
Copy link
Owner

Looks like the loongarch64 CI linker failure is an issue with cross-rs. I suspect this is just because the CI for this repo is using an outdated version of cross-rs as I see there have been some recent fixes for loongarch64.

syscalls-483deb5c79caa4ef.00d8fg4tdgpxcva2mmxyzpx89.rcgu.o: Relocations in generic ELF (EM: 258)
syscalls-483deb5c79caa4ef.00d8fg4tdgpxcva2mmxyzpx89.rcgu.o: error adding symbols: file in wrong format

If you don't want to solve this issue, then I'm okay with simply having it disabled for now.

@k0tran
Copy link
Contributor Author

k0tran commented Aug 16, 2024

On my loongarch64 machine and cross 0.2.5 (on x86 with loongarch64 toolchain) compiles just fine. I'll look if I can update ci cross version

@k0tran
Copy link
Contributor Author

k0tran commented Aug 16, 2024

After installing rust from rustup everything started failing as in CI. Cross version is the same (0.2.5). I think the main cause of the error is this warning:

[cross] warning: `cross` does not provide a Docker image for target loongarch64-unknown-linux-gnu, specify a custom image in `Cross.toml`.

@k0tran
Copy link
Contributor Author

k0tran commented Aug 16, 2024

Found the problem. Right now cross version from cargo install cross does not work, but master (cargo install cross --git https://github.com/cross-rs/cross) does, so CI should wait until next cross-rs release, I suppose.

src/macros.rs Outdated Show resolved Hide resolved
src/macros.rs Outdated Show resolved Hide resolved
@jasonwhite jasonwhite merged commit 21faac7 into jasonwhite:main Aug 20, 2024
23 of 26 checks passed
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