Jan Fan     About     Archive     Feed     中文博客

LLVM

!--more--

Setup Dev Environments

I can’t believe that LLVM tool sets are incomplete in OS X?!

If you gonna use LLVM tools like lli and llc, you need to install them from the source code from scratch or through the pre-compiled packages. Or if you want to install with easy homebrew, it will inform you of this:

This formula is keg-only.
Mac OS X already provides this software and installing another version in parallel can cause all kinds of trouble.

In either ways you are about to have duplicated versions of LLVM in your OS X , which is just intolerant!

Finally I give up on it because I don’t want to mess up my OS X system. I install the complete LLVM tool suites on my Ubuntu system which is running on the VM.

The process is quite simple. Follow the instructions in this post.

To retrieve the archive signature:

$ cd ~/Documents
$ wget -O sig.key http://llvm.org/apt/llvm-snapshot.gpg.key
$ sudo apt-key add sig.key

To install just clang and lldb (3.5 release):

$ sudo apt-get install clang-3.5 lldb-3.5

To install all packages:

$ sudo apt-get install clang-3.5 clang-3.5-doc libclang-common-3.5-dev libclang-3.5-dev libclang1-3.5 libclang1-3.5-dbg libllvm-3.5-ocaml-dev libllvm3.5 libllvm3.5-dbg lldb-3.5 llvm-3.5 llvm-3.5-dev llvm-3.5-doc llvm-3.5-examples llvm-3.5-runtime clang-modernize-3.5 clang-format-3.5 python-clang-3.5 lldb-3.5-dev

Run Your First Program

// in hello.c
#include<stdio.h>

int main() {
    printf("Hello, World.");
    return 0;
}
$ clang-3.5 hello.c -S -emit-llvm
$ lli-3.5 hello.ll

You are gonna see the familiar words on your console.

IR Bytecode

Reference

[4]:

Comments

comments powered by Disqus