make self-contained static binaries for racket applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
haskal f6da2eb731 commit MAJOR elf crimes to invoke ld.so at runtime 1 month ago
scripts commit MAJOR elf crimes to invoke ld.so at runtime 1 month ago
.gitignore add demo of static binary ffi 1 month ago
Makefile commit MAJOR elf crimes to invoke ld.so at runtime 1 month ago
README.md update readme 1 month ago
main_bc.c commit MAJOR elf crimes to invoke ld.so at runtime 1 month ago
run.rkt committing ELF crimes (part 1) 1 month ago
startup.c commit MAJOR elf crimes to invoke ld.so at runtime 1 month ago

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