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 RISC-V 64 Support #2341

Open
Avimitin opened this issue Mar 4, 2022 · 8 comments
Open

Add RISC-V 64 Support #2341

Avimitin opened this issue Mar 4, 2022 · 8 comments
Labels
Build Libraries & Interfaces enhancement Enhancement or improvement to existing feature or request

Comments

@Avimitin
Copy link

Avimitin commented Mar 4, 2022

Is your feature request related to a problem? Please describe.
I am trying to build this program on RISC-V 64 Arch Linux platform. And I found that it currently only support x86_64 and i386. I wonder if there are any x86_64 specific code? Or it can just be built without code modification?

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@Avimitin Avimitin added enhancement Enhancement or improvement to existing feature or request untriaged labels Mar 4, 2022
@macrakis
Copy link

macrakis commented Mar 9, 2022

Thanks for your interest in running OpenSearch on RISC-V. Although RISC-V is not explicitly a supported platform, OpenSearch should build and run correctly on any JVM platform, except for a small amount of functionality that depends on native x86 code, notably KNN.

I suggest you go ahead, build it, and try it out. I will close this issue report, but if you run into difficulties, please provide a detailed problem report including version numbers of your JVM and OS.

@anasalkouz
Copy link
Member

Closing this for now. @Avimitin, please feel free to reopen if you faced any issues during the build

@Avimitin
Copy link
Author

Context: building on Linux 5.16.11-arch1-1 (riscv64) QEMU environment, for opensearch version 1.2.4, using java-11-openjdk, gradle 6.6.1.


I actually got problem when building the opensearch. During the build, it reports that can not determine architecture from [riscv64], this error is from Script '/build/opensearch/src/OpenSearch-1.2.4/gradle/runtime-jdk-provision.gradle' line: 33.

I tried to add this line to return the proper system architecture:

--- buildSrc/src/main/java/org/opensearch/gradle/Architecture.java
+++ buildSrc/src/main/java/org/opensearch/gradle/Architecture.java
@@ -40,6 +40,7 @@
     public static Architecture current() {
         final String architecture = System.getProperty("os.arch", "");
         switch (architecture) {
+            case "riscv64":
             case "amd64":
             case "x86_64":
                 return X64;

And I found this error in the new build:

* What went wrong:
Execution failed for task ':plugins:analysis-icu:test'.
> A problem occurred starting process 'command '/build/.gradle/caches/transforms-2/files-2.1/8e4cc3c6a9f53237ac703baa5e202c9b/linux-15.0.1-x64.tar.gz/bin/java''

Is the opensearch trying to download a java executable for current architecture? Is there a build argument to close this behavior and let it choose a executable from target machine?

@dblock
Copy link
Member

dblock commented Mar 10, 2022

Let's reopen this now that we have a clear bug.

I don't have an answer to your question @Avimitin, but add comments to the issue as you make progress!

@dblock dblock reopened this Mar 10, 2022
@dblock dblock changed the title RISC-V 64 Support Add RISC-V 64 Support Mar 10, 2022
@dbwiddis
Copy link
Member

Hi @Avimitin. Not sure if you've made any more progress on this. I spent the last few days looking into this. I was of course able to reproduce the initial failure in the Architecture class but after adding the riscv64 entry as you did, have not been able to reproduce the later error. After making the same architecture change, I was successfully able to build on a GNU Compile Farm RISC-V 64 machine (gcc92).

This report looks identical to the symptoms in #1303 (for a different architecture) which includes some stack traces. The stack traces do not have any OpenSearch code in them; they are entirely Gradle internal code, and share the same Gradle version as you have here, 6.6.1.

The stack trace seems to imply the problem is in Gradle's determining of the appropriate runtime Java version. One of the lines in the stack trace is:

at org.gradle.api.tasks.testing.Test.getJavaVersion(Test.java:266)

This particular line of code was changed in Gradle 6.7.0, in gradle/gradle#14031 which may or may not have any effect on fixing it.

I do think there's a strong possibility that this bug in OpenJ9 may be the root cause of both your issue and #1303, since they share the commonality of non-Hotspot JVMs: eclipse-openj9/openj9#11013

Bottom line:

  • I believe the test failures are associated with a bug in either Gradle or OpenJ9 and may be fixed by using newer versions.
  • Please submit a PR to add the riscv64 option per your change noted above. There's an open PR Add ppc64le architecture #3435 for a similar change on ppc64.

@Avimitin
Copy link
Author

Sorry for the late response. I don't know much about Java Eco-system, so I don't take much time to discover that problem. I am glad that this issue has been fixed. And I will retry building it after the new version is released.

@dbwiddis
Copy link
Member

You can probably rebuild it from source right now by changing the Architecture class as you did in this comment. Just use a newer version of Gradle which should use a newer, non-bugged JVM.

It would be very helpful to know if you run into any other issues.

@dbwiddis dbwiddis removed their assignment Nov 7, 2022
@kxxt
Copy link

kxxt commented Apr 18, 2023

I can build OpenSearch without trouble on riscv64. But the build for plugins failed because an incorrect x86_64 toolchain is downloaded to ~/.gradle/caches/transforms-3/612c119ac6f070061b748e583332b78a/transformed/linux-17.0.6-x64.tar.gz/.

> Task :plugins:discovery-azure-classic:internalClusterTest FAILED

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':plugins:discovery-azure-classic:internalClusterTest'.
> Error while evaluating property 'javaLauncher' of task ':plugins:discovery-azure-classic:internalClusterTest'.
> Failed to calculate the value of task ':plugins:discovery-azure-classic:internalClusterTest' property 'javaLauncher'.
> Toolchain installation '/build/.gradle/caches/transforms-3/612c119ac6f070061b748e583332b78a/transformed/linux-17.0.6-x64.tar.gz' could not be probed: A problem occurred starting process 'command '/build/.gradle/caches/transforms-
3/612c119ac6f070061b748e583332b78a/transformed/linux-17.0.6-x64.tar.gz/bin/java''
file /build/.gradle/caches/transforms-3/612c119ac6f070061b748e583332b78a/transformed/linux-17.0.6-x64.tar.gz/bin/java
/build/.gradle/caches/transforms-3/612c119ac6f070061b748e583332b78a/transformed/linux-17.0.6-x64.tar.gz/bin/java: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, not stripped

I didn't find a way to modify it to make sure riscv64 toolchain get used.

Update: BTW Adoptium doesn't have prebuilt JDK for riscv64. So now I need a way to use the system JDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Libraries & Interfaces enhancement Enhancement or improvement to existing feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants