-
-
Notifications
You must be signed in to change notification settings - Fork 680
Chez+racket: support building with cosmopolitan libc #5004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Tested on linux-amd64 with cosmocc 3.3.10. This patch allows cosmocc to build the main racket distribution as an Actually Portable Executable https://github.com/jart/cosmopolitan?tab=readme-ov-file#cosmopolitan https://cosmo.zip/pub/cosmocc/ With cosmocc unzipped in `/opt/cosmocc` and a `/zip` directory with user read+write, run this script in the repo root to build `racket.com`: ```sh REPO_ROOT=$PWD COSMOCC=/opt/cosmocc MAKE=$COSMOCC/bin/make export CC=$COSMOCC/bin/x86_64-unknown-cosmo-cc export AR=$COSMOCC/bin/x86_64-unknown-cosmo-ar export STRIP=echo export COSMOPOLITAN_DISABLE_ZIPOS=1 $MAKE pb-fetch mkdir racket/src/build || true cd racket/src/build ../configure --prefix=/zip/usr rm -rf /zip/usr || true rm -rf ./dist || true $MAKE -j $MAKE install cp -r /zip ./dist cd ./dist mv ./usr/bin/racket ./ $COSMOCC/bin/fixupobj ./racket $COSMOCC/bin/apelink -o ./racket.zip ./racket zip -r ./racket.zip usr/ cd $REPO_ROOT mv racket/src/build/dist/racket.zip ./racket.com ```
I'm confused about why this particular situation for locating .boot files should be hardcoded. Can using Also, significant parts of base Racket depend on the ffi; for example the ability to use openssl to download packages over HTTPS or use sqlite to manage databases when building code and documentation. Do those work with this set of changes? |
On linux it does ( I don't know if that would be trivial to change, I did see the source in Also note this doesn't touch the behavior of other libc implementations. I am able to get a REPL on Windows 10 and Linux with the built distribution in
I agree that its not particularly ideal, but since the APE image always provides the embedded zip archive, it seems like the most reliable solution for storing the boot images. I could try to work it into the build steps somehow, but I didn't want to disrupt how the existing targets work. Also
Maybe you were referring to a different configure option? As far as I understand, there's no need to use different Chez sources for this to work. It probably would be helpful to at least sketch working some of this into CI/build steps. I'll try what I can, but do let me know if there's anything in particular that would be helpful to look at. |
If you want to build a cross build, you can see the
|
That's a fair point. I do imagine searching for dynamic libraries/filling the ABI gaps would be enough of a challenge on its own to get right, considering how things are currently done with the I can leave this open as a draft, but if there's anyone who would be more interested in getting this to work correctly, they can start from what I have here. I'll try to tidy up the details where I can at least. Thanks for taking a look @samth !
Just for clarity, cosmopolitan provides access to a ZIP archive embedded in the executable, it will retrieve files that are stored in it when you access anything under the |
Based on #5004 by @jjsullivan5196
I merged the Chez Scheme part of this (by syncing with the Chez Scheme commit) and also changed the For the boot-file part, probably there should be a new |
Checklist
Description of change
This patch adds some minimal scaffolding to allow building and running Chez and the Racket main distribution with cosmopolitan libc, affording access to 6 operating systems with a single binary https://github.com/jart/cosmopolitan
The main contents of this patch are a couple of platform checks, and an addition to Racket's bootup procedure such that it can load the start image and packages from an embedded ZIP object store provided by the platform. I know this isn't exactly new in terms of what
raco exe
can do, but it does collapse the amount of binary images needed to ship to different platforms, while taking away ABI variability/build churn.The shell script included in the commit message demonstrates shipping the main distribution as a single binary file, which runs on amd64 Linux, Windows 10, MacOS, NetBSD, OpenBSD, and FreeBSD. These are all covered by the static minimal racket binary built with the cosmopolitan toolchain. aarch64 should also work, though I still need to try it out.
Of course, this isn't all sunshine and rainbows. Cosmo does ship its own implementation of a POSIX ABI to cover most OS interfacing, but Racket assumes a lot about the underlying system from build time (such as it pertains to the foreign interface for instance, getting the gui package to work might be a challenge). I don't want to make outlandish claims of what's possible or worth doing, but I thought this was interesting and useful enough to share with the maintainers. Also where I might not be expert in the details of the platform, @jart or @ahgamut should be able to provide some clarification. I'd be happy to make any changes the authors would prefer of course. I'll also add an accompanying PR to the Chez repo cisco/ChezScheme#837