Live data from Hacker News

Shecc: A self-hosting and educational C optimizing compiler

github.com

1–10 of 23 posts

Re: Shecc: A self-hosting and educational C optimizing compiler

#2
Shecc is a self-compiling compiler for 32-bit Arm and RISC-V architectures, focusing on a subset of the C language and incorporating basic optimization techniques. It generates executable Linux ELF binaries for ARMv7-A and RV32IM and includes a minimal C standard library for GNU/Linux I/O. Written in ANSI C, it is broadly compatible and features an integrated machine code generator, removing the need for external tools. The compiler uses a two-pass process for syntax checking and translating operations into machine code, and has a register allocation system for RISC-style architectures. Additionally, it includes an architecture-independent, SSA-based middle-end for enhanced optimizations.

Re: Shecc: A self-hosting and educational C optimizing compiler

#3
I've been working on a C compiler with the goal of ANSI C compliance, and most of the projects described as a "C compiler" seem to only support an arbitrary subset of C. This project seems to support more than most educational/toy CCs, but I still believe there’s value in implementing full standard C.

Re: Shecc: A self-hosting and educational C optimizing compiler

#5
post #3

I've been working on a C compiler with the goal of ANSI C compliance, and most of the projects described as a "C compiler" seem to only support an arbitrary subset of C. This project seems to support more than most educational/toy CCs, but I still believe there’s value in implementing full standard C.

To me, a useful cutoff would be to define "C compiler" as anything that can compile TCC (the tiny c compiler, that can more-or-less compile the old C versions of GCC).

Maybe it's legitimate to say "TCC must be a single-file amalgam first and you have to use an external preprocessor".

Re: Shecc: A self-hosting and educational C optimizing compiler

#6
post #3

I've been working on a C compiler with the goal of ANSI C compliance, and most of the projects described as a "C compiler" seem to only support an arbitrary subset of C. This project seems to support more than most educational/toy CCs, but I still believe there’s value in implementing full standard C.

What're you thinking of doing with the preprocessor? Accept the complexity and build that too, run a pre-existing one, implement a subset of it, other...

Re: Shecc: A self-hosting and educational C optimizing compiler

#8
post #3

I've been working on a C compiler with the goal of ANSI C compliance, and most of the projects described as a "C compiler" seem to only support an arbitrary subset of C. This project seems to support more than most educational/toy CCs, but I still believe there’s value in implementing full standard C.

What're you thinking of doing with the preprocessor? Accept the complexity and build that too, run a pre-existing one, implement a subset of it, other...

IIRC C preprocessor is not very hard to implement according to the specification if you don't worry too much about performance.

Re: Shecc: A self-hosting and educational C optimizing compiler

#9
I keep vacillating on whether to use Go or Rust for my next cli or desktop tool (eg., for desktop egui in Rust). However, every time I see C or start to write it, I just see in it too much fun. In Go I see boredem, and Rust, frustration.

I'm not writing production software for a large audience, at best tools for myself which a few others might use.

Yet, it also seems a waste to be using what many now regard as out dated tech.

It would be a great thing if a C-2030 could be arranged with a new standard library and a move-semantics compiler mode (say).

Re: Shecc: A self-hosting and educational C optimizing compiler

#10

I keep vacillating on whether to use Go or Rust for my next cli or desktop tool (eg., for desktop egui in Rust). However, every time I see C or start to write it, I just see in it too much fun. In Go I see boredem, and Rust, frustration. I'm not writing production software for a large audience, at best tools for myself which a few others might use. Yet, it also seems a waste to be using what many now regard as out da…

... and arrays that don't decay to pointers. (Which, in my opinion, is C's real million-dollar mistake, not null pointers.)

Oh, and less undefined behaviors.

Post reply on HN