2 ms·
I've been dying to play with cosmopolitan for a while while working on a micro-Lisp and another interpreted language that I've been designing for a while. Imag
by sph 3y ago
I've been dying to play with cosmopolitan for a while while working on a micro-Lisp and another interpreted language that I've been designing for a while.
Imagine writing an interpreter that's compiled with cosmopolitan, you bundle it with your program source code, and bam! your script runs pretty much everywhere, even on bare metal. How cool is that? I could distribute my apps written in my niche Lisp to anyone, without having to write a JIT, or incorporate LLVM, or asking them to download and compile my interpreter from github. Here's a binary, just run it (if you trust me :)
To me it's mind blowing, and I have enormous respect for the work of Justine and her collaborators.
- matheusmoreira 3y ago> a micro-Lisp and another interpreted language that I've been designing for a while > bundle it with your program source code, and bam! your script runs pretty much everywhere > How cool is that? Extremely cool! I've got a small lisp too and cosmopolitan inspired me to work on similar stuff. Seems I'm not alone. While cosmopolitan's PKZIP support is impressive, I've been perfecting an alternative method to embedding source code inside the lisp interpreter executable that's more tightly integrated. Cosmopolitan libc opens the executable and reads the data from the filesystem. I want the data to already be mapped in before execution even starts. I only target Linux so I get to take full advantage of the ELF format: concatenate the data to the ELF and add a PT_LOAD segment for it so that Linux loads it onto memory automatically. So far my work has resulted in a new feature being added to the mold linker and and a couple stackoverflow questions. Just submitted a pull request to the patchelf utility too. Once it's working, I'll write an article about it and submit it here.
- sph 3y ago> concatenate the data to the ELF and add a PT_LOAD segment for it so that Linux loads it onto memory automatically I was reading Justine's Github profile, and there was a mention of POSIX systems natively supporting shebang programs made of binary + appended data out of the box. I don't remember the specifics, might be worth investigating how that works exactly.
- matheusmoreira 3y agoYeah, she actually got that feature standardized. Apparently it's a binary version of the feature used in those self-extracting installer .run scripts. I finished the embedded segment loading feature by the way. I'm writing that article as promised but if you'd like to check it out ahead of time: https://github.com/lone-lang/lone/blob/master/source/tools/lone-embed.c https://github.com/lone-lang/lone/blob/master/source/tools/l... https://github.com/lone-lang/lone/blob/master/source/lone/auxiliary_vector.c https://github.com/lone-lang/lone/blob/master/source/lone/au... https://github.com/lone-lang/lone/blob/master/source/lone/segment.c https://github.com/lone-lang/lone/blob/master/source/lone/se... https://github.com/lone-lang/lone/blob/master/source/lone/modules/embedded.c https://github.com/lone-lang/lone/blob/master/source/lone/mo...