gollvm: Interpret llvm-goc LLVM-IR with lli

213 views
Skip to first unread message

ars...@gmail.com

unread,
Feb 4, 2020, 8:21:42 AM2/4/20
to golang-nuts
Hello!
I am doing a project in which I need to generate LLVM IR file by use gollvm . but the result that I get can not exec the .ll file by lli command
any suggestion

best wishes

 

Than McIntosh

unread,
Feb 4, 2020, 8:59:14 AM2/4/20
to ars...@gmail.com, golang-nuts
Hello,

You wrote:
>> .. . result that I get can not exec the .ll file by lli command

Go programs depend on the Go runtime and standard library -- you can't really do anything interesting in Go without involving these packages.

Consider a toy program like this: https://play.golang.org/p/MAohLsrz7JQ

When this Go program runs, the Go runtime does a lot of setup work (initializing the scheduler, the garbage collector, etc) before main.main is ever invoked. Then when main.main calls fmt.Println(), there is (again) a lot of runtime involvement needed to carry out the work of printing a message.

When you run "lli" on just a single bitcode file generated from compiling a Go main package with llvm-goc, "lli" can't really do much with it since you aren't also handing off a copy of the go runtime.

Folks have experimented in the past with hacking up the compiler and runtime to get it into a form where it will work with lli, but this is not a supported usage mode for Gollvm at the moment (a good deal more engineering work would be needed, due to the oddities of how "lli" works).

Thanks, Than


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/7bbfcb8f-f488-445d-bd78-0c531cd42b1d%40googlegroups.com.

alsh...@clarkson.edu

unread,
Feb 4, 2020, 9:55:35 AM2/4/20
to golang-nuts
in this case is Only GOLLVM does not allow to go direct to .ll or it is general issue. on the other hand, Is any way or tools that compile/interpret/convert from GO to .LL

best wishes


On Tuesday, February 4, 2020 at 8:59:14 AM UTC-5, Than McIntosh wrote:
Hello,

You wrote:
>> .. . result that I get can not exec the .ll file by lli command

Go programs depend on the Go runtime and standard library -- you can't really do anything interesting in Go without involving these packages.

Consider a toy program like this: https://play.golang.org/p/MAohLsrz7JQ

When this Go program runs, the Go runtime does a lot of setup work (initializing the scheduler, the garbage collector, etc) before main.main is ever invoked. Then when main.main calls fmt.Println(), there is (again) a lot of runtime involvement needed to carry out the work of printing a message.

When you run "lli" on just a single bitcode file generated from compiling a Go main package with llvm-goc, "lli" can't really do much with it since you aren't also handing off a copy of the go runtime.

Folks have experimented in the past with hacking up the compiler and runtime to get it into a form where it will work with lli, but this is not a supported usage mode for Gollvm at the moment (a good deal more engineering work would be needed, due to the oddities of how "lli" works).

Thanks, Than


On Tue, Feb 4, 2020 at 8:21 AM <ars...@gmail.com> wrote:
Hello!
I am doing a project in which I need to generate LLVM IR file by use gollvm . but the result that I get can not exec the .ll file by lli command
any suggestion

best wishes

 

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.

Than McIntosh

unread,
Feb 4, 2020, 12:48:24 PM2/4/20
to alsh...@clarkson.edu, golang-nuts
>>in this case is Only GOLLVM does not allow to go direct to .ll or it is general issue

It's a general issue. Hypothetically if someone were to write another LLVM-IR-producing Go compiler (not gollvm), you would no doubt have the same problem. 

Than


To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f485eb0d-75fd-4578-837a-3bd766d22d70%40googlegroups.com.

ars...@gmail.com

unread,
Feb 4, 2020, 1:55:26 PM2/4/20
to golang-nuts
Thank very much for your response and clarifying this issue

Reply all
Reply to author
Forward
0 new messages