3 ms·
Would be a lot better if it came with tests. Please do this justice and dont let it rot as a gist, make a real repo and add some docs and at least smoke tests o
by kelsey98765431 6mo ago
Would be a lot better if it came with tests. Please do this justice and dont let it rot as a gist, make a real repo and add some docs and at least smoke tests or some kind. Thanks
- fuhsnn 6mo agoDon't understand why you were downvoted. An untested C compiler is simply worthless.
- nananana9 6mo agoThe 2026 brain simply cannot comprehend recreational programming.
- fuhsnn 6mo agoWell, I happen to have been recreationally maintaining a hobbyist C compiler for three years, adding tests is part of the fun.
- gaigalas 6mo agoYou want to know what kinds of programs it can run, right? Look at this one: https://gist.github.com/alganet/1513d7b6abef5c1a53a324d897c358e0 https://gist.github.com/alganet/1513d7b6abef5c1a53a324d897c3... shell.c is a shell interpreter written for c89cc.sh. It can do the full self-hosting ouroboros: - c89cc.sh can compile shell.c - compiled shell.c via c89cc.sh can run c89cc.sh It's not a full blown battle tested shell interpreter yet, but I'm working on it. This file is part of the bootstrapping setup I'm working on for very early (pre tinyc) bootstrap from source in x64 machines and it is by far the most complicated program c89cc.sh can compile.
- fuhsnn 6mo agoThanks, that actually look like a very solid baseline to start things with. Are you aware of onramp[1]? They use a custom VM to base compiler and shell on, it's extra steps, but could be more flexible long term. [1] https://github.com/ludocode/onramp https://github.com/ludocode/onramp
- ludocode 6mo agoI'm the author of Onramp. Thanks for linking it! One of the VMs I wrote for Onramp is in POSIX shell [1]. This was intended to make C bootstrappable on any POSIX system of any architecture with nothing besides the shell. Unfortunately it's about 100,000x too slow to be useful. It's also at least as complicated as a machine code VM. I've since mostly abandoned the POSIX shell idea. Onramp does have a very simple C89 VM though, and its purpose is for bootstrapping modern C on systems that have only a basic C compiler [2]. So this c89cc.sh could in theory work. I tried it and unfortunately it doesn't quite compile yet (and doesn't give a comprehensible error message either.) Even if it worked, c89cc.sh only compiles to x86_64 ELF, and it's way more complicated than the x86_64 ELF machine code Onramp VM [3]. This has been a bit of a recurring theme with Onramp: anything I've tried to get away from the initial machine code stages ends up being more complicated than handwritten machine code. Still, it's nice to have a lot of different ways to bootstrap. I love seeing projects like this and I'm glad to see more people taking bootstrapping seriously. [1]: https://github.com/ludocode/onramp/blob/develop/platform/vm/sh/vm.sh https://github.com/ludocode/onramp/blob/develop/platform/vm/... [2]: https://github.com/ludocode/onramp/blob/develop/platform/vm/c89/vm.c https://github.com/ludocode/onramp/blob/develop/platform/vm/... [3]: https://github.com/ludocode/onramp/blob/develop/platform/vm/x86_64-linux/vm.ohx https://github.com/ludocode/onramp/blob/develop/platform/vm/...
- gaigalas 6mo agoTook some time to look at onramp, it looks awesome!
- gaigalas 6mo agoThis gist is a concatenation of several shell script modules which form a comprehensive parser library for the portable shell. The main parser and emitter are BFN-generated (that's why they look so mechanical). The BNF parser generator is also written in portable shell (I posted another gist with a preview of it in another thread). All modules have comprehensive tests, but it is still lacking documentation and not ready for prime time!
- akavel 6mo agoIn the classic FLOSS tradition, it would be cool if you might still consider publishing such a "not-ready" repository - some people may (or may not!) be still interested, and also (sorry!) there's the bus factor... But on the other hand, in the classic FLOSS tradition, it's also 100% your decision and you have the full right to do any way you like!