graalvm

Ingy döt Net 2023-12-05T14:35:09.524679Z

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.

borkdude 2023-12-05T15:11:34.524109Z

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

borkdude 2023-12-05T15:11:57.759909Z

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

borkdude 2023-12-05T15:12:25.924919Z

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

borkdude 2023-12-05T15:12:44.696219Z

See the bb build for how this is put together

Ingy döt Net 2023-12-05T15:41:10.219819Z

Thanks! What are the downsides of static?

borkdude 2023-12-05T15:42:54.025169Z

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 Net 2023-12-05T15:50:20.534049Z

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.

borkdude 2023-12-05T15:51:04.638589Z

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

borkdude 2023-12-05T15:51:15.425959Z

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

Ingy döt Net 2023-12-05T15:52:02.373159Z

Cheers!

borkdude 2023-12-05T15:52:21.102309Z

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
borkdude 2023-12-05T15:53:02.342259Z

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

Ingy döt Net 2023-12-05T15:54:47.895519Z

That's the "mostly static" arrangement they talk about in https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/ ?

borkdude 2023-12-05T15:55:06.573059Z

yes

borkdude 2023-12-05T15:55:36.675449Z

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

borkdude 2023-12-05T15:56:18.114109Z

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

Ingy döt Net 2023-12-05T15:58:08.601229Z

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

👍 2
timo 2023-12-14T13:15:18.571229Z

perfect intro into that matter