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 support for loongarch64 #528

Closed
wants to merge 1 commit into from

Conversation

zhaixiaojuan
Copy link

The LoongArch architecture (LoongArch) is an Instruction Set Architecture (ISA) that has a RISC style.

Documentations:
ISA:
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html
ABI:
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
More docs can be found at:
https://loongson.github.io/LoongArch-Documentation/README-EN.html

Copy link

@xen0n xen0n left a comment

Choose a reason for hiding this comment

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

Now I see why rust-lang/rust#101069 is needed at all at such an early bring-up stage... this crate is being depended upon by Cargo. A lot have changed since I last ported Rust.

cc @heiher

@@ -361,6 +361,8 @@ fn init() {
let ptr = vdso.sym(cstr!("LINUX_2.6"), cstr!("__vdso_clock_gettime64"));
#[cfg(target_arch = "mips64")]
let ptr = vdso.sym(cstr!("LINUX_2.6"), cstr!("__vdso_clock_gettime"));
#[cfg(target_arch = "loongarch64")]
let ptr = vdso.sym(cstr!("LINUX_5.19"), cstr!("__vdso_clock_gettime"));
Copy link

Choose a reason for hiding this comment

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

This is wrong, LoongArch vDSO symbol version is LINUX_5.10 according to the sources. (It's the version at the time LoongArch upstream work has started, not the time when the port was mainlined, IIUC.)

@@ -328,6 +336,7 @@ pub(crate) fn setpriority_process(pid: Option<Pid>, priority: i32) -> io::Result
}
}

#[cfg(not(target_arch = "loongarch64"))]
Copy link

Choose a reason for hiding this comment

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

I don't think we should deprive LoongArch from having old-style {get,set}rlimit API support. As you can see, this function is actually just a prlimit64 wrapper.

#[cfg(all(target_pointer_width = "64", not(target_arch = "mips64")))]
#[cfg(all(
target_pointer_width = "64",
not(any(target_arch = "mips64", target_arch = "loongarch64"))
Copy link

Choose a reason for hiding this comment

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

Similarly we most definitely don't want to force everyone to migrate to statx if they ever want their code to run on LoongArch systems. We should keep the generic stat definitions here, but add code for translating between the two ABIs: see my Go adaptation a while ago (check src/syscall/syscall_linux_loong64.go) or glibc (check sysdeps/unix/sysv/linux/fstatat64.c). We have to add the code because we're the first 64-bit architecture without fstat at all.

@sunfishcode
Copy link
Member

Now I see why rust-lang/rust#101069 is needed at all at such an early bring-up stage... this crate is being depended upon by Cargo. A lot have changed since I last ported Rust.

On architectures it doesn't recognize, rustix should default to using its libc backend, which doesn't use any asm and in theory should just work. If this is an early bring-up phase, it may make sense to just use that rather than pushing for rustix linux_raw support right away.

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.

3 participants