C89cc.sh – standalone C89/ELF64 compiler in pure portable shell
100 points
1 day ago
| 6 comments
| gist.github.com
| HN
kelsey98765431
4 hours 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
reply
fuhsnn
3 hours ago
[-]
Don't understand why you were downvoted. An untested C compiler is simply worthless.
reply
nananana9
1 hour ago
[-]
The 2026 brain simply cannot comprehend recreational programming.
reply
fuhsnn
46 minutes ago
[-]
Well, I happen to have been recreationally maintaining a hobbyist C compiler for three years, adding tests is part of the fun.
reply
JackSmith_YC
36 minutes ago
[-]
Pure shell. Love the minimalism here... especially when every tiny CLI tool these days seems to require a 50MB node_modules folder just to run. There’s a certain Zen in doing things with zero dependencies. Reminds me of why I got into Unix in the first place.
reply
_ache_
3 hours ago
[-]
I'm tempted to execute it, but it may as well be shellcode I couldn't tell.
reply
jey
4 hours ago
[-]
It targets x86-64/ELF? I thought it would target `sh` to be portable?
reply
gaigalas
1 day ago
[-]
Single standalone file, no external tools used, PATH='' (empty), portable (bash, dash, ksh, zsh), produces x86 ELF executables, has mini-libc builtin.

Usage:

printf 'int main(){puts("hello");return 0;}' | sh c89cc.sh > hello

chmod +x hello

./hello

reply
angry_octet
4 hours ago
[-]
I can't think of a reason to use c89cc.sh, but I salute this effort nonetheless.
reply
t-3
1 hour ago
[-]
Why not POSIX or some common external tools where it makes sense? Most of those big switch statements could be easily replaced with some standard programs that already exist everywhere.
reply
jonahx
1 hour ago
[-]
gorgeous!
reply
dmitrygr
4 hours ago
[-]
Many parts of this are clearly autogenerated, but that in no way diminishes the sickening impressiveness of it!
reply
userbinator
3 hours ago
[-]
It would be far more interesting to look at what this was "compiled" from; it looks like the output of a state-machine generator.
reply
phire
4 hours ago
[-]
It does make it a little hard to understand how the parser/ast_builder works.

But the rest seems easy enough to understand.

reply
fuhsnn
3 hours ago
[-]
> It does make it a little hard to understand

Or much easier to backdoor...

reply