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 Linux RISC-V 64 #890

Merged
merged 2 commits into from
Nov 9, 2023
Merged

Add support for Linux RISC-V 64 #890

merged 2 commits into from
Nov 9, 2023

Conversation

Glavo
Copy link
Contributor

@Glavo Glavo commented May 27, 2023

Most of the work has been completed, and both cross compilation and native compilation can work. I have successfully launched Minecraft on Debian RISC-V 64.

image

Currently, the dependent native libraries are all built by me on my own machine. Next, I need to have LWJGL CI build the native libraries for RISC-V.

Progress:

@Glavo
Copy link
Contributor Author

Glavo commented May 27, 2023

@Spasi

I'm running into a little trouble.

I disabled the bgfx module for RISC-V 64. However, the nanovg module contains a class (NanoVGBGFX) that depends on bgfx. When the bgfx module is disabled, the class cannot be compiled either (because several invokeXXX methods are missing in org.lwjgl.system.JNI).

I guess this is a known thing since I saw in the template that the class is only generated when the bgfx module is enabled (nanovg_bgfx.kt). But unfortunately, unless I run ant clean first and then turn on offline mode before building, the class always appears.

I know that the generator of LWJGL caches generated classes, so I'm guessing the cause of the problem is that the generator doesn't delete classes that shouldn't be there. But I'm not familiar with the generator, so can you take a look at this problem?

@Spasi
Copy link
Member

Spasi commented May 28, 2023

@Glavo That's correct, the generator is not clever enough to delete previously generated code that is no longer needed. Also, ant clean will only clean directories of currently enabled modules.

I've verified that with a fully clean/reset repo and bgfx disabled in config/build-bindings.xml, the NanoVGBGFX class is not generated and LWJGL builds correctly. Just make sure to not use ant hydrate-kotlinc, that will generate everything again. Use ant compile-templates instead (slow, but necessary in this case).

@Glavo
Copy link
Contributor Author

Glavo commented May 28, 2023

@Glavo That's correct, the generator is not clever enough to delete previously generated code that is no longer needed. Also, ant clean will only clean directories of currently enabled modules.

I've verified that with a fully clean/reset repo and bgfx disabled in config/build-bindings.xml, the NanoVGBGFX class is not generated and LWJGL builds correctly. Just make sure to not use ant hydrate-kotlinc, that will generate everything again. Use ant compile-templates instead (slow, but necessary in this case).

I see, thank you.

@Slackadays
Copy link
Contributor

I just spent a few hours working on the same thing, so hopefully I can help progress this PR!

@Slackadays
Copy link
Contributor

Slackadays commented Aug 2, 2023

There is an issue with compiling this on a VisionFive 2 running the Debian image with OpenJDK 19:

javac: nanovg] /home/user/lwjgl3-riscv/lwjgl3-riscv-existing/modules/lwjgl/nanovg/src/generated/java/org/lwjgl/nanovg/NanoVGBGFX.java:72: error: cannot find symbol
[javac: nanovg]         return invokeCPP(_edgeaa, _viewId, _allocator, __functionAddress);
[javac: nanovg]                ^
[javac: nanovg]   symbol:   method invokeCPP(int,short,long,long)
[javac: nanovg]   location: class NanoVGBGFX
[javac: nanovg] /home/user/lwjgl3-riscv/lwjgl3-riscv-existing/modules/lwjgl/nanovg/src/generated/java/org/lwjgl/nanovg/NanoVGBGFX.java:97: error: cannot find symbol
[javac: nanovg]         invokePCV(_ctx, _viewId, __functionAddress);
[javac: nanovg]         ^
[javac: nanovg]   symbol:   method invokePCV(long,short,long)
[javac: nanovg]   location: class NanoVGBGFX
[javac: nanovg] /home/user/lwjgl3-riscv/lwjgl3-riscv-existing/modules/lwjgl/nanovg/src/generated/java/org/lwjgl/nanovg/NanoVGBGFX.java:158: error: cannot find symbol
[javac: nanovg]         invokeCPV(_view_id, _framebuffer, __functionAddress);
[javac: nanovg]         ^
[javac: nanovg]   symbol:   method invokeCPV(short,long,long)
[javac: nanovg]   location: class NanoVGBGFX
[javac: nanovg] /home/user/lwjgl3-riscv/lwjgl3-riscv-existing/modules/lwjgl/nanovg/src/generated/java/org/lwjgl/nanovg/NanoVGBGFX.java:172: error: cannot find symbol
[javac: nanovg]         invokePCV(_ctx, _id, _width, _height, flags, __functionAddress);
[javac: nanovg]         ^
[javac: nanovg]   symbol:   method invokePCV(long,short,int,int,int,long)
[javac: nanovg]   location: class NanoVGBGFX
[javac: nanovg] 4 errors
[javac: nanovg] 1 warning

Looking in my own lwjgl3 fork, it appears that this symbol does exist as just a function declaration. What differences would cause your version to not make this symbol?

Edit: just do ant clean first

@Glavo
Copy link
Contributor Author

Glavo commented Aug 2, 2023

@Slackadays Hey, the problem you encountered was mentioned in the previous conversation. Here is Spasi's reply to this:

That's correct, the generator is not clever enough to delete previously generated code that is no longer needed. Also, ant clean will only clean directories of currently enabled modules.

I've verified that with a fully clean/reset repo and bgfx disabled in config/build-bindings.xml, the NanoVGBGFX class is not generated and LWJGL builds correctly. Just make sure to not use ant hydrate-kotlinc, that will generate everything again. Use ant compile-templates instead (slow, but necessary in this case).

@Slackadays
Copy link
Contributor

I actually just realized that by trying ant clean right after, so I guess that's on me because I'm used to CMake where it handles this kind of thing properly.

@Slackadays
Copy link
Contributor

One more thing: I'm trying to get the tests working, and it looks like rpmalloc was removed specifically for RISC-V in f206273. However, it seems to compile just fine, so is there a specific reason it was disabled?

@Glavo
Copy link
Contributor Author

Glavo commented Aug 2, 2023

One more thing: I'm trying to get the tests working, and it looks like rpmalloc was removed specifically for RISC-V in f206273. However, it seems to compile just fine, so is there a specific reason it was disabled?

Sorry, I forgot why I did this. I will re-review these temporarily disabled modules when the issues blocking this PR are resolved.

@Slackadays
Copy link
Contributor

Slackadays commented Aug 3, 2023

It turns out that there was an issue with rpmalloc which prevented it from properly working on RISC-V. I just made a PR at Glavo#1 that should fix it. Unfortunately, the tests hang at OpenCL probably because the VF2's Imagination drivers are pure junk right now, so that might improve sometime in the future.

@Glavo
Copy link
Contributor Author

Glavo commented Oct 7, 2023

@Spasi There has been no progress on this PR for several months. Can you please take a look at these PRs?

@Glavo
Copy link
Contributor Author

Glavo commented Oct 20, 2023

long wait……

@Slackadays
Copy link
Contributor

@Spasi these PRs let RISC-V become viable for Minecraft and anything else that uses LWJGL

@Glavo
Copy link
Contributor Author

Glavo commented Nov 8, 2023

I'll run some tests right away to see if there are any issues that need to be addressed.

@Glavo
Copy link
Contributor Author

Glavo commented Nov 8, 2023

@Spasi I have successfully built LWJGL on RISC-V platform and it passes all tests. This PR is now pending review.

image

@Glavo
Copy link
Contributor Author

Glavo commented Nov 8, 2023

GitHub Action is working: https://github.com/Glavo/lwjgl3/actions/runs/6803359632

image

@Spasi Spasi merged commit 437a4ad into LWJGL:master Nov 9, 2023
@Spasi
Copy link
Member

Spasi commented Nov 9, 2023

Thank you @Glavo and @Slackadays! The first 3.3.4 snapshot will include riscv64 binaries.

@Glavo Glavo deleted the riscv64 branch November 9, 2023 17:05
@Spasi
Copy link
Member

Spasi commented Nov 10, 2023

@SimonIT it's up, I published it before going to bed and updated https://www.lwjgl.org/customize about an hour ago.

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

Successfully merging this pull request may close these issues.

3 participants