-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·71 lines (58 loc) · 1.41 KB
/
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
#!/bin/bash
set -uex
root=$PWD
date +%s > build-start-time
if [ "${TRAVIS:-}" = true ]
then
time_limit=2650
else
time_limit=36000
fi
ccache --zero-stats
# Increase cache size from default of 500MB because clang is big
ccache --max-size=1G
ccache --show-stats
function build_time {
echo $(($(date +%s) - $(cat $root/build-start-time)))
}
export CC=clang-$LLVM_VERSION
export CXX=clang++-$LLVM_VERSION
llvm_dir=/usr/lib/llvm-$LLVM_VERSION/lib/cmake/llvm
test -f "$llvm_dir/LLVMConfig.cmake"
git clone --depth 1 --branch release/${LLVM_VERSION}.x \
https://github.com/llvm/llvm-project.git
cd llvm-project
cd clang/tools
ln -s ../../clang-tools-extra extra
cd ../..
patch -p1 < ../plugin-support.patch
patch -p1 < ../clang-tidy-scripts.patch
cd clang
mkdir build
cd build
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_EXE_LINKER_FLAGS="-rdynamic -fuse-ld=lld" \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_TARGETS_TO_BUILD="" \
-DCLANG_ENABLE_ARCMT=OFF \
-DLLVM_DIR="$llvm_dir" \
..
# -DCLANG_ENABLE_STATIC_ANALYZER=OFF \
#cat CMakeCache.txt
parallel=$(($(nproc) + 1))
# Loop over targets so we can abort when aproaching the 50 minute Travis time
# limit
while read targets
do
time=$(build_time)
if [ "$time" -gt "$time_limit" ]
then
echo "Stopping build; running out of time"
break
fi
make -j$parallel $targets
done < $root/targets
ccache --show-stats
cd $root