2020-10-13 08:37:53 +00:00
|
|
|
# racket-static
|
|
|
|
|
|
|
|
a base set of scripts that let you build fully self-contained static binaries for racket
|
2020-10-14 22:52:09 +00:00
|
|
|
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
|
2020-10-13 08:37:53 +00:00
|
|
|
|
|
|
|
## dependencies
|
|
|
|
|
|
|
|
- systemd-nspawn (containers!)
|
|
|
|
- sudo (for running the above)
|
|
|
|
- rsync (copying files into container)
|
|
|
|
- wget (downloading stuff)
|
|
|
|
|
2020-10-14 22:52:09 +00:00
|
|
|
## 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
|
|
|
|
|
2020-10-13 08:37:53 +00:00
|
|
|
## 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>
|