4 ms·
Can one man really make a C compiler in one week that can compile linux, sqlite, etc.? Maybe I'm underestimating the simplicity of the C language, but that doe
by sebzim4500 9mo ago
Can one man really make a C compiler in one week that can compile linux, sqlite, etc.?
Maybe I'm underestimating the simplicity of the C language, but that doesn't sound very plausible to me.
- dmitrygr 9mo agoyes, if you do not care to optimize, yes. source: done it
- Philpax 9mo agoI would love to see the commit log on this.
- dmitrygr 9mo agodid this before i knew how to git, back in college. target was ARMv5
- Philpax 9mo agoGreat. Did your compiler support three different architectures (four, if you include x86 in addition to x86-64) and compile and pass the test suite for all of this software? > Projects that compile and pass their test suites include PostgreSQL (all 237 regression tests), SQLite, QuickJS, zlib, Lua, libsodium, libpng, jq, libjpeg-turbo, mbedTLS, libuv, Redis, libffi, musl, TCC, and DOOM — all using the fully standalone assembler and linker with no external toolchain. Over 150 additional projects have also been built successfully, including FFmpeg (all 7331 FATE checkasm tests on x86-64 and AArch64), GNU coreutils, Busybox, CPython, QEMU, and LuaJIT. Writing a C compiler is not that difficult, I agree. Writing a C compiler that can compile a significant amount of real software across multiple architectures? That's significantly more non-trivial.
- AshamedCaptain 9mo agoFrankly, I think you are exaggerating. My university had a course that required students to build a C compiler that could run the C subset of SPECint (which includes frigging Perl) and this was the usual 3 month class that was not expected to fill in 24h of your time, so I'd say 1 week sounds perfectly reasonable for someone already familiar. Good enough C for a shitton of projects is barely more complicated than writing an assembler, in fact, that is one of C's strong points (which is also the source of most of its weaknesses).
- Philpax 9mo agoI really, really don't think so, but you're welcome to try :-)
- deleted 9mo ago[deleted]
- rustystump 9mo agoImplementing just enough to conform to a language is not as difficult as it seems. Making it fast is hard.