Zig: Additional backend to generate C code

Created on 25 Nov 2019  路  9Comments  路  Source: ziglang/zig

I would like to known the position of the zig team on a C backend in addition to LLVM.

I known that not a lot of people will need such a backend, it's a very specific need which mostly target embedded system using custom architecture and C compiler. It's still the only missing step to stuck out from C, which would be very cool 馃憤

Thank you and keep the good work

accepted proposal stage2

Most helpful comment

The closer the output is to human readable C, the better. For me it's like an insurance policy for the bus factor problem. The llvm to C translators aren't the best from that perspective.

All 9 comments

I see it as one of many desirable targets. It's not provided by LLVM so this would be something provided by an alternate backend.

There is one by the Julia team (resurrected llvm C backend) but not very usable on a work basis, and it's tied to llvm, which I don't see as a good solution.
Since it's desirable I will start thinking about it, I'm open to any advice for where to start, I'm still very unfamiliar with the Zig compiler

I don't think this project is startable yet; there are too many unfinished prerequisites.

  • self-hosted compiler (#89)
  • support for alternative backends besides LLVM in the self-hosted compiler

Ok I will be patient then, thank you for enlightenment and quick answers :ok_hand:

The closer the output is to human readable C, the better. For me it's like an insurance policy for the bus factor problem. The llvm to C translators aren't the best from that perspective.

Duplicate of #5107, closing

Thanks - I had forgotten about this one. Let's keep the earlier one.

One note here is that once we are shipping self-hosted as the main zig compiler, we can remove LLVM from the bootstrapping process by having the stage1 zig compiler emit C code rather than LLVM IR. That is a separate issue however, since this issue is for self-hosted.

This is now part of stage2, and further improvements can be their own issues.

Was this page helpful?
0 / 5 - 0 ratings