-
Notifications
You must be signed in to change notification settings - Fork 120
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
Initial RISC-V 64-bit Support #261
Conversation
I have used https://gitlab.com/giomasce/dqib to get a qemu rv64 instance of Debian sid up and running. |
We already have CI in QEMU for Arm, adding RV should be easy. it would be nice if this could also support RV32, most of the changes would just be changing magic constants to a multiple of XLEN, but I’m happy to land 64-bit support first. Can you also add a bullet in ANNOUNCE? I think adding a new architecture counts as something worth mentioning in the release notes. Note that clang will need to be patched to add RV64 to the set of architectures that it used non-legacy dispatch for (when using a runtime version of 2.2 or newer). I think you can pass something like -fno-legacy-dispatch, but please make sure that it actually is emitting objc_msgSend and not the two-stage approach that we use on architectures without the assembly fast paths. |
Here the Ghidra C reconstruction: [...]
local_18 = (int)local_a0;
/* try { // try from 00102cd6 to 00102ce1 has its CatchHandler @ 00102d04 */
FUN_00101f20(TestCls,.objc_selector_foo_);
if (local_18 == 0) {
FUN_00101e90("exceptionThrown && \"An exception was thrown\"",
"/root/libobjc2/Test/objc_msgSend.m",0xbd,"int main(void)");
}
[..] void FUN_00101f20(void)
{
gp = &__global_pointer$;
objc_msgSend();
return;
} |
That would be great. Not sure what the calling conventions look like for the SIMD and Vector extensions. If either of these can carry arguments then we would also need to spill them.
Up to you.
Ah, this one calls
It's probably a bad sign that I find that harder to read than RISC-V assembly. |
Oh yeah I forgot about this.
I have never worked with the clang sources. Where can I find this set?
It seems like there is no Linux distribution supporting riscv32. Debian supports riscv64 in unstable, but not riscv32, as it is mostly used by microcontrollers anyway. So there are two options:
I would like to get the CI up and running in this PR, and add rv32 support later. This is mostly due to the fact, that I setting up an environment is not trivial.
:) |
Huh, it looks as if FreeBSD doesn’t either. I support a RISC-V profile (CHERIoT, based on RV32E) that doesn’t support *NIX systems but I thought there was Linux support for larger embedded systems. Happy to not bother with 32-bit if it’s painful. We probably can’t support Objective-C on our platform since we’re mostly targeting systems with tens to hundreds of KiBs of RAM (though I may revisit the low memory profile at some point).
This should be the right place: It looks as if we don’t use the fast paths for AArch64 either, which probably should be fixed at the same time, since that’s been working in the runtime for 5 years. Should at least be enabled for 2.0 or later… |
CI is now up and running! I had to add LLVM 15 and exclude 13, and 14 because lld did not support R_RISCV_ALIGN relocations until version 15. Waiting for your review!
Sounds like an interesting project :)
I will open a PR. Thank you! |
LGTM, please can you fix ANNOUNCE and squash? |
#76694) This PR updates the list of architectures for which libobjc2 has fast-path objc_msgSend implementations. Related to: gnustep/libobjc2#261
This pull request adds RISC-V 64-bit (rv64) support to libobjc2. This includes:
All unit tests run successfully on my test machine, and I am planning to run the libs-base testsuite as well.
Things to consider:
Test Results
Test Machine
CMake
Test Results