Fork me on GitHub
#graalvm
<
2021-07-11
>
bocaj20:07:06

Hi! I’m trying to build a command-line tool for non clojure using colleagues (or not yet 🙂 ). We need to run on linux (centos and ubuntu). I’ve used this docker image to create the native image.

# Dockerfile 
FROM 
WORKDIR /opt/graalvm
RUN gu install native-image
ENTRYPOINT ["native-image"] # // building the image
# docker build -t graalvm-native-image .
and using Babashka to run this task.
native-image-linux {:depends [uberjar]
                      :task (do
                              (def native-image-cmd
                                (str/join " "
                                          ["docker" "run" "--rm"
                                           "-v"
                                           (str (cd) "/:/opt/cp")
                                           "-v"
                                           (str (cd) "/:/opt/graalvm")
                                           "graalvm-native-image"
                                           ;; "-J-Xmx3g"
                                           ;; "-R:MaxHeapSize=3.5g"
                                           "-H:Name=dataloader"
                                           "-H:+ReportExceptionStackTraces"
                                           "-jar" "dataloader.jar"
                                           "pdrdataloader-linux"
                                           "--initialize-at-build-time"
                                           "--no-fallback"
                                           "--no-server"]))
                              (println "running: " native-image-cmd)
                              (shell native-image-cmd))}
Reaching out for help, because when I run the image on graalvm-ce docker image above, I get “missing file” errror.
bash-5.1# ldd /opt/cp/pdrdataloader-linux
	/lib64/ld-linux-x86-64.so.2 (0x7f3c92756000)
	libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f3c92756000)
	libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f3c92756000)
	libz.so.1 => /lib/libz.so.1 (0x7f3c9273c000)
	librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7f3c92756000)
	libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f3c92756000)
Error relocating /opt/cp/pdrdataloader-linux: __strdup: symbol not found

borkdude20:07:23

@bocaj Is this a question or just an informative statement? ;)

bocaj20:07:49

Oops, hit the wrong keys, updating now

bocaj20:07:04

Broadly looking for help on how to debug this type of issue

borkdude20:07:00

What distribution is this base image based upon? I usually use ubuntu

borkdude20:07:34

Does centos have glibc?

bocaj20:07:06

I was just trying to round-trip the docker image that I used to build the native image

bocaj20:07:29

but maybe native image builds without have the libs required to run it

borkdude20:07:37

" I get “missing file” errror."

borkdude20:07:41

can you be more specific?

borkdude21:07:54

I usually see such a message when I build a dynamic image and run it on a system that doesn't have glibc

borkdude21:07:21

so you could either try a static (muslc) based build or try running the image in ubuntu (or centos)

bocaj15:07:51

Update: I built on Ubuntu 20.10 and run great. When I run on “oracle linux” (compatible with centos), I get a nice error “/lib64/libc.so.6: version `GLIBC_2.32' not found (required by /opt/cp/pdrdataloader-linux~ubuntu)”

bocaj21:07:36

ok, Thanks for pointing me in a direction. I’ll look through your CI configuration for more help as well. Is there a project of yours that has a simple CI build or docker? I’d prefer to build on my laptop for simplicity

borkdude21:07:33

yes, e.g. babashka or clj-kondo

borkdude21:07:17

what I usually do is run in ubuntu (in CI), then download graalvm via curl, etc. then build. and then copy the image into a docker image (to provide docker images with the binary in it, but this is optional)

👍 2