-
How do I use cosmopolitan c as a replacement for libc outside the cosmo ecoysystem (ie, purely as a dependent library), while also keeping up with changes to it? Long time ago, I used the original APE blog post to download the binaries and setup make to use them, but that was point-in-time and I'm still stuck with that version. Recently, I found this post on the internet which goes one step better by pulling the binaries (as long as a checksum matches) from within the make file. Is this the best way to do it? How can I do the equivalent of "get latest" every time I build my code? Note: I know there are benefits to being inside the cosmo ecosystem, but it feels like an overkill for my small project, hence this question. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
The flagship example for doing this is llamafile, which sets up a monorepo that's built externally by cosmocc. Feel free to use its boilerplate:
The basic idea is you get all your make rules to depend on this target that downloads your toolchain. That target is defined as Your cosmocc toolchain is hosted redundantly via both our GitHub and our cosmo.zip web server, so it's guaranteed reliable for your CI. The downloader script is designed so that it'll failover if one of the servers is down or blocked by your firewall. The versioned artifacts for cosmo also never change, so each time you want to upgrade you just pin the new version with its checksum. I promise to maintain these URLs until the heat death of the universe in service to your projects. |
Beta Was this translation helpful? Give feedback.
-
If you use Bazel then ARM maintains the code for integrating it with Cosmopolitan here: https://gitlab.arm.com/bazel/ape |
Beta Was this translation helpful? Give feedback.
-
For examples of how to get other people's normative open source code to build using cosmocc, see https://justine.lol/cosmo3/#install which gives a few examples. For example, for projects with a simple Makefile like https://github.com/jart/json.cpp it is oftentimes sufficient to say:
For projects that use GNU Autotools, you'll often say something like:
For other people's projects that use cmake, what I might say is:
For our own projects that use cmake, Cristian Adam from Qt team recommends something like:
Finally let's say you want to go really advanced with @ahgamut level build mastery. For complicated projects like Emacs or GCC you might need to switch from using cosmocc (our all-in-one frontend wrapper script) to using the architecture-specific toolchains separately, creating two separate binaries, and then unifying them using the
|
Beta Was this translation helpful? Give feedback.
The flagship example for doing this is llamafile, which sets up a monorepo that's built externally by cosmocc. Feel free to use its boilerplate:
The basic idea is you get all your make rules to depend on this target that downloads your toolchain.
https://github.com/Mozilla-Ocho/llamaf…