Run passes and linking issue

80 views
Skip to first unread message

Mohsen

unread,
Feb 2, 2017, 4:47:34 AM2/2/17
to llgo-dev
Hi all,

I'm trying to run some passes on my go applications. By digging in some other threads I could manage some steps, here is how far I got:

First, I use llgo to emit bitcode:

llgo -S -emit-llvm source.go -o source.bc

Then, I run my pass using opt command:

opt -load libPass.so source.bc -pass -o source.pass

Running the source.pass using lli throws
'main' function not found in module.

I believe this is a linking issue, so my question is what should I link with the binary and how?

Thanks!

Mohsen

Andrew Wilkins

unread,
Feb 3, 2017, 1:48:52 AM2/3/17
to llgo...@googlegroups.com
Hi Mohsen,

You should be able to use clang to compile the .bc file to .o, and then link the .o file using llgo. However, it looks like llgo is emitting something invalid now, because I'm seeing:

/tmp/main.ll:17:51: error: invalid type for global variable
@__go_type_hash_empty_interface = external global i64 (i8*, i64)

I don't have time to dig into this right now. If you do, please report back and/or send a patch.

Cheers,
Andrew
 
Thanks!

Mohsen

--
You received this message because you are subscribed to the Google Groups "llgo-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to llgo-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

t.j.a....@gmail.com

unread,
Nov 14, 2017, 7:13:52 AM11/14/17
to llgo-dev
Hi all,

this is exaclty what I am trying to do. creating bitcode to then run passes on it. When I run

llgo -S -emit-llvm source.go -o source.bc

and then use llc or opt or any program to process the .bc file I get the error mentioned by Andrew.
Could you find any solution to the problem?

Best,
Tobias

Reply all
Reply to author
Forward
0 new messages