1*9880d681SAndroid Build Coastguard WorkerThis directory contains LLVM bindings for the Go programming language 2*9880d681SAndroid Build Coastguard Worker(http://golang.org). 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard WorkerPrerequisites 5*9880d681SAndroid Build Coastguard Worker------------- 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Worker* Go 1.2+. 8*9880d681SAndroid Build Coastguard Worker* CMake (to build LLVM). 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard WorkerUsing the bindings 11*9880d681SAndroid Build Coastguard Worker------------------ 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard WorkerThe package path "llvm.org/llvm/bindings/go/llvm" can be used to 14*9880d681SAndroid Build Coastguard Workerimport the latest development version of LLVM from SVN. Paths such as 15*9880d681SAndroid Build Coastguard Worker"llvm.org/llvm.v36/bindings/go/llvm" refer to released versions of LLVM. 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard WorkerIt is recommended to use the "-d" flag with "go get" to download the 18*9880d681SAndroid Build Coastguard Workerpackage or a dependency, as an additional step is required to build LLVM 19*9880d681SAndroid Build Coastguard Worker(see "Building LLVM" below). 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard WorkerBuilding LLVM 22*9880d681SAndroid Build Coastguard Worker------------- 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard WorkerThe script "build.sh" in this directory can be used to build LLVM and prepare 25*9880d681SAndroid Build Coastguard Workerit to be used by the bindings. If you receive an error message from "go build" 26*9880d681SAndroid Build Coastguard Workerlike this: 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker ./analysis.go:4:84: fatal error: llvm-c/Analysis.h: No such file or directory 29*9880d681SAndroid Build Coastguard Worker #include <llvm-c/Analysis.h> // If you are getting an error here read bindings/go/README.txt 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Workeror like this: 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Worker ./llvm_dep.go:5: undefined: run_build_sh 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Workerit means that LLVM needs to be built or updated by running the script. 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Worker $ $GOPATH/src/llvm.org/llvm/bindings/go/build.sh 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard WorkerAny command line arguments supplied to the script are passed to LLVM's CMake 40*9880d681SAndroid Build Coastguard Workerbuild system. A good set of arguments to use during development are: 41*9880d681SAndroid Build Coastguard Worker 42*9880d681SAndroid Build Coastguard Worker $ $GOPATH/src/llvm.org/llvm/bindings/go/build.sh -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD=host -DBUILD_SHARED_LIBS=ON 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard WorkerNote that CMake keeps a cache of build settings so once you have built 45*9880d681SAndroid Build Coastguard WorkerLLVM there is no need to pass these arguments again after updating. 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard WorkerAlternatively, you can build LLVM yourself, but you must then set the 48*9880d681SAndroid Build Coastguard WorkerCGO_CPPFLAGS, CGO_CXXFLAGS and CGO_LDFLAGS environment variables: 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Worker $ export CGO_CPPFLAGS="`/path/to/llvm-build/bin/llvm-config --cppflags`" 51*9880d681SAndroid Build Coastguard Worker $ export CGO_CXXFLAGS=-std=c++11 52*9880d681SAndroid Build Coastguard Worker $ export CGO_LDFLAGS="`/path/to/llvm-build/bin/llvm-config --ldflags --libs --system-libs all`" 53*9880d681SAndroid Build Coastguard Worker $ go build -tags byollvm 54