LoginSignup
5
0

More than 5 years have passed since last update.

GoでLLVMバインディングを使えるようにしたときのメモ

Last updated at Posted at 2018-12-31

はじめに

Macで、Go言語のLLVMバインディングを使おうとしたときに、かなり手間取ったのでメモ。
あくまで自分の環境向けなので、他の人の役にたつかは不明。

準備

環境変数LDFLAGSに/usr/local/includeなどがセットされていると、

ld: can't map file, errno=22 file '/usr/local/include' for architecture x86_64

みたいなエラーが起きるときがあるのでLDFLAGSをクリアしておく(自己責任ででお願いします)。

$ unset LDFLAGS

ダウンロード

$ release=RELEASE_601
$ svn co https://llvm.org/svn/llvm-project/llvm/tags/$release/final $GOPATH/src/llvm.org/llvm

どのバージョンのLLVMを使うかによって、releaseの値を変える。
存在するバージョンはhttps://llvm.org/svn/llvm-project/llvm/tags/を見るとわかる。

CMakeLists.txt

$GOPATH/src/llvm.org/llvm/CMakeLists.txt で、 /usr/local/include が含まれている行をコメントアウトしておく。

ld: can't map file, errno=22 file '/usr/local/include' for architecture x86_64というエラーが出たりしたので念のため。

Build

$ cd $GOPATH/src/llvm.org/llvm/bindings/go
$ ./build.sh
$ go install llvm.org/llvm/bindings/go/llvm

ビルドには時間がかかるので覚悟しておく。

参考

Go言語で利用するLLVM入門
ld: can't map file, errno=22 file '/usr/local/opt/libffi/lib' for architecture x86_64 #1133

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0