blob: 26ee8efb3d7ed50b5de3364f13cec565b42f8376 (
plain) (
blame)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
#!/bin/bash -x
set -ev
STAGE="$1"
DIR="$(cd "$(dirname "$0")" && pwd)"
source "${DIR}/common-defaults.sh"
if [[ "${LLVM_VERSION_SHORT}" == "" ]]; then
echo "LLVM_VERSION_SHORT not set"
exit 1
fi
if [[ "${BASE}" == "" ]]; then
echo "BASE not set"
exit 1
fi
# Install packages if possible
if [[ "${PACKAGED}x" == "1x" ]]; then
apt update
apt install -y llvm-${LLVM_VERSION} llvm-${LLVM_VERSION}-dev
apt install -y clang-${LLVM_VERSION}
exit 0
fi
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
LLVM_BASE="${BASE}/llvm-${LLVM_VERSION_SHORT}"
# Checkout LLVM code
svn co http://llvm.org/svn/llvm-project/llvm/branches/release_${LLVM_VERSION_SHORT} "${LLVM_BASE}"
cd "${LLVM_BASE}/tools"
svn co http://llvm.org/svn/llvm-project/cfe/branches/release_${LLVM_VERSION_SHORT} clang
cd "${LLVM_BASE}/projects"
svn co http://llvm.org/svn/llvm-project/compiler-rt/branches/release_${LLVM_VERSION_SHORT} compiler-rt
if [[ ${LLVM_VERSION_SHORT} -gt 37 ]]; then
cd "${LLVM_BASE}/projects"
svn co http://llvm.org/svn/llvm-project/libcxx/branches/release_${LLVM_VERSION_SHORT} libcxx
cd "${LLVM_BASE}/projects"
svn co http://llvm.org/svn/llvm-project/libcxxabi/branches/release_${LLVM_VERSION_SHORT} libcxxabi
fi
# Apply existing patches if needed
if [ -f "${BASE}/scripts/build/llvm${LLVM_VERSION_SHORT}.patch" ]; then
cd "${LLVM_BASE}"
patch -p0 -i "${BASE}/scripts/build/llvm${LLVM_VERSION_SHORT}.patch"
fi
fi
# For memory sanitizer, we have a multi-stage build process
if [[ "${SANITIZER_BUILD}" == "memory" ]]; then
if [[ ${LLVM_VERSION_SHORT} -le 37 ]]; then
echo "Memory sanitizer builds for <= LLVM 3.7 are not supported"
exit 1
fi
# Build uninstrumented compiler
mkdir "${SANITIZER_LLVM_UNINSTRUMENTED}"
cd "${SANITIZER_LLVM_UNINSTRUMENTED}"
cmake -GNinja -DCMAKE_BUILD_TYPE=Release "${LLVM_BASE}"
ninja
# Build instrumented libc/libc++
mkdir "${SANITIZER_LLVM_LIBCXX}"
cd "${SANITIZER_LLVM_LIBCXX}"
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
${SANITIZER_CMAKE_C_COMPILER} \
${SANITIZER_CMAKE_CXX_COMPILER} \
"${LLVM_BASE}"
ninja cxx cxxabi
# Build instrumented clang
mkdir "${LLVM_BUILD}"
cd "${LLVM_BUILD}"
cmake -GNinja \
${SANITIZER_CMAKE_C_COMPILER} \
${SANITIZER_CMAKE_CXX_COMPILER} \
-DCMAKE_C_FLAGS="$SANITIZER_C_FLAGS" \
-DCMAKE_CXX_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
-DLLVM_ENABLE_LIBCXX=ON \
-DCMAKE_EXE_LINKER_FLAGS="$SANITIZER_LD_FLAGS" \
-DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL}" \
"${LLVM_BASE}"
# Build clang as a dependency and install all needed packages
ninja clang
ninja install-clang install-llvm-config install-llvm-objdump \
install-llvm-link install-llvm-ar install-llvm-nm install-llvm-dis \
install-clang-headers install-llvm-as installhdrs install-LLVMX86Disassembler \
install-LLVMX86AsmParser install-LLVMX86CodeGen install-LLVMSelectionDAG \
install-LLVMAsmPrinter install-LLVMX86Desc install-LLVMMCDisassembler \
install-LLVMX86Info install-LLVMX86AsmPrinter install-LLVMX86Utils \
install-LLVMMCJIT install-LLVMExecutionEngine install-LLVMRuntimeDyld \
install-LLVMipo install-LLVMVectorize install-LLVMLinker install-LLVMIRReader \
install-LLVMAsmParser install-LLVMCodeGen install-LLVMTarget install-LLVMScalarOpts \
install-LLVMInstCombine install-LLVMInstrumentation install-LLVMProfileData \
install-LLVMObject install-LLVMMCParser install-LLVMTransformUtils install-LLVMMC \
install-LLVMAnalysis install-LLVMBitWriter install-LLVMBitReader install-LLVMCore \
install-llvm-symbolizer install-LLVMSupport install-lli not FileCheck
cp "${LLVM_BUILD}/bin/FileCheck" "${LLVM_INSTALL}/bin/"
cp "${LLVM_BUILD}/bin/not" "${LLVM_INSTALL}/bin/"
exit 0
fi
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
# Configure; build; and install
mkdir -p "${LLVM_BUILD}"
cd "${LLVM_BUILD}"
# Skip building if already finished
if [[ -e "${LLVM_BUILD}/.build_finished" ]]; then
exit 0
fi
# Configure LLVM
if [[ ${LLVM_VERSION_SHORT} -le 37 ]]; then
CONFIG=(--enable-jit --prefix="${LLVM_INSTALL}")
if [[ "${ENABLE_OPTIMIZED}" == "1" ]]; then
CONFIG+=(--enable-optimized)
else
CONFIG+=(--disable-optimized)
fi
if [[ "${DISABLE_ASSERTIONS}" == "1" ]]; then
CONFIG+=(--disable-assertions)
else
CONFIG+=(--enable-assertions)
fi
if [[ "${ENABLE_DEBUG}" == "1" ]]; then
CONFIG+=(--enable-debug-runtime --enable-debug-symbols)
else
CONFIG+=(--disable-debug-symbols)
fi
CC=${CC} CXX=${CXX} CFLAGS="${LLVM_CFLAGS}" CXXFLAGS="${LLVM_CXXFLAGS}" LDFLAGS="${LLVM_LDFLAGS}" "${LLVM_BASE}/configure" "${CONFIG[@]}"
else
CONFIG=(-DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL}")
# cmake build
if [[ "${ENABLE_OPTIMIZED}" == "1" && "${ENABLE_DEBUG}" != "1" ]]; then
CONFIG+=(-DCMAKE_BUILD_TYPE=Release)
fi
if [[ "${ENABLE_OPTIMIZED}" == "1" && "${ENABLE_DEBUG}" == "1" ]]; then
CONFIG+=(-DCMAKE_BUILD_TYPE=RelWithDebInfo)
fi
if [[ "${ENABLE_OPTIMIZED}" != "1" && "${ENABLE_DEBUG}" == "1" ]]; then
CONFIG+=(-DCMAKE_BUILD_TYPE=Debug)
fi
if [[ "${DISABLE_ASSERTIONS}" == "1" ]]; then
CONFIG+=(-DLLVM_ENABLE_ASSERTIONS=Off)
else
CONFIG+=(-DLLVM_ENABLE_ASSERTIONS=On)
fi
if [[ ! -z "${LLVM_CFLAGS}" ]] ; then
CONFIG+=(-DCMAKE_C_FLAGS="$LLVM_CFLAGS")
fi
if [[ ! -z "${LLVM_CXXFLAGS}" ]] ; then
CONFIG+=(-DCMAKE_CXX_FLAGS="$LLVM_CXXFLAGS")
fi
if [[ ! -z "${LLVM_LDFLAGS}" ]]; then
LDFLAGS="${LLVM_LDFLAGS}"
fi
cmake "${CONFIG[@]}" "${LLVM_BASE}"
fi
make -j$(nproc)
make install
touch "${LLVM_BUILD}/.build_finished"
cp "${LLVM_BUILD_BIN}/FileCheck" "${LLVM_INSTALL}/bin/"
cp "${LLVM_BUILD_BIN}/not" "${LLVM_INSTALL}/bin/"
if [[ "${KEEP_BUILD}x" != "1x" ]]; then
rm -rf "${LLVM_BUILD}"
fi
if [[ "${KEEP_SRC}x" != "1x" ]]; then
rm -rf "${LLVM_BASE}"
fi
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
# We use our own local cache if possible
set +e
brew install "$HOME"/Library/Caches/Homebrew/llvm\@${LLVM_VERSION}*.bottle.tar.gz
RES=$?
set -ev
if [ ${RES} -ne 0 ]; then
# This might build the llvm package use a time out to avoid dumping log information
brew install -v --build-bottle "llvm@${LLVM_VERSION}"
# Now bottle the brew
brew bottle llvm\@${LLVM_VERSION}
# Not make sure it's cached
cp llvm\@${LLVM_VERSION}*.bottle.tar.gz $HOME/Library/Caches/Homebrew/
fi
else
echo "Unhandled TRAVIS_OS_NAME \"${TRAVIS_OS_NAME}\""
exit 1
fi
|