graalvm

grounded_sage 2022-05-22T07:40:47.788589Z

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

phronmophobic 2022-05-22T08:02:38.648079Z

You can use the static methods on the ImageInfo class, https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/ImageInfo.html

phronmophobic 2022-05-22T08:06:49.562089Z

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_sage 2022-05-22T08:12:22.526169Z

Oh yea the different code paths when building Jar makes sense

borkdude 2022-05-22T09:00:13.615559Z

@grounded_sage You can check system properties for this.

borkdude 2022-05-22T09:02:12.783209Z

https://stackoverflow.com/a/50291759/6264

borkdude 2022-05-22T09:03:35.739579Z

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_sage 2022-05-22T09:03:50.108829Z

Found that this does not appear to be working when working on Datahike stack. https://github.com/replikativ/superv.async/blob/5c1ac415b9642e5fb53dccca939dd1a9d44b76ad/src/superv/async.cljc#L101

grounded_sage 2022-05-22T09:04:46.587569Z

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

grounded_sage 2022-05-22T09:06:07.340919Z

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

👍 1