-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_build.sh
executable file
·109 lines (102 loc) · 3.48 KB
/
local_build.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
set -uex
BIRTH_ARCH=x86_64
BIRTH_OS=linux
CMAKE_BUILD_TYPE=Debug
ROOT_DIR=$(pwd)
LLVM_BASENAME=llvm-$BIRTH_ARCH-$BIRTH_OS-$CMAKE_BUILD_TYPE
INSTALL_DIRECTORY_PATH=$ROOT_DIR/$LLVM_BASENAME
ZSTD_BUILD_DIR=build-zstd
mkdir -p $ZSTD_BUILD_DIR
cd $ZSTD_BUILD_DIR
cmake $ROOT_DIR/zstd -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_ASM_COMPILER=clang -DCMAKE_INSTALL_PREFIX="$INSTALL_DIRECTORY_PATH" -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE
cmake --build . --target install
cd $ROOT_DIR
ZLIB_BUILD_DIR=build-zlib
mkdir -p $ZLIB_BUILD_DIR
cd $ZLIB_BUILD_DIR
cmake $ROOT_DIR/zlib -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_ASM_COMPILER=clang -DCMAKE_INSTALL_PREFIX="$INSTALL_DIRECTORY_PATH" -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE
cmake --build . --target install
cd $ROOT_DIR
case $BIRTH_OS in
windows) OPTIONAL_TRIPLE_ARG="-DLLVM_HOST_TRIPLE=$BIRTH_ARCH";;
*) OPTIONAL_TRIPLE_ARG="";;
esac
LLVM_BUILD_DIR=build-llvm
mkdir -p $LLVM_BUILD_DIR
cd $LLVM_BUILD_DIR
cmake $ROOT_DIR/llvm \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIRECTORY_PATH" \
-DCMAKE_PREFIX_PATH="$INSTALL_DIRECTORY_PATH" \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_ASM_COMPILER=clang \
$OPTIONAL_TRIPLE_ARG \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_LIBPFM=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_OCAMLDOC=OFF \
-DLLVM_ENABLE_PLUGINS=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_Z3_SOLVER=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_BUILD_UTILS=OFF \
-DLLVM_BUILD_TOOLS=OFF \
-DLLVM_INCLUDE_TOOLS=ON \
-DLLVM_INCLUDE_UTILS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
-DLLVM_TOOL_LLVM_LTO2_BUILD=OFF \
-DLLVM_TOOL_LLVM_LTO_BUILD=OFF \
-DLLVM_TOOL_LTO_BUILD=OFF \
-DLLVM_TOOL_REMARKS_SHLIB_BUILD=OFF
cmake --build . --target llvm-config llvm-tblgen install
cd $ROOT_DIR
mkdir -p $INSTALL_DIRECTORY_PATH/bin
cp build-llvm/bin/llvm-config $INSTALL_DIRECTORY_PATH/bin
cp build-llvm/bin/llvm-tblgen $INSTALL_DIRECTORY_PATH/bin
LLD_BASENAME=lld-$BIRTH_ARCH-$BIRTH_OS-$CMAKE_BUILD_TYPE
INSTALL_DIRECTORY_PATH=$ROOT_DIR/$LLD_BASENAME
LLVM_PREFIX=$ROOT_DIR/$LLVM_BASENAME
LLD_BUILD_DIR=build-lld
mkdir -p $LLD_BUILD_DIR
cd $LLD_BUILD_DIR
cmake $ROOT_DIR/lld \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIRECTORY_PATH" \
-DCMAKE_PREFIX_PATH="$LLVM_PREFIX" \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_ASM_COMPILER=clang \
$OPTIONAL_TRIPLE_ARG \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_LIBPFM=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_OCAMLDOC=OFF \
-DLLVM_ENABLE_PLUGINS=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_Z3_SOLVER=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_INCLUDE_UTILS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
-DLLVM_BUILD_UTILS=OFF \
-DLLVM_BUILD_TOOLS=OFF \
-DLLVM_TOOL_LLVM_LTO2_BUILD=OFF \
-DLLVM_TOOL_LLVM_LTO_BUILD=OFF \
-DLLVM_TOOL_LTO_BUILD=OFF \
-DLLVM_TOOL_REMARKS_SHLIB_BUILD=OFF \
-DLLD_BUILD_TOOLS=OFF
cmake --build . --target install
cd $ROOT_DIR