janet-lang / janet

A dynamic language and bytecode vm
https://janet-lang.org
MIT License
3.38k stars 217 forks source link

Support a cosmopolitan target #1322

Closed tionis closed 2 months ago

tionis commented 8 months ago

Supporting a cosmopolitan build target https://github.com/jart/cosmopolitan would be awesome. I'm not sure how complicated to do that would be though with all the ifdefs. Some more information on cosmopolitan:

bakpakin commented 8 months ago

I'm pretty sure jart was one of the people who first got janet to run with cosmopolitan - helps that Janet has a sort of generic "Posix" target built in, but I would imagine it would mostly just work.

tionis commented 8 months ago

Makes sense, as cosmopolitan handles the other platform abstractions. I'll just try to compile the generic posix later with the cosmocc toolchain.

bakpakin commented 8 months ago

I got it working locally - however I needed to turn off IPV6 code and make some Makefile modifications to allow bypassing the shared library step. There also seem to be some extra warnings but otherwise it looks ok.

tionis commented 8 months ago

Should I leave this open then, until the cosmopolitan target supports ipv6 and the build process is documented?

bakpakin commented 8 months ago

I pushed a build changes yesterday, but I wouldn't consider this fixed until CI has a cosmopolitan build in it

tionis commented 8 months ago

The python.com binary allow embedding of pure python libraries in the binary itself, as it's a valid zip file. To add the same feature in Janet, a custom loader could be added to janet.com during the build process.

tecosaur commented 5 months ago

As mentioned in https://github.com/janet-lang/janet/discussions/1363, I'm interested in creating some APE binaries with Janet. @tionis it sounds like you managed to get this working?

tionis commented 5 months ago

You should be able to compile the cosmopolitan target with a working cosmopolitan environment to get a Janet APE executable. But anything else is not supported at the moment. I'd like to fix it up, but I'm not that well versed in C and got other projects with higher priority, so I don't know if/when I'll look into it again.