ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
35.24k stars 2.57k forks source link

translate-c: implement translation of GCC inline assembly #18537

Open Ivan-Velickovic opened 10 months ago

Ivan-Velickovic commented 10 months ago

Zig's translate-c command/functionality is currently unable to translate inline assembly, resulting in the following message when attempting to do so: TODO implement translation of stmt class GCCAsmStmtClass.

I think it's okay to make these TODOs as tracking issues on GitHub, please close the issue if I am wrong.

For context, I want this functionality so I can translate the seL4 microkernel's C API for use from Zig code. The current process for getting it working is somewhat manual and so being able to have the API auto-translated would be great.

f-cozzocrea commented 10 months ago

Thanks for the tracking issue. I've actually been thinking about adding this, but I'm not sure how difficult it is. I'll take a look over the next week or so.

f-cozzocrea commented 10 months ago

The main problem with handling this in translate-c is that asm isn't well supported by the language right now. Intel syntax isn't supported due to buggy behaviour in LLVM, and input/output constraints are considered unstable (according to the current docs).

It probably makes more sense to pursue this functionality when asm statements are at a happier place in zig.

Related issue #215.

Ivan-Velickovic commented 10 months ago

Fair enough. Probably a good idea to wait than to have a partially working implementation in the mean-time.

Thanks for looking into it.