2017年12月4日 星期一

Go binding llvm

Use command
$ go get -d llvm.org/llvm/bindings/go/llvm
to get llvm project
Then
$ cd $GOPATH/src/llvm.org/llvm/bindings/go/llvm 
Then
$ mkdir workdir && cd workdir && mkdir llvm-build
Then go back to dir go/llvm
$ ./build.sh -DCMAKE_BUILD_TYPE=Release
I had installed Ninja, then build script use it to build system.
I am not sure if you didn't install it, can compile or not.(Maybe will invoke make)

After those steps.
You can create a main.go
package main

import (
    "fmt"
    "llvm.org/llvm/bindings/go/llvm"
)

func main() {
    m := llvm.NewModule("hello")
    fmt.Println(m)
}
Then go run the main file.
You will see some LLVM IR
It contains module information.
Thanks for see.

沒有留言:

張貼留言