15 comments

[ 2.8 ms ] story [ 36.3 ms ] thread
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

I can't think of a reason to use c89cc.sh, but I salute this effort nonetheless.
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.
Many parts of this are clearly autogenerated, but that in no way diminishes the sickening impressiveness of it!
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
It targets x86-64/ELF? I thought it would target `sh` to be portable?
I'm tempted to execute it, but it may as well be shellcode I couldn't tell.
"Claude please generate me a C compiler in bash"

I mean, today it's possible to generate it in Tcl, Elisp, Windows BAT, Powershell.

The effort is just 1 prompt.

The WHY question is much more important today -- "because I can" no longer makes sense, because we all can do much, much more with minimum effort today than before LLMs.

I am tempted to click the "report abuse" link ;-)
This is vibe coded right?
if one could boostrap tcc with it, then it might be a viable tool.
[flagged]
I love this as a novelty, and it could be useful for bootstrapping a system that’s had a shell cross-compiled to it.

Thinking about this in the context of a job I used to do, security on shared hosting environments, it gives me a bit of a shiver. There are reasons compilers aren’t available to normal users on those.