Re:Self-contained Linux applications with lone Lisp
by regularfry on Tuesday January 23, 2024 @02:49AM
(#39100633)
If you're happy with a compile and link step, you can embed arbitrary data at link time with an ordinary linker by making yourself a linkable object with objcopy(1). I've played with it in the past as a way to embed an sqlite database into a ruby interpreter, which lets you do funky things like reimplementing `require` to read from the embedded database.
[ Parent
| on HN ]
Re:Self-contained Linux applications with lone Lisp
by electroly on Tuesday January 23, 2024 @02:58AM
(#39100678)
It's a possibility. It's not unreasonable for me to ship builds of objcopy and lld that I can run at embed time. An immediate difficulty is that I support Windows and macOS, so I need a solution for PE and Mach-O executables too. I think a solution probably exists but I may need a separate solution for each platform. Embedding resources into binaries is pretty easy, it's just a matter of how to do it without shipping an entire C toolchain to users of my language.
Re:Self-contained Linux applications with lone Lisp
by regularfry on Tuesday January 23, 2024 @05:38AM
(#39101708)
I suspect the easier thing to do today is actually just embed tcc, and use its linker. Generating a C source file that embeds whatever binary you want in a string literal is straightforward templating. I couldn't really do that at the time.
Re:Self-contained Linux applications with lone Lisp
by electroly on Tuesday January 23, 2024 @10:23AM
(#39104576)
That's a great idea. I'll have to check and see if some fork of tcc today supports all my target platforms, but I bet it does.
Re:Self-contained Linux applications with lone Lisp
by zokier on Tuesday January 23, 2024 @09:48AM
(#39104002)
would using libbfd or llvms objcopy library be of use here? https://llvm.org/doxygen/namespacellvm_1_1objcopy.html