I made some progresses
Hello, First of all, thanks a lot for this repo! Without it, I wouldn't have known where to start.
I resurrected it in a fork and managed to compile a working version of ripgrep and dog.
All my findings are detailed here: https://blog.crisidev.org/tags/series-one-bin-to-rule-them-all/
After I have cleaned up a bunch of things, I'll release all the forks I needed to patch to make it work.
Awesome work!
From previous experiments, I believe https://github.com/ahgamut/rust-ape-example/issues/3 is still a relevant issue (and the linked blog post agrees with that view). Is there a repo or CI result somewhere where we can see the APE binaries running on Windows / MacOS?
Also, submit a PR!
In the first post of the serie, you can download the result executable (with a big disclaimer that you should run them in a VM and don't trust me 😉)
I had to fork a bunch of things and I still have to cleanup the libc and stdlib patches needed to reproduce this.
I hope to have some time to do this over the week and post the results here..
And yes, I believe #3 stands correct because most of the patches are about making constants extern to allow the linker to fish them out of Cosmo libc.
I have created a MR (#7) with the changes required to the example to work on recent rust nightly, while I cleanup the repo that is able to build dog and ripgrep
Repository with the repro: https://github.com/crisidev/ape-rs
CI/CD is set to run on tags and generate releases with rg, dog, xh and probe.
Nice! Have you gone through @io12's work here? That was the most recent attempt I knew of before this.
Nice! Have you gone through @io12's work here? That was the most recent attempt I knew of before this.
I haven't, thanks a lot, it's so cool.
Wonderful job! I also gave it a try a long time ago. I managed to make synchronous HTTPS requests using ureq + rustls (["ring", "std", "tls12"]) on Linux x86_64/aarch64, Windows and MacOS (Have not test on other platforms).
If I remember correctly, I only ran into two annoyances:
ringcompiles some code, and the editor would complain that the current toolchain is not a valid target triple. I had to rename the toolchain to an existing<arch>-unknown-linux-musl(which didn't seem to have any side effects).ringdepends onlibc, and you need to patch quite a few constants that differ across platforms (I saw this mentioned in your blog post as well).
Oh, one more thing — I also hit a nasty pitfall on aarch64 Linux. The program would occasionally crash at runtime. It turned out that cosmocc reserves the x28 register for TLS (thread-local storage), but the Rust compiler happily uses x28 as a general-purpose callee-saved register in the code it generates, so the value gets clobbered unexpectedly. In the end I had to tell the compiler to reserve that register. https://github.com/jart/cosmopolitan/issues/1416