babashka 2026-11-03

It came to my attention that the nix version of babashka doesn't statically link libffi. This means that babashka.ffi will work, but not to the full extent that it will in the "normal" distribution of babashka. Is there anyone in this channel that is involved with bb on nix that has an interest in fixing this?

👀 1

Claude thinks we need to use "-EBABASHKA_FEATURE_LIBFFI", add something to -H:NativeLinkerOption=... , and also add BABASHKA_FEATURE_LIBFFI=true to the environment. Does that sound correct? I'm surprised that all three are needed

yes, all three

1

Funny, I pushed back, and Claude decided I didn't need the env var. Do you have any recommendations for testing, other than bb describe?

just look at bb's own build, it uses all three of these

👍 1

a test: let me think

$ bb describe | grep libffi
 :libffi/version     "3.8.0"

$ bb -e "(require '[babashka.ffi :refer [defcfn]]) (defcfn c-printf \"printf\" [:string :&] :int) (c-printf \"%s: %.0f\n\" \"count\" 42.0)"
count: 42

maybe test the last example against the current nix version too

to see if it fails

❯ bb -e "(require '[babashka.ffi :refer [defcfn]]) (defcfn c-printf \"printf\" [:string :&] :int) (c-printf \"%s: %.0f\n\" \"count\" 42.0)"
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  babashka.ffi: unsupported signature: printf [:string :&] -> :int. a variadic call in a native image goes through libffi, and this build has none. Workaround: call through libffi (examples/libffi.clj shows how). Please report this signature in a babashka issue; it can likely be supported.

❯ /nix/store/0vxslx4f65g5mj76mq5s8vjcrmxy6mha-babashka-1.13.226/bin/bb -e "(require '[babashka.ffi :refer [defcfn]]) (defcfn c-printf \"printf\" [:string :&] :int) (c-printf \"%s: %.0f\n\" \"count\" 42.0)"
count: 42
10

🎉 1

what's the second?

The second is with the fixes

great work

1

@borkdude the Cheshire maintainers kindly merged a change to bump the jackson version to address some CVEs; is there any chance you could update to cheshire 6.2.1 in the next Babashka release? cf https://github.com/dakrone/cheshire/pull/255