LLVM Build

work on ubuntu

1
2
3
4
5
6
7
8
9
10
sudo apt-get install 
cmake \
gcc-4.7-arm-linux-gnueabihf \
gcc-4.7-multilib-arm-linux-gnueabihf \
binutils-arm-linux-gnueabihf \
libgcc1-armhf-cross \
libsfgcc1-armhf-cross \
libstdc++6-armhf-cross \
libstdc++6-4.7-dev-armhf-cross \
# ninja-build (from backports in Ubuntu)
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# http://llvm.org/docs/GettingStarted.html

svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm

cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
# lld linker optional
svn co http://llvm.org/svn/llvm-project/lld/trunk lld
cd -

cd llvm/projects
# Compiler-RT (required to build the sanitizers) [Optional]
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
# Libomp (required for OpenMP support) [Optional]
svn co http://llvm.org/svn/llvm-project/openmp/trunk openmp
# libcxx and libcxxabi [Optional]
svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi
# Test Suite Source Code [Optional]
svn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suite
cd -

mkdir build && cd build

# CC='clang' CXX='clang++'
cmake \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=llvm \
-DCMAKE_CROSSCOMPILING=True \
-DLLVM_BUILD_RUNTIME=Off \
-DLLVM_INCLUDE_TESTS=Off \
-DLLVM_INCLUDE_EXAMPLES=Off \
-DLLVM_ENABLE_BACKTRACES=Off \
-DLLVM_TABLEGEN=llvm-tblgen \
-DCLANG_TABLEGEN=clang-tblgen \
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf \
-DLLVM_TARGET_ARCH=ARM \
-DLLVM_TARGETS_TO_BUILD="ARM;X86" \
../llvm

make
# make install
compile RPI3 執行檔
1
2
3
# http://stackoverflow.com/questions/35295502/clang-cross-compilation-for-arm
sudo apt-get install g++-multilib
clang hello.c --target=arm-linux-gnueabihf-raspbian -o hello

llvm-config –host-target
x86_64-pc-linux-gnu
x86_64-apple-darwin16.4.0

xx