Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional backend to generate C code #3772

Closed
uael opened this issue Nov 25, 2019 · 10 comments
Closed

Additional backend to generate C code #3772

uael opened this issue Nov 25, 2019 · 10 comments
Labels
accepted This proposal is planned. frontend Tokenization, parsing, AstGen, Sema, and Liveness. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@uael
Copy link

uael commented Nov 25, 2019

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

@andrewrk andrewrk added this to the 1.1.0 milestone Nov 25, 2019
@andrewrk
Copy link
Member

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.

@uael
Copy link
Author

uael commented Nov 25, 2019

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

@andrewrk andrewrk added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Nov 25, 2019
@andrewrk
Copy link
Member

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

@uael
Copy link
Author

uael commented Nov 25, 2019

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

@andrewrk andrewrk changed the title Zig position on compiling to C Additional backend to generate C code Nov 26, 2019
@andrewchambers
Copy link

andrewchambers commented Nov 26, 2019

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.

@uael
Copy link
Author

uael commented May 1, 2020

Duplicate of #5107, closing

@uael uael closed this as completed May 1, 2020
@andrewrk andrewrk modified the milestones: 1.1.0, 0.8.0 May 1, 2020
@andrewrk
Copy link
Member

andrewrk commented May 1, 2020

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

@andrewrk andrewrk reopened this May 1, 2020
@andrewrk andrewrk added accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. labels May 1, 2020
@andrewrk
Copy link
Member

andrewrk commented May 1, 2020

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.

@andrewrk
Copy link
Member

andrewrk commented Sep 1, 2020

This is now part of stage2 via the -ofmt=c flag, and further improvements can be their own issues.

@andrewrk andrewrk closed this as completed Sep 1, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.7.0 Sep 1, 2020
@g-berthiaume
Copy link

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.

Thanks for thinking about embedded systems.
Compiling to clean and safe C code would allow Zig to enter the bare-metal firmware ecosystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. frontend Tokenization, parsing, AstGen, Sema, and Liveness. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

4 participants