Total Pageviews

Tuesday, 30 August 2016


LLVM-based compiler for Go.
This project has moved to Any contributions or bug reports should be sent there. Please refer to thellgo readme for more information.
llgo is a Go frontend for LLVM, written in Go.
llgo is under active development. It compiles and passes most of the standard library test suite and a substantial portion of the gc test suite, but there are some corner cases that are known not to be handled correctly yet. Nevertheless it can compile modestly substantial programs (including itself; it is self hosting on x86-64 Linux).
Progress will be reported on the mailing list.


llgo requires:
Note that Ubuntu Precise is one Linux distribution which does not package a sufficiently new CMake or C++ toolchain.
If you built a newer GCC following the linked instructions above, you will need to set the following environment variables before proceeding:
export PATH=/path/to/gcc-inst/bin:$PATH
export LD_LIBRARY_PATH=/path/to/gcc-inst/lib64:$LD_LIBRARY_PATH
export CC=`which gcc`
export CXX=`which g++`
export LIBGO_CFLAGS=--gcc-toolchain=/path/to/gcc-inst
To build and install llgo:
# Ensure $GOPATH is set.
go get -d
cd $GOPATH/src/
make install prefix=/path/to/prefix j=N  # where N is the number of cores on your machine.


We install two binaries to $prefix/bin: llgo and llgo-go.
llgo is the compiler binary. It has a command line interface that is intended to be compatible to a large extent withgccgo.
llgo-go is a command line wrapper for go. It works like the regular go command except that it uses llgo to build.

LLVM bindings for the Go programming language 


This project has moved to Any contributions or bug reports should be sent there. Please refer to the Go bindings readme for more information.
Build Status


  • Go 1.2+.
  • CMake (to build LLVM).
The author has only built and tested with Linux, but there is no particular reason why GoLLVM should not work with other operating systems.

Building LLVM

The development version of GoLLVM is tied to a specific revision of LLVM SVN trunk. We also make releases which are synchronized with LLVM releases. Those releases are available in branches named vMN, where M is the major number of the LLVM release and N is the minor number.
The script update\ in this directory can be used to build the required revision of LLVM and prepare it to be used by GoLLVM. If you receive an error message from go build like this:
./analysis.go:4:84: fatal error: llvm-c/Analysis.h: No such file or directory
 #include <llvm-c/Analysis.h> // If you are getting an error here read
or like this:
./llvm_dep.go:5: undefined: run_update_llvm_sh_to_get_revision_NNNNNN
it means that LLVM needs to be built or updated by running the script.
$ ./
Any command line arguments supplied to the script are passed to LLVM's CMake build system. A good set of arguments to use during development are:
Note that CMake keeps a cache of build settings so once you have built LLVM there is no need to pass these arguments again after updating.
Alternatively, you can build LLVM yourself or use a version provided by your distribution, but you must then set the CGO_CFLAGS and CGO_LDFLAGS environment variables:
$ export CGO_CFLAGS=`llvm-config --cflags`
$ export CGO_LDFLAGS="`llvm-config --ldflags` -Wl,-L`llvm-config --libdir` -lLLVM-`llvm-config --version`"
$ go get -tags byollvm