5 comments

  • kelsey98765431 3 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
    • fuhsnn 1 hour ago
      Don't understand why you were downvoted. An untested C compiler is simply worthless.
  • _ache_ 1 hour ago
    I'm tempted to execute it, but it may as well be shellcode I couldn't tell.
  • 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

    • t-3 6 minutes 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.
    • angry_octet 3 hours ago
      I can't think of a reason to use c89cc.sh, but I salute this effort nonetheless.
    • jonahx 6 minutes ago
      gorgeous!
  • jey 2 hours ago
    It targets x86-64/ELF? I thought it would target `sh` to be portable?
  • dmitrygr 3 hours ago
    Many parts of this are clearly autogenerated, but that in no way diminishes the sickening impressiveness of it!
    • userbinator 2 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.
    • phire 2 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.

      • fuhsnn 1 hour ago
        > It does make it a little hard to understand

        Or much easier to backdoor...