llir / llvm

Library for interacting with LLVM IR in pure Go.
https://llir.github.io/document/
BSD Zero Clause License
1.19k stars 78 forks source link

Is it possible to interact with Go runtime without interpreter? #174

Closed yingfeng closed 3 years ago

yingfeng commented 3 years ago

Similar with this issue, suppose there is an IR generated from other languages, since there does not exist an official Golang interpreter right now, is it possible to interact with go runtime through other mechanism? For example, to build IR into golang shared library or plugin such that it could be dynamically loaded?

mewmew commented 3 years ago

Hi @yingfeng,

As for interpreting Go, I'd very much recommend Yaegi [1], [2]. It supports the full Go language specification and is a production quality interpreter.

When it comes to having LLVM IR generated from other languages interact with LLVM IR of Go (and the Go runtime), I would recommend taking a look at Gollvm [3], the official LLVM-based Go frontend. It should be possible to hook these up to work and interact as you see fit, of course taking careful consideration of calling conventions, memory handling, etc.

Oh, and if you do venture into trying this out, I'd definitely be curious to learn of your experiences and how it went! Even if it did not work, so we get more insight into what works and what doesn't.

Wish you all the best and happy hacking!

Cheerful regards, Robin

yingfeng commented 3 years ago

Thanks a lot for your suggestion !

mewmew commented 3 years ago

Thanks a lot for your suggestion !

Glad to. Remember to report back on how your experiments go :)

yingfeng commented 3 years ago

We plan to provide user defined functions for sql engine, but it's not our current focus right now since we need to deliver the engine itself at first, we might return to this issue several months later. If you are interested in our work, you could ping me through my email :)