Fork me on GitHub
#graalvm
<
2022-05-22
>
grounded_sage07:05:47

Is there a way to check at build time if you are building a GraalVM native image?

phronmophobic08:05:49

Although you may also want to have different code paths at compile time (eg. building an uber jar). For that, it's common to use System properties. See https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/graal_native.cljhttps://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/graal_native.cljfor an example

grounded_sage08:05:22

Oh yea the different code paths when building Jar makes sense

borkdude09:05:13

@U05095F2K You can check system properties for this.

borkdude09:05:35

So:

(System/getProperty "com.oracle.graalvm.isaot") 
should do the trick and will not couple your program to any of the graalvm specific classes

grounded_sage09:05:46

I'll play with these responses when I am back at computer.

grounded_sage09:05:07

Actually just realised I build the jar and then the native image. So of course it's not there at macro expansion.

👍 1