Fork me on GitHub
#graalvm
<
2022-02-14
>
Adam Helins08:02:02

I see --initialize-at-build-timewithout args is deprecated. What does it mean exactly for Clojure?

lispyclouds08:02:29

https://github.com/clj-easy/graal-build-time was built to address this specifically 😄

lispyclouds08:02:27

essentially all the relevant classes need to be initialised individually, which is pretty much what lib does

Adam Helins09:02:33

Looks like a fix but I'm having an issue. Prior to using graal-build-time, the image was building fine with --initialize-at-build-time(even with graal 22.0) but would fail at runtime when calling a function that was relying on LazySodium (native lib not found, it's libsodium accessed through JNA). After adding graal-build-time, building the image fails:

Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of com.goterl.lazysodium.LazySodiumJava are allowed in the image heap as this class should be initialized at image runtime.
Kinda makes sense. However, I tried overriding it but it does not change anything. Any clue?! --initialize-at-run-time=com.goterl.lazysodium.LazySodiumJava

lispyclouds09:02:38

Is is the same issue as above, the lib cannot be found?

lispyclouds10:02:12

also theres this https://github.com/oracle/graal/issues/673#issuecomment-583413789 not sure if full JNA support has landed already or not

Adam Helins10:02:00

Ah, good point about JNA, but it sounds like it could work as long as all the JNA stuff is initialized at build time? So no, now it fails with this exception at build time instead of failing at run time with a link error. But I've entered a rabbit hole. I've tried forcing --initialize-at-run-time on consumer of that class and now am seeing dozens of errors, classes from Java libs being "unintentionally initialized at build time" 😅

borkdude10:02:11

@UCFG3SDFV You can add java packages for build time initialization by just adding the prefix

borkdude10:02:28

--initialize-at-build-time=java.pkg

lispyclouds10:02:45

Also are you supplying the the path to the shared lib correctly during the build process? I think it was -H:AdditionalLinkerOptions= or something? akin to passing -l/path/to/shared/lib for gcc

Adam Helins11:02:14

@U04V15CAJ But this is for JVM package, right? Whereas I now see complaints about stuff from Java libs like slf4j @U7ERLH6JX I tried using -Djava.library.pathwhen executing native-image

borkdude11:02:02

What is the difference between JVM package and Java libs?

Adam Helins11:02:10

Sorry, I misunderstood you 🙂