Hello! I recently want to use gollvm to analyse code. However I met a problem after I get the llvm ir whith the instructions shown in gollvm official doc ---- I can not exec the .ll file by lli command
------------------------------------------------------------
zty@zty-server:~/go-projects/src/testfile$ cat hello.go
package main
import "fmt"
func main() {
fmt.Println("hello world!")
return
}
zty@zty-server:~/go-projects/src/testfile$ go build -work -x hello.go 1> transcript_hello.txt 2>&1
zty@zty-server:~/go-projects/src/testfile$ egrep '(WORK=|llvm-goc -c)' transcript_hello.txt
WORK=/tmp/go-build177380678
/usr/local/llvmgo/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-relative-import-path=_/home/zty/go-projects/src/testfile -o $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ ./hello.go $WORK/b001/_gomod_.go
zty@zty-server:~/go-projects/src/testfile$ /usr/local/llvmgo/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=/tmp/go-build177380678=/tmp/go-build -gno-record-gcc-switches -fgo-relative-import-path=_/home/zty/go-projects/src/testfile -o hello.ll -S -emit-llvm -I /tmp/go-build177380678/b001/_importcfgroot_ ./hello.go /tmp/go-build177380678/b001/_gomod_.go
zty@zty-server:~/go-projects/src/testfile$ ls hello.ll
hello.ll
zty@zty-server:~/go-projects/src/testfile$ lli hello.ll
lli: error: 'main' function not found in module.
---------------------------------------------------------------
After I get the hello.ll, I can not exec it by lli command, while for other .ll from c code I can exec it.
And I find that llvm pass can work on this "hello.ll", so what's the reason of it?
--------------------------------- Hello World pass work as normal
zty@zty-server:~/go-projects/src/testfile$ opt -load /home/zty/workarea/llvm-project/build/lib/LLVMHello.so -hello -time-passes < hello.ll > /dev/null
Hello: __go_init_main
Hello: main.main
Hello: main.main..init0
Hello: main.struct.4runtime.gList.2.runtime.n.0int32.5..hash
Hello: main.struct.4runtime.gList.2.runtime.n.0int32.5..eq
Hello: main.struct.4Size.0uint32.2Mallocs.0uint64.2Frees.0uint64.5..hash
Hello: main.struct.4Size.0uint32.2Mallocs.0uint64.2Frees.0uint64.5..eq
===-------------------------------------------------------------------------===
... Pass execution timing report ...
===-------------------------------------------------------------------------===
Total Execution Time: 0.0022 seconds (0.0022 wall clock)
---User Time--- --User+System-- ---Wall Time--- --- Name ---
0.0017 ( 77.3%) 0.0017 ( 77.3%) 0.0017 ( 77.4%) Bitcode Writer
0.0004 ( 18.2%) 0.0004 ( 18.2%) 0.0004 ( 18.1%) Hello World Pass
0.0001 ( 4.4%) 0.0001 ( 4.4%) 0.0001 ( 4.5%) Module Verifier
0.0022 (100.0%) 0.0022 (100.0%) 0.0022 (100.0%) Total
===-------------------------------------------------------------------------===
LLVM IR Parsing
===-------------------------------------------------------------------------===
Total Execution Time: 0.0023 seconds (0.0023 wall clock)
---User Time--- --User+System-- ---Wall Time--- --- Name ---
0.0023 (100.0%) 0.0023 (100.0%) 0.0023 (100.0%) Parse IR
0.0023 (100.0%) 0.0023 (100.0%) 0.0023 (100.0%) Total
--------------------------------