graalvm

John 2023-10-16T17:18:08.256159Z

so, my -main sets up logging (timbre) and nrepl. i'm trying to generate a native image. I get all sorts of complaints about Ipv4 being in the heap and so on. I know there are a lot of knobs, but I'm not sure what's the proper way to go about it. I've seen many guides and consulted babashka source code and all of it makes it seem to me that things should 'just work' in this case. I'm specially confused about many guides incentivizing :aot :all which doesn't seem to be the way for a complex project with java deps. any pointers are appreciated

borkdude 2023-10-16T17:47:05.934959Z

avoid :aot :all but write :aot [your.main-namespace]

borkdude 2023-10-16T17:47:28.438909Z

why do you need nrepl in a native image?

borkdude 2023-10-16T17:47:47.753159Z

try with the least amount of deps first, find out what works and incrementally add stuff

John 2023-10-16T17:52:52.605749Z

> why nrepl just expected it to work, for debugging happiness same thing kinda goes with the core of my app though. for example com.slack.api being initialized and starting threads and etc. and then graalvm complains, rightly so. i feel like im missing a trick somewhere

John 2023-10-16T17:53:25.977759Z

just tried --features=clj_easy.graal_build_time.InitClojureClasses but still

borkdude 2023-10-16T17:53:58.828949Z

nrepl needs eval , this won't work in a native image

borkdude 2023-10-16T17:54:36.761009Z

you need to avoid top level values that start threads, you can wrap those in a delay

John 2023-10-16T17:55:03.240269Z

^ tried that, though i wrapped that in an immediate (force)

John 2023-10-16T17:56:05.362489Z

when I read about avoiding toplevel prior, I expected to have to avoid things outside defn's for example

borkdude 2023-10-16T17:56:24.958389Z

> though i wrapped that in an immediate (force) that defeats the whole purpose of delaying

John 2023-10-16T17:57:34.451169Z

building without it now

John 2023-10-18T12:45:27.982969Z

got far then stumbled on some runtime issues but the approach in my case seems to be: • clj easy • only my namespace on aot • my actual main being guarded with a property org.graalvm.nativeimage.imagecode != buildtime • --strict-image-heap

John 2023-10-18T12:46:57.998869Z

the third point might be covered by delay but i didnt make sense of how to wait for the execution when actually running the app