How to wrap a C compiler and preprocessor, really
78 points
10 days ago
| 1 comment
| humprog.org
| HN
fuhsnn
8 days ago
[-]
I have some experience getting several non-trivial projects to build with a small C compiler [1]. Generally, the more a toolchain resemblance, say GCC, the more GCC specific stuff build scripts will feed to it, this may send you down a rabbit hole of recreating GCC behavior distracting from the intended topic. There are simply too many varying factors in the internal messages between a toolchain's sub-fuctions: versioning, target system, the specific installation's default configuration etc. I have no idea what the author's intended modification are, but it may be actually simpler, and more reliable, to modify a compiler at source level than to provide a drop in injection of a certain stage.

[1] https://github.com/fuhsnn/widcc?tab=readme-ov-file#building-...

reply
NonEUCitizen
8 days ago
[-]
"widcc is based on Rui Ueyama's chibicc"
reply
senkora
8 days ago
[-]
The chibicc commit history is a fun read. It builds up a mostly working C compiler from nothing, adding one small feature on each commit, keeping a working compiler at every step. It really is pleasant and informative to read.
reply