make self-contained static binaries for racket applications
Go to file
xenia 9da497d10b update readme 2020-10-14 18:52:09 -04:00
scripts initial commit 2020-10-13 04:40:00 -04:00
.gitignore add demo of static binary ffi 2020-10-14 18:17:24 -04:00
Makefile update embedding launcher to cooperate with 3m GC 2020-10-14 17:33:50 -04:00
README.md update readme 2020-10-14 18:52:09 -04:00
main_bc.c add demo of static binary ffi 2020-10-14 18:17:24 -04:00
run.rkt add demo of static binary ffi 2020-10-14 18:17:24 -04:00

README.md

racket-static

a base set of scripts that let you build fully self-contained static binaries for racket applications

depending on your needs, this can be preferred to the usual raco exe/raco dist because that tooling can generate distribution folders that still depend on dynamic libraries the target system might not have (actually, i was prompted to make this partially by someone running into this exact problem on mastodon). additionally, one single binary can be more convenient to distribute than a whole dist folder structure

dependencies

  • systemd-nspawn (containers!)
  • sudo (for running the above)
  • rsync (copying files into container)
  • wget (downloading stuff)

limitations

because the runtime is hosted in a static binary, dynamic ffi is unavailable (eg, ffi-lib) will not work. the workaround for this currently provided is static ffi, where loading table from static-ffi (a primitive module instatiated by the runtime wrapper) will produce a table of available static ffi functions - the integer pointer will need to be cast to the correct function type but after that it works as expected
further work will automate the generation and loading of static ffi tables, ideally out of C headers using c-utils

currently if the racket code runs into an error it segfaults. i think i have to register a handler for this but idk how the internals work

runtime include paths probably don't work as expected. i have not tested but ideally don't use those yet

hello world demo

first time you run make it'll take a while. be patient. having more cores helps

make
./run

references

https://docs.racket-lang.org/inside/embedding.html