Fork me on GitHub
#graalvm
<
2023-12-05
>
Ingy döt Net14:12:09

I made a github release of YAMLScript's ys binary https://github.com/yaml/yamlscript/releases/tag/0.1.20 and wrote about it here: https://yamlscript.org/posts/advent-2023/dec-05/ One of the readers had a problem running it:

$ ys-install/bin/ys --version
ys-install/bin/ys: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ys-install/bin/ys)
ys-install/bin/ys: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ys-install/bin/ys)
and said: > ldd --version > ldd (GNU libc) 2.31 > opensuse leap is not always current on libs and kernels > ugh, that glibc I have on this machine is old, and this is the latest stable release of opensuse He can build ys (`make build`) on that machine fine.

borkdude15:12:34

If you build a dynamic binary it will depend on the glibc on the machine you build it on

borkdude15:12:57

For this reason I choose to build it on an image which has a low as possible glibc such that most users will have it

borkdude15:12:25

And also defaulting to static (using musl) helps preventing problems like this

borkdude15:12:44

See the bb build for how this is put together

Ingy döt Net15:12:10

Thanks! What are the downsides of static?

borkdude15:12:54

I see more positives to static than downsides since the behavior is more predictable, but one downside is that the included libs aren't always up to date and not upgradable in case of security issues

1
Ingy döt Net15:12:20

I think I'll go the static route for now as it seems easier to accomplish. https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/ is good info.

borkdude15:12:04

there is once caveat that I will warn you for up-front: the standard musl binary via graalvm has a too small stack size

borkdude15:12:15

the workaround I apply in all my binaries to to start the main function in a thread

borkdude15:12:21

check out this code: https://github.com/babashka/babashka/blob/fc19382b5e433dfaeb2c29f8e71dbf4e458fc39d/src/babashka/main.clj#L1194-L1212 and all related environment variable usage in the bb project and you should be good to go

❤️ 2
borkdude15:12:02

also note that aarch64 does not support fully static, so it's almost static there "except glibc"

borkdude15:12:36

and for "mostly" static it matters to use a low glibc version since that's the only dynamic part

borkdude15:12:18

this is how I ensure that 2.31 is used and not a newer one

Ingy döt Net15:12:08

Awesome. Thanks (again) for all the help @U04V15CAJ

👍 2
timo13:12:18

perfect intro into that matter