-
Notifications
You must be signed in to change notification settings - Fork 931
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 RISC-V #628
Comments
Initial support for interpreter for march=rv32g mabi=ilp32d was at one point available, but it is not available anymore. |
First, I have some general questions:
Another thing to consider: the currently submitted RV32G target does not correspond to any practical combination of available hardware and OS at this point. Embedded CPUs are RV32I (without FPU), whereas Debian/Ubuntu target RV64G only. And About the code submitted so far:
|
hi there! :) maybe this can be helpful: good luck with it! :) |
Hi Mike, |
|
@apivovarov Further work on LuaJIT for Risc-V requires sponsorship, so until that issue is sorted out, future progress will be sporadic unfortunatelly. |
May I suggest marking this as a draft PR? |
No, this is not a draft PR. It was w-i-p that has not been continued due to the lack of interest/sponsorship. |
Hi, I'm Wei Wu, the director for PLCT Lab. Porting LuaJIT to RV64GC is listed on our roadmap[1]. One of the long term goals of PLCT Lab is bringing RISC-V to all important open source projects as tier-1 platform. I'd like to make either sponsorship or contribution on the porting project. I've searched mailing list[2] and the sponsorship page[3], and found that the discussion of sponsorship were not active. Is there any way that we can support/collaborate[4]? [1] https://plctlab.github.io/PLCT-Roadmap-2021.html [2] https://www.freelists.org/post/luajit/Want-to-sponsor [3] http://luajit.org/sponsors.html [4] Either sponsorship or community contribution is good to me. I want to avoid duplicate works. |
Hi Wei Wu, pleased to meet you. I will send you a longer response to your email, but short version is that if there is a sponsorship, there are people who can help. So far, I have seen only a general interest for RISC-V which does not make things happen. |
@lazyparser I should mention that contributing a new architecture port to LuaJIT is absolutely a non-trivial undertaking. One needs not only very detailed knowledge about the architecture in question, but also about Lua, C, compilers and the LuaJIT codebase. Based on previous occurences, someone with money at hand, but only a marginal understanding of any single of these requirements will not successfully complete this task. Also, I'm very, very, very stringent about the quality of the code that I accept. |
Hi @MikePall
I totally agree. Implementing or porting a production level JIT compiler is a serious project, especially LuaJIT. Although the PLCT lab has ported several compilers/VMs to RISC-V, we are very cautious about starting the project for porting LuaJIT, for the internal complexity of LuaJIT.
I really respect and appreciate the strict criteria in the LuaJIT project, which makes the project successful with a high quality codebase. This is also one of the reasons that I'm looking for experienced developers who has good understanding of the LuaJIT codebase. (the other reason is trying to avoid duplication work in open source) After reading again your comments, I'm afraid that my previous comments may conveyed information that I did not mean to . I have never thought of spending money to get things done. (English is not my native language. Please bear with my translated English.) Let me try to express my idea/purpose in different words: I was a compiler engineer and co-founded PLCT Lab, which is an engineering team working on compilers, simulators and language virtual machines. The big goal is to have a RISC-V laptop by the end of 2022, with Debian/Ubuntu or Fedora running on it. One of the critical paths is porting language VMs with JIT compilers. The PLCT Lab is working on JavaScript VM (V8: upstreamed; Spidermonkey: started), Java VM (OpenJDK RV32GC: WIP), etc. I humbly understand how hard of porting & optimizing the virtual machines or JIT compilers. All the important VMs and compilers are expected to be ported to RISC-V platform, and I am working really hard on it. There are 20+ engineers in PLCT Lab working on V8, OpenJDK, Spidermonkey, and others. As mentioned earlier, LuaJIT is an important project, depended by lots of softwares that are used by RISC-V users. I am very happy to find that there were already a few previous effort for porting LuaJIT to RISC-V. I want to accelerate the porting process, while keeping the code quality at the high level. |
Hi @petar-jovanovic, Thanks very much for this. I'll reply the questions in Mike's previous comment carefully. |
Hi @lazyparser, |
Still in the planning stage and still on the roadmap of the PLCT Lab. We may start to port LuaJIT after the spidermonkey porting get done. |
any news here? |
The PLCT Lab had forked the LuaJIT repo[1] and started to porting to RISC-V this month. Currently no workable version available. The best guess is that interpreter part will be done in 8-12 weeks, and the JIT part may need more 12-18 weeks. Based on the requirements in LuaJIT community, the PLCT Lab is going to upstream the ports after all the works (interpreter, JIT, testsuite) get done. |
I'm currently working with PLCT Lab under @lazyparser on initial bring-up work on the RISC-V platform. My current progress can be found here. At the time of speaking, we have DynASM RV32G/RV64G support functioning, plus some preliminary work on the interpreter backend. Here's a screenshot of a DynASM-based BF JIT compiler vs. a naive BF interpreter on a HiFive Unmatched executing the famous "mandelbrot" program. I'm looking forward to a functional interpreter in ~8 weeks, following which we'll continue working on the JIT section. |
Use lua51 instead of luajit because it doesn't support RISC-V (LuaJIT/LuaJIT#628) Unfortunately we are not getting flags correctly from luarocks. Setting all variables to avoid using default (5.4) lua installation.
Use lua51 instead of luajit because it doesn't support RISC-V (LuaJIT/LuaJIT#628)
Use lua51 instead of luajit because it doesn't support RISC-V (LuaJIT/LuaJIT#628)
Use lua51 instead of luajit because it doesn't support RISC-V (LuaJIT/LuaJIT#628) Unfortunately we are not getting flags correctly from luarocks. Setting all variables to avoid using default (5.4) lua installation.
It's been a little over nine weeks since the last progress update. The interpreter appears to be mostly functioning as of right now (301/304 tests, LuaJIT/LuaJIT-test-cleanup, without 5.2 support), with minor exceptions like DynASM reporting immediate overflow during building and occasional segfaults. Therefore, cleanups and further optimization might be wanted still. I'm now concentrating on the FFI library and the SSA IR assembler. FFI without callback support should be functional soon, whereas JIT is anticipated to have a working prototype early next year. |
Support is not yet there but close: LuaJIT/LuaJIT#628
Support is not yet there but close: LuaJIT/LuaJIT#628
Support is not yet there but close: LuaJIT/LuaJIT#628
@infiWang are there any news about your progress? |
The interpreter is generally in good shape, plus FFI w/o callback should function now. Please try it out and let me know how it goes! JIT is mainly still in the works. My patch is experiencing problems with constant (re)materialization during register allocation. I'm afraid trace patching/dispatching is also flawed in some way. Update: FFI issue has been fixed by riscv(interp): reallocate TMP registers to comply with ABI . It's safe to say that we have finished the interpreter and interpreter FFI porting now. |
JIT seems to be working correctly now. Debug information and potential UB's sanitization should be the only things left. |
@infiWang first of all that is awesome news, thanks a lot for all this hard work! I worked on compilers in my past and know how hard it is. I think it will need some heavy testing (I did not see such comprehensive tests in your repo but I suppose this will be published later - esp. some Lua-heavy existing SW which has its own large test suite would be interesting to test with LuaJIT). I have just randomly looked around your repo and it seems the license headers in files are not updated. I think before distributions can start shipping this gem, this should be prepared to not cause any confusion or license issues. Kudos once again! |
All RISC-V related work should be listed here.
The text was updated successfully, but these errors were encountered: