terralang / terra

Terra is a low-level system programming language that is embedded in and meta-programmed by the Lua programming language.
terralang.org
Other
2.71k stars 197 forks source link

question: using Terra to transpile C to Rust/Go #647

Closed DrGo closed 8 months ago

DrGo commented 9 months ago

Has anyone tried to use Terra to transpile a fairly complex c lib to Rust or Go?
What would be the general approach and possible obstacles? I am not familiar with Terra. Thanks,

elliottslaughter commented 9 months ago

Hi,

I think you might have misunderstood Terra.

Terra parses C headers using Clang. We use Clang to generate LLVM IR. So the path looks something like: Clang -> LLVM IR -> machine code.

If you're compiling Terra at the same time, the path is: Terra -> LLVM IR -> machine code.

If you have mixed C/Terra modules, we combine those at the LLVM IR level so that LLVM can optimize them together.

However, if you want to get back to source code, what you're talking about is basically decompiling LLVM IR. There are definitely tools that do that, but Terra is not one of them.

Hope that helps.

DrGo commented 9 months ago

Yes. Very helpful and it makes a lot of sense...