[graalvm-dev] How to use compiled source GraalVM to run a java program?

Fabio Niephaus lists at fniephaus.com
Sun Mar 22 01:50:25 PDT 2020


On Sun, Mar 22, 2020 at 9:25 AM Ofir Gordon <ofirg6 at gmail.com> wrote:
>
> Thank you for your answer!
>
> When running mx --env ce graalvm-home I'm getting the following error message:
>  "Could not find a JDK
> The following JDKs are available:
>   /usr/java/jdk-12.0.2
>   /usr/java/openjdk1.8.0_242-jvmci-20.0-b02
> Specify one with the --java-home or --extra-java-homes option or with the JAVA_HOME or EXTRA_JAVA_HOMES environment variable."

Oh no, that's an mx error. You need to run `mx --env ce graalvm-home`
inside the graal/vm directory. If that doesn't work, try this: `mx
--env ce --java-home /usr/java/openjdk1.8.0_242-jvmci-20.0-b02
graalvm-home`.

>
> The two jdks specified in the message are jdks that I downloaded, not the product of the graalvm compilation.
>
> What does it mean build a custom JVMCI-enabled OpenJDK? I cloned the graal project from here: https://urldefense.com/v3/__https://github.com/oracle/graal__;!!GqivPVa7Brio!KJa_hWe9qiE_ti2xh5V1PHX_cmK3yU3_O20bl0cNarsG4IIIiAm7iMiTgcjL6anjmtaPkQ$ 
> and built the source code in it, under graal/vm.
> Isn't this the JVM source code? Did I build the wrong code? What am I missing here?

Disclaimer: I'm not on the GraalVM team, and my understanding of this
process may not always be accurate.

When you build a GraalVM, it copies over most of the JVMCI-enabled
JVM's components (incl. GC). So the JVM you use to build GraalVM is
basically a template for the resulting GraalVM. In your case, that
would be /usr/java/openjdk1.8.0_242-jvmci-20.0-b02. The build process
compiles and installs the Graal compiler as well as some other
GraalVM-specific components.

The graal-jvmci-8 repo [1] let's you build your own OpenJDK with JVMCI
support, which mx accepts as a GraalVM template. So that's where you
have to look for the JVM sources if you want to modify one of the GCs.

Hope the above makes sense!

Fabio

[1] https://urldefense.com/v3/__https://github.com/graalvm/graal-jvmci-8__;!!GqivPVa7Brio!KJa_hWe9qiE_ti2xh5V1PHX_cmK3yU3_O20bl0cNarsG4IIIiAm7iMiTgcjL6amFP7yObA$ 

>
> Again thank you for your help,
> Ofir
>
>
> ‫בתאריך יום א׳, 22 במרץ 2020 ב-1:22 מאת ‪Fabio Niephaus‬‏ <‪lists at fniephaus.com‬‏>:‬
>>
>> Hi Ofir,
>>
>> On Sat, 21 Mar 2020 at 10:19 pm, Ofir Gordon <ofirg6 at gmail.com> wrote:
>>>
>>> Hello,
>>> I hope this is the right place to ask this question,
>>>
>>> I built the GraalVM jvm code from the project repository, using the following instructions. I think it completed successfully (didn't see any error messages), and it created a new folder graal\vm\mxbuild with what seems to be the compilation product.
>>>
>>> My question is, how do I use the compiled JVM to run a java program? usually I would expect some java execution file, but I can't find any.
>>
>> If you ran mx --env ce build to build it, mx --env ce graalvm-home should print the path to your custom built GraalVM home. This should contain the usual bin/ directory with the java binary you are looking for.
>>>
>>> My goal is to eventually change the jvm code in order to test the behavior of the GC, so if there is a differnt way to do it with the graalvm source code I'll appreciate your instructions.
>>
>> The JVM has lots of GC flags. But if that's not enough and you want to change the actual implementation of one of the GCs, I think you'd need to build a custom JVMCI-enabled OpenJDK (see [1]) with your patches and use that to build a GraalVM.
>>
>> Hope this helps!
>>
>> Fabio
>>
>> [1] https://urldefense.com/v3/__https://github.com/graalvm/graal-jvmci-8__;!!GqivPVa7Brio!KJa_hWe9qiE_ti2xh5V1PHX_cmK3yU3_O20bl0cNarsG4IIIiAm7iMiTgcjL6amFP7yObA$ 
>>
>>
>>> Thanks in advance,
>>>
>>> Ofir
>>>
>>> _______________________________________________
>>> GraalVM-Dev mailing list
>>> GraalVM-Dev at oss.oracle.com
>>> https://oss.oracle.com/mailman/listinfo/graalvm-dev



More information about the GraalVM-Dev mailing list