graalvm 2024-12-18

Bruno do Nascimento Maciel 2024-12-18T21:26:31.594809Z

Hey folks, I trying to generate a native image for a telegram bot that uses morse (https://github.com/Otann/morse) 🧵

Bruno do Nascimento Maciel 2024-12-18T21:28:52.661269Z

While build the native image I am getting this error related to a Thread being started:

Fatal error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected a started Thread in the image heap. Thread name: clojure.core.async.timers/timeout-daemon. Threads running in the image generator are no longer running at image runtime. Prevent threads from starting during image generation, or a started thread from being included in the image.

Bruno do Nascimento Maciel 2024-12-18T21:36:58.663289Z

but I don't have enough knowledge to circumvent that

that code is ok, but it's not ok to deref that thing on the top level

you could try to compile an example program that has less code and add stuff until it fails, this should give you a clearer picture of what code triggers this

Bruno do Nascimento Maciel 2024-12-18T21:46:09.415679Z

At the top level it is in this line (p/start token bot-api) . I think that I will have to go deep on the library implementation

where is that line, in your project?

Bruno do Nascimento Maciel 2024-12-18T21:50:13.519699Z

it is in a branch from the forked repository graalvm-clojure https://github.com/macielti/graalvm-clojure/blob/add-morse/morse/src/simple/main.clj#L29

Bruno do Nascimento Maciel 2024-12-18T21:50:44.722699Z

I created a draft pull request https://github.com/clj-easy/graalvm-clojure/pull/68

Bruno do Nascimento Maciel 2024-12-18T21:53:40.601579Z

I event tried to use a when to only call the (p/start token bot-api) when the start argument is provided via command line to avoid this being interpreted at the build time. But it did not worked, I am not sure if GraalVM works this way

it's late here but I might check tomorrow time willing

Bruno do Nascimento Maciel 2024-12-18T21:55:30.071949Z

nice, I really appreciate your willingness to help. I will wait.

@brunodonascimentomaci have you figured out this issue in the end? I'm trying to build a native image with morse, and running into the same issue.