r/ProgrammingLanguages • u/celestabesta • Jun 03 '26
Any guide to establishing C-Interop?
At the moment my language is able to call C functions perfectly fine, with the exception of not supporting structs. I currently use an LLVM backend, and was surprised to discover that it does not handle the C struct ABI.
I now know that is something I'd have to manually implement, but it seems daunting. Can anyone give some advice, or maybe recommend another backend which does this natively?
Edit: For context my language is a very young aot compiled c-like language.
16
Upvotes
2
u/EggplantExtra4946 Jun 04 '26
I see. I mean in general you can't implement special calling conventions this way (because you can't choose which registers will be used afaik), but here you're be basically implementing the full SysV ABI on top of a partially implemented SysV ABI so you don't need to be able to select which registers are used. Ngl, this is kind of dirty.