OLD | NEW |
---|---|
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # This script will check out llvm and clang into third_party/llvm and build it. | 6 # This script will check out llvm and clang into third_party/llvm and build it. |
7 | 7 |
8 # Do NOT CHANGE this if you don't know what you're doing -- see | 8 # Do NOT CHANGE this if you don't know what you're doing -- see |
9 # https://code.google.com/p/chromium/wiki/UpdatingClang | 9 # https://code.google.com/p/chromium/wiki/UpdatingClang |
10 # Reverting problematic clang rolls is safe, though. | 10 # Reverting problematic clang rolls is safe, though. |
11 CLANG_REVISION=214024 | 11 CLANG_REVISION=215468 |
12 | 12 |
13 THIS_DIR="$(dirname "${0}")" | 13 THIS_DIR="$(dirname "${0}")" |
14 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" | 14 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" |
15 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" | 15 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build/Release+Asserts" |
16 COMPILER_RT_BUILD_DIR="${LLVM_DIR}/../llvm-build/compiler-rt" | |
16 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" | 17 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" |
17 LLVM_BOOTSTRAP_INSTALL_DIR="${LLVM_DIR}/../llvm-bootstrap-install" | 18 LLVM_BOOTSTRAP_INSTALL_DIR="${LLVM_DIR}/../llvm-bootstrap-install" |
18 CLANG_DIR="${LLVM_DIR}/tools/clang" | 19 CLANG_DIR="${LLVM_DIR}/tools/clang" |
19 CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" | 20 CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" |
20 COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" | 21 COMPILER_RT_DIR="${LLVM_DIR}/compiler-rt" |
21 LIBCXX_DIR="${LLVM_DIR}/projects/libcxx" | 22 LIBCXX_DIR="${LLVM_DIR}/projects/libcxx" |
22 LIBCXXABI_DIR="${LLVM_DIR}/projects/libcxxabi" | 23 LIBCXXABI_DIR="${LLVM_DIR}/projects/libcxxabi" |
23 ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk" | 24 ANDROID_NDK_DIR="${THIS_DIR}/../../../third_party/android_tools/ndk" |
24 STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" | 25 STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" |
25 | 26 |
26 ABS_LIBCXX_DIR="${PWD}/${LIBCXX_DIR}" | 27 ABS_LIBCXX_DIR="${PWD}/${LIBCXX_DIR}" |
27 ABS_LIBCXXABI_DIR="${PWD}/${LIBCXXABI_DIR}" | 28 ABS_LIBCXXABI_DIR="${PWD}/${LIBCXXABI_DIR}" |
29 ABS_LLVM_DIR="${PWD}/${LLVM_DIR}" | |
30 ABS_LLVM_BUILD_DIR="${PWD}/${LLVM_BUILD_DIR}" | |
31 ABS_COMPILER_RT_DIR="${PWD}/${COMPILER_RT_DIR}" | |
28 | 32 |
29 | 33 |
30 # Use both the clang revision and the plugin revisions to test for updates. | 34 # Use both the clang revision and the plugin revisions to test for updates. |
31 BLINKGCPLUGIN_REVISION=\ | 35 BLINKGCPLUGIN_REVISION=\ |
32 $(grep LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \ | 36 $(grep 'set( LIBRARYNAME' "$THIS_DIR"/../blink_gc_plugin/CMakeLists.txt \ |
Nico
2014/08/14 17:30:37
(do cmake files have spaces after set(s, usually)
hans
2014/08/14 19:39:40
There is precedence in some LLVM files for this, b
| |
33 | cut -d '_' -f 2) | 37 | cut -d ' ' -f 3) |
34 CLANG_AND_PLUGINS_REVISION="${CLANG_REVISION}-${BLINKGCPLUGIN_REVISION}" | 38 CLANG_AND_PLUGINS_REVISION="${CLANG_REVISION}-${BLINKGCPLUGIN_REVISION}" |
35 | 39 |
36 # ${A:-a} returns $A if it's set, a else. | 40 # ${A:-a} returns $A if it's set, a else. |
37 LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} | 41 LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} |
38 | 42 |
39 if [[ -z "$GYP_DEFINES" ]]; then | 43 if [[ -z "$GYP_DEFINES" ]]; then |
40 GYP_DEFINES= | 44 GYP_DEFINES= |
41 fi | 45 fi |
42 if [[ -z "$GYP_GENERATORS" ]]; then | 46 if [[ -z "$GYP_GENERATORS" ]]; then |
43 GYP_GENERATORS= | 47 GYP_GENERATORS= |
(...skipping 10 matching lines...) Expand all Loading... | |
54 force_local_build= | 58 force_local_build= |
55 run_tests= | 59 run_tests= |
56 bootstrap= | 60 bootstrap= |
57 with_android=yes | 61 with_android=yes |
58 chrome_tools="plugins blink_gc_plugin" | 62 chrome_tools="plugins blink_gc_plugin" |
59 gcc_toolchain= | 63 gcc_toolchain= |
60 | 64 |
61 if [[ "${OS}" = "Darwin" ]]; then | 65 if [[ "${OS}" = "Darwin" ]]; then |
62 with_android= | 66 with_android= |
63 fi | 67 fi |
64 if [ "${OS}" = "FreeBSD" ]; then | |
65 MAKE=gmake | |
66 else | |
67 MAKE=make | |
68 fi | |
69 | 68 |
70 while [[ $# > 0 ]]; do | 69 while [[ $# > 0 ]]; do |
71 case $1 in | 70 case $1 in |
72 --bootstrap) | 71 --bootstrap) |
73 bootstrap=yes | 72 bootstrap=yes |
74 ;; | 73 ;; |
75 --if-needed) | 74 --if-needed) |
76 if_needed=yes | 75 if_needed=yes |
77 ;; | 76 ;; |
78 --force-local-build) | 77 --force-local-build) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 if which curl > /dev/null; then | 190 if which curl > /dev/null; then |
192 curl -L --fail "${CDS_FULL_URL}" -o "${CDS_OUTPUT}" || \ | 191 curl -L --fail "${CDS_FULL_URL}" -o "${CDS_OUTPUT}" || \ |
193 rm -rf "${CDS_OUT_DIR}" | 192 rm -rf "${CDS_OUT_DIR}" |
194 elif which wget > /dev/null; then | 193 elif which wget > /dev/null; then |
195 wget "${CDS_FULL_URL}" -O "${CDS_OUTPUT}" || rm -rf "${CDS_OUT_DIR}" | 194 wget "${CDS_FULL_URL}" -O "${CDS_OUTPUT}" || rm -rf "${CDS_OUT_DIR}" |
196 else | 195 else |
197 echo "Neither curl nor wget found. Please install one of these." | 196 echo "Neither curl nor wget found. Please install one of these." |
198 exit 1 | 197 exit 1 |
199 fi | 198 fi |
200 if [ -f "${CDS_OUTPUT}" ]; then | 199 if [ -f "${CDS_OUTPUT}" ]; then |
201 rm -rf "${LLVM_BUILD_DIR}/Release+Asserts" | 200 rm -rf "${LLVM_BUILD_DIR}" |
202 mkdir -p "${LLVM_BUILD_DIR}/Release+Asserts" | 201 mkdir -p "${LLVM_BUILD_DIR}" |
203 tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}/Release+Asserts" | 202 tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}" |
204 echo clang "${CLANG_REVISION}" unpacked | 203 echo clang "${CLANG_REVISION}" unpacked |
205 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" | 204 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" |
206 rm -rf "${CDS_OUT_DIR}" | 205 rm -rf "${CDS_OUT_DIR}" |
207 exit 0 | 206 exit 0 |
208 else | 207 else |
209 echo Did not find prebuilt clang at r"${CLANG_REVISION}", building | 208 echo Did not find prebuilt clang at r"${CLANG_REVISION}", building |
210 fi | 209 fi |
211 fi | 210 fi |
212 | 211 |
213 if [[ -n "${with_android}" ]] && ! [[ -d "${ANDROID_NDK_DIR}" ]]; then | 212 if [[ -n "${with_android}" ]] && ! [[ -d "${ANDROID_NDK_DIR}" ]]; then |
214 echo "Android NDK not found at ${ANDROID_NDK_DIR}" | 213 echo "Android NDK not found at ${ANDROID_NDK_DIR}" |
215 echo "The Android NDK is needed to build a Clang whose -fsanitize=address" | 214 echo "The Android NDK is needed to build a Clang whose -fsanitize=address" |
216 echo "works on Android. See " | 215 echo "works on Android. See " |
217 echo "http://code.google.com/p/chromium/wiki/AndroidBuildInstructions for how" | 216 echo "http://code.google.com/p/chromium/wiki/AndroidBuildInstructions for how" |
218 echo "to install the NDK, or pass --without-android." | 217 echo "to install the NDK, or pass --without-android." |
219 exit 1 | 218 exit 1 |
220 fi | 219 fi |
221 | 220 |
221 # Check that cmake and ninja are available. | |
Nico
2014/08/14 17:30:37
Maybe
if ! which cmake > /dev/null; then
echo "
hans
2014/08/14 19:39:40
Done.
| |
222 cmake --version | |
223 ninja --version | |
224 | |
222 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" | 225 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" |
223 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ | 226 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ |
224 "${LLVM_DIR}"; then | 227 "${LLVM_DIR}"; then |
225 echo Checkout failed, retrying | 228 echo Checkout failed, retrying |
226 rm -rf "${LLVM_DIR}" | 229 rm -rf "${LLVM_DIR}" |
227 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" | 230 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" |
228 fi | 231 fi |
229 | 232 |
230 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" | 233 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" |
231 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" | 234 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" |
232 | 235 |
236 # We have changed the compiler_rt, so nuke the old one. | |
Nico
2014/08/14 17:30:36
Why is this needed?
hans
2014/08/14 19:39:40
If there is a stale copy checked out in-tree, it w
| |
237 rm -rf "${LLVM_DIR}/projects/compiler-rt" | |
233 echo Getting compiler-rt r"${CLANG_REVISION}" in "${COMPILER_RT_DIR}" | 238 echo Getting compiler-rt r"${CLANG_REVISION}" in "${COMPILER_RT_DIR}" |
234 svn co --force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \ | 239 svn co --force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \ |
235 "${COMPILER_RT_DIR}" | 240 "${COMPILER_RT_DIR}" |
236 | 241 |
237 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes | 242 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes |
238 # (i.e. this is needed for bootstrap builds). | 243 # (i.e. this is needed for bootstrap builds). |
239 if [ "${OS}" = "Darwin" ]; then | 244 if [ "${OS}" = "Darwin" ]; then |
240 echo Getting libc++ r"${CLANG_REVISION}" in "${LIBCXX_DIR}" | 245 echo Getting libc++ r"${CLANG_REVISION}" in "${LIBCXX_DIR}" |
241 svn co --force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \ | 246 svn co --force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \ |
242 "${LIBCXX_DIR}" | 247 "${LIBCXX_DIR}" |
(...skipping 21 matching lines...) Expand all Loading... | |
264 +// (PR11974) | 269 +// (PR11974) |
265 | 270 |
266 @import Crash; | 271 @import Crash; |
267 EOF | 272 EOF |
268 patch -p4 | 273 patch -p4 |
269 popd | 274 popd |
270 | 275 |
271 # Echo all commands. | 276 # Echo all commands. |
272 set -x | 277 set -x |
273 | 278 |
274 NUM_JOBS=3 | 279 # Set default values for CC and CXX if they're not set in the environment. |
275 if [[ "${OS}" = "Linux" ]]; then | 280 CC=${CC:-cc} |
276 NUM_JOBS="$(grep -c "^processor" /proc/cpuinfo)" | 281 CXX=${CXX:-c++} |
277 elif [ "${OS}" = "Darwin" -o "${OS}" = "FreeBSD" ]; then | |
278 NUM_JOBS="$(sysctl -n hw.ncpu)" | |
279 fi | |
280 | 282 |
281 if [[ -n "${gcc_toolchain}" ]]; then | 283 if [[ -n "${gcc_toolchain}" ]]; then |
282 # Use the specified gcc installation for building. | 284 # Use the specified gcc installation for building. |
283 export CC="$gcc_toolchain/bin/gcc" | 285 CC="$gcc_toolchain/bin/gcc" |
284 export CXX="$gcc_toolchain/bin/g++" | 286 CXX="$gcc_toolchain/bin/g++" |
285 # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap compiler, | 287 # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap compiler, |
286 # etc.) find the .so. | 288 # etc.) find the .so. |
287 export LD_LIBRARY_PATH="$(dirname $(${CXX} -print-file-name=libstdc++.so.6))" | 289 export LD_LIBRARY_PATH="$(dirname $(${CXX} -print-file-name=libstdc++.so.6))" |
288 fi | 290 fi |
289 | 291 |
290 export CFLAGS="" | 292 CFLAGS="" |
291 export CXXFLAGS="" | 293 CXXFLAGS="" |
294 LDFLAGS="" | |
292 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is | 295 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is |
293 # needed, on OS X it requires libc++. clang only automatically links to libc++ | 296 # needed, on OS X it requires libc++. clang only automatically links to libc++ |
294 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on | 297 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on |
295 # OS X versions as old as 10.7. | 298 # OS X versions as old as 10.7. |
296 # TODO(thakis): Some bots are still on 10.6, so for now bundle libc++.dylib. | 299 # TODO(thakis): Some bots are still on 10.6, so for now bundle libc++.dylib. |
297 # Remove this once all bots are on 10.7+, then use --enable-libcpp=yes and | 300 # Remove this once all bots are on 10.7+, then use --enable-libcpp=yes and |
298 # change all MACOSX_DEPLOYMENT_TARGET values to 10.7. | 301 # change all MACOSX_DEPLOYMENT_TARGET values to 10.7. |
299 if [ "${OS}" = "Darwin" ]; then | 302 if [ "${OS}" = "Darwin" ]; then |
300 # When building on 10.9, /usr/include usually doesn't exist, and while | 303 # When building on 10.9, /usr/include usually doesn't exist, and while |
301 # Xcode's clang automatically sets a sysroot, self-built clangs don't. | 304 # Xcode's clang automatically sets a sysroot, self-built clangs don't. |
302 export CFLAGS="-isysroot $(xcrun --show-sdk-path)" | 305 CFLAGS="-isysroot $(xcrun --show-sdk-path)" |
303 export CPPFLAGS="${CFLAGS}" | 306 CPPFLAGS="${CFLAGS}" |
304 export CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLA GS}" | 307 CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLAGS}" |
305 fi | 308 fi |
306 | 309 |
307 # Build bootstrap clang if requested. | 310 # Build bootstrap clang if requested. |
308 if [[ -n "${bootstrap}" ]]; then | 311 if [[ -n "${bootstrap}" ]]; then |
309 ABS_INSTALL_DIR="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}" | 312 ABS_INSTALL_DIR="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}" |
310 echo "Building bootstrap compiler" | 313 echo "Building bootstrap compiler" |
311 mkdir -p "${LLVM_BOOTSTRAP_DIR}" | 314 mkdir -p "${LLVM_BOOTSTRAP_DIR}" |
312 pushd "${LLVM_BOOTSTRAP_DIR}" | 315 pushd "${LLVM_BOOTSTRAP_DIR}" |
313 if [[ ! -f ./config.status ]]; then | 316 |
314 # The bootstrap compiler only needs to be able to build the real compiler, | 317 cmake -GNinja \ |
315 # so it needs no cross-compiler output support. In general, the host | 318 -DCMAKE_BUILD_TYPE=Release \ |
316 # compiler should be as similar to the final compiler as possible, so do | 319 -DLLVM_ENABLE_ASSERTIONS=ON \ |
317 # keep --disable-threads & co. | 320 -DLLVM_TARGETS_TO_BUILD=host \ |
318 ../llvm/configure \ | 321 -DLLVM_ENABLE_THREADS=OFF \ |
319 --enable-optimized \ | 322 -DCMAKE_INSTALL_PREFIX="${ABS_INSTALL_DIR}" \ |
320 --enable-targets=host-only \ | 323 -DCMAKE_C_COMPILER="${CC}" \ |
321 --enable-libedit=no \ | 324 -DCMAKE_CXX_COMPILER="${CXX}" \ |
322 --disable-threads \ | 325 -DCMAKE_C_FLAGS="${CFLAGS}" \ |
323 --disable-pthreads \ | 326 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ |
324 --without-llvmgcc \ | 327 ../llvm |
325 --without-llvmgxx \ | 328 |
326 --prefix="${ABS_INSTALL_DIR}" | 329 ninja |
330 if [[ -n "${run_tests}" ]]; then | |
331 ninja check-all | |
327 fi | 332 fi |
328 | 333 |
329 ${MAKE} -j"${NUM_JOBS}" | 334 ninja install |
330 if [[ -n "${run_tests}" ]]; then | |
331 ${MAKE} check-all | |
332 fi | |
333 | |
334 ${MAKE} install | |
335 if [[ -n "${gcc_toolchain}" ]]; then | 335 if [[ -n "${gcc_toolchain}" ]]; then |
336 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap | 336 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap |
337 # compiler can start. | 337 # compiler can start. |
338 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \ | 338 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \ |
339 "${ABS_INSTALL_DIR}/lib/" | 339 "${ABS_INSTALL_DIR}/lib/" |
340 fi | 340 fi |
341 | 341 |
342 popd | 342 popd |
343 export CC="${ABS_INSTALL_DIR}/bin/clang" | 343 CC="${ABS_INSTALL_DIR}/bin/clang" |
344 export CXX="${ABS_INSTALL_DIR}/bin/clang++" | 344 CXX="${ABS_INSTALL_DIR}/bin/clang++" |
345 | 345 |
346 if [[ -n "${gcc_toolchain}" ]]; then | 346 if [[ -n "${gcc_toolchain}" ]]; then |
347 # Tell the bootstrap compiler to use a specific gcc prefix to search | 347 # Tell the bootstrap compiler to use a specific gcc prefix to search |
348 # for standard library headers and shared object file. | 348 # for standard library headers and shared object file. |
349 export CFLAGS="--gcc-toolchain=${gcc_toolchain}" | 349 CFLAGS="--gcc-toolchain=${gcc_toolchain}" |
350 export CXXFLAGS="--gcc-toolchain=${gcc_toolchain}" | 350 CXXFLAGS="--gcc-toolchain=${gcc_toolchain}" |
351 fi | 351 fi |
352 | 352 |
353 echo "Building final compiler" | 353 echo "Building final compiler" |
354 fi | 354 fi |
355 | 355 |
356 # Build clang (in a separate directory). | 356 # Build clang (in a separate directory). |
357 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, | 357 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, |
358 # so if you change it you also need to change these links. | 358 # so if you change it you also need to change these links. |
359 mkdir -p "${LLVM_BUILD_DIR}" | 359 mkdir -p "${LLVM_BUILD_DIR}" |
360 pushd "${LLVM_BUILD_DIR}" | 360 pushd "${LLVM_BUILD_DIR}" |
(...skipping 17 matching lines...) Expand all Loading... | |
378 | 378 |
379 pushd libcxxbuild | 379 pushd libcxxbuild |
380 ${CC:-cc} libcxx/*.o libcxxabi/*.o -o libc++.1.dylib -dynamiclib \ | 380 ${CC:-cc} libcxx/*.o libcxxabi/*.o -o libc++.1.dylib -dynamiclib \ |
381 -nodefaultlibs -current_version 1 -compatibility_version 1 \ | 381 -nodefaultlibs -current_version 1 -compatibility_version 1 \ |
382 -lSystem -install_name @executable_path/libc++.dylib \ | 382 -lSystem -install_name @executable_path/libc++.dylib \ |
383 -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib/libc++unexp.exp \ | 383 -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib/libc++unexp.exp \ |
384 -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib/notweak.exp \ | 384 -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib/notweak.exp \ |
385 -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib/weak.exp | 385 -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib/weak.exp |
386 ln -sf libc++.1.dylib libc++.dylib | 386 ln -sf libc++.1.dylib libc++.dylib |
387 popd | 387 popd |
388 export LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild" | 388 LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild" |
389 fi | 389 fi |
390 | 390 |
391 if [[ ! -f ./config.status ]]; then | 391 if [[ ! -f ./CMakeCache.txt ]]; then |
392 ../llvm/configure \ | 392 MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \ |
393 --enable-optimized \ | 393 -DCMAKE_BUILD_TYPE=Release \ |
394 --enable-libedit=no \ | 394 -DLLVM_ENABLE_ASSERTIONS=ON \ |
395 --disable-threads \ | 395 -DLLVM_ENABLE_THREADS=OFF \ |
396 --disable-pthreads \ | 396 -DCMAKE_C_COMPILER="${CC}" \ |
397 --without-llvmgcc \ | 397 -DCMAKE_CXX_COMPILER="${CXX}" \ |
398 --without-llvmgxx | 398 -DCMAKE_C_FLAGS="${CFLAGS}" \ |
399 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ | |
400 -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ | |
401 -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ | |
402 "${ABS_LLVM_DIR}" | |
403 env | |
399 fi | 404 fi |
400 | 405 |
401 if [[ -n "${gcc_toolchain}" ]]; then | 406 if [[ -n "${gcc_toolchain}" ]]; then |
402 # Copy in the right stdlibc++.so.6 so clang can start. | 407 # Copy in the right stdlibc++.so.6 so clang can start. |
403 mkdir -p Release+Asserts/lib | 408 mkdir -p lib |
404 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" \ | 409 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" lib/ |
405 Release+Asserts/lib/ | |
406 fi | 410 fi |
407 MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" | 411 |
412 ninja | |
413 | |
408 STRIP_FLAGS= | 414 STRIP_FLAGS= |
409 if [ "${OS}" = "Darwin" ]; then | 415 if [ "${OS}" = "Darwin" ]; then |
410 # See http://crbug.com/256342 | 416 # See http://crbug.com/256342 |
411 STRIP_FLAGS=-x | 417 STRIP_FLAGS=-x |
412 | 418 |
413 cp libcxxbuild/libc++.1.dylib Release+Asserts/bin | 419 cp libcxxbuild/libc++.1.dylib bin/ |
414 fi | 420 fi |
415 strip ${STRIP_FLAGS} Release+Asserts/bin/clang | 421 strip ${STRIP_FLAGS} bin/clang |
422 popd | |
423 | |
424 # Build compiler-rt out-of-tree. | |
425 mkdir -p "${COMPILER_RT_BUILD_DIR}" | |
426 pushd "${COMPILER_RT_BUILD_DIR}" | |
427 | |
428 MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \ | |
429 -DCMAKE_BUILD_TYPE=Release \ | |
430 -DLLVM_ENABLE_ASSERTIONS=ON \ | |
431 -DLLVM_ENABLE_THREADS=OFF \ | |
432 -DCMAKE_C_COMPILER="${CC}" \ | |
433 -DCMAKE_CXX_COMPILER="${CXX}" \ | |
434 -DLLVM_CONFIG_PATH="${ABS_LLVM_BUILD_DIR}/bin/llvm-config" \ | |
435 "${ABS_COMPILER_RT_DIR}" | |
436 | |
437 ninja | |
438 | |
439 # Copy selected output to the main tree. | |
440 # Darwin doesn't support cp --parents, so pipe through tar instead. | |
441 ABS_LLVM_CLANG_LIB_DIR=$(find ${ABS_LLVM_BUILD_DIR}/lib -path '*/clang/3.*.0') | |
442 tar -c *blacklist.txt | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv | |
443 tar -c include/sanitizer | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv | |
444 if [[ "${OS}" = "Darwin" ]]; then | |
445 tar -c lib/darwin | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv | |
446 else | |
447 tar -c lib/linux | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv | |
448 fi | |
449 | |
416 popd | 450 popd |
417 | 451 |
418 if [[ -n "${with_android}" ]]; then | 452 if [[ -n "${with_android}" ]]; then |
419 # Make a standalone Android toolchain. | 453 # Make a standalone Android toolchain. |
420 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ | 454 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ |
421 --platform=android-14 \ | 455 --platform=android-14 \ |
422 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \ | 456 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \ |
423 --system=linux-x86_64 \ | 457 --system=linux-x86_64 \ |
424 --stl=stlport | 458 --stl=stlport |
425 | 459 |
426 # Android NDK r9d copies a broken unwind.h into the toolchain, see | 460 # Android NDK r9d copies a broken unwind.h into the toolchain, see |
427 # http://crbug.com/357890 | 461 # http://crbug.com/357890 |
428 rm -v "${LLVM_BUILD_DIR}"/android-toolchain/include/c++/*/unwind.h | 462 rm -v "${LLVM_BUILD_DIR}"/android-toolchain/include/c++/*/unwind.h |
429 | 463 |
430 # Build ASan runtime for Android. | 464 # Build ASan runtime for Android in a separate build tree. |
431 # Note: LLVM_ANDROID_TOOLCHAIN_DIR is not relative to PWD, but to where we | 465 mkdir -p ${LLVM_BUILD_DIR}/android |
432 # build the runtime, i.e. third_party/llvm/projects/compiler-rt. | 466 pushd ${LLVM_BUILD_DIR}/android |
433 pushd "${LLVM_BUILD_DIR}" | 467 MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \ |
434 ${MAKE} -C tools/clang/runtime/ \ | 468 -DCMAKE_BUILD_TYPE=Release \ |
435 LLVM_ANDROID_TOOLCHAIN_DIR="../../../llvm-build/android-toolchain" | 469 -DLLVM_ENABLE_ASSERTIONS=ON \ |
470 -DLLVM_ENABLE_THREADS=OFF \ | |
471 -DCMAKE_C_COMPILER=${PWD}/../bin/clang \ | |
472 -DCMAKE_CXX_COMPILER=${PWD}/../bin/clang++ \ | |
473 -DLLVM_CONFIG_PATH=${PWD}/../bin/llvm-config \ | |
474 -DCMAKE_C_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../androi d-toolchain/sysroot -B${PWD}/../android-toolchain" \ | |
475 -DCMAKE_CXX_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../andr oid-toolchain/sysroot -B${PWD}/../android-toolchain" \ | |
476 -DANDROID=1 \ | |
477 "${ABS_COMPILER_RT_DIR}" | |
478 ninja clang_rt.asan-arm-android | |
479 | |
480 # And copy it into the main build tree. | |
481 cp "$(find -name libclang_rt.asan-arm-android.so)" "${ABS_LLVM_CLANG_LIB_DIR}/ lib/linux/" | |
436 popd | 482 popd |
437 fi | 483 fi |
438 | 484 |
439 # Build Chrome-specific clang tools. Paths in this list should be relative to | 485 # Build Chrome-specific clang tools. Paths in this list should be relative to |
440 # tools/clang. | 486 # tools/clang. |
441 # For each tool directory, copy it into the clang tree and use clang's build | 487 # For each tool directory, copy it into the clang tree and use clang's build |
442 # system to compile it. | 488 # system to compile it. |
443 for CHROME_TOOL_DIR in ${chrome_tools}; do | 489 for CHROME_TOOL_DIR in ${chrome_tools}; do |
444 TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}" | 490 TOOL_SRC_DIR="${PWD}/${THIS_DIR}/../${CHROME_TOOL_DIR}" |
445 TOOL_DST_DIR="${LLVM_DIR}/tools/clang/tools/chrome-${CHROME_TOOL_DIR}" | 491 TOOL_BUILD_DIR="${ABS_LLVM_BUILD_DIR}/tools/clang/tools/chrome-${CHROME_TOOL_D IR}" |
446 TOOL_BUILD_DIR="${LLVM_BUILD_DIR}/tools/clang/tools/chrome-${CHROME_TOOL_DIR}" | 492 |
447 rm -rf "${TOOL_DST_DIR}" | |
448 cp -R "${TOOL_SRC_DIR}" "${TOOL_DST_DIR}" | |
449 rm -rf "${TOOL_BUILD_DIR}" | 493 rm -rf "${TOOL_BUILD_DIR}" |
450 mkdir -p "${TOOL_BUILD_DIR}" | 494 mkdir -p "${TOOL_BUILD_DIR}" |
451 cp "${TOOL_SRC_DIR}/Makefile" "${TOOL_BUILD_DIR}" | 495 pushd "${TOOL_BUILD_DIR}" |
452 MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" -C "${TOOL_BUILD_DIR}" | 496 MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \ |
497 -DLLVM_BUILD_DIR="${ABS_LLVM_BUILD_DIR}" \ | |
498 -DLLVM_SRC_DIR="${ABS_LLVM_DIR}" \ | |
499 -DCMAKE_C_COMPILER="${CC}" \ | |
500 -DCMAKE_CXX_COMPILER="${CXX}" \ | |
501 -DCMAKE_C_FLAGS="${CFLAGS}" \ | |
502 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ | |
503 -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ | |
504 -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ | |
505 "${TOOL_SRC_DIR}" | |
506 ninja | |
507 cp -v "${TOOL_BUILD_DIR}/lib"/* "${ABS_LLVM_BUILD_DIR}/lib/" | |
508 popd | |
453 done | 509 done |
454 | 510 |
455 if [[ -n "$run_tests" ]]; then | 511 if [[ -n "$run_tests" ]]; then |
456 # Run a few tests. | 512 # Run the tests for each chrome tool. |
457 for CHROME_TOOL_DIR in ${chrome_tools}; do | 513 for CHROME_TOOL_DIR in ${chrome_tools}; do |
458 TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}" | 514 TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}" |
515 TOOL_BUILD_DIR="${ABS_LLVM_BUILD_DIR}/tools/clang/tools/chrome-${CHROME_TOOL _DIR}" | |
459 if [[ -f "${TOOL_SRC_DIR}/tests/test.sh" ]]; then | 516 if [[ -f "${TOOL_SRC_DIR}/tests/test.sh" ]]; then |
460 "${TOOL_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" | 517 "${TOOL_SRC_DIR}/tests/test.sh" "${ABS_LLVM_BUILD_DIR}/bin/clang" "${TOOL_ BUILD_DIR}/lib"/* |
461 fi | 518 fi |
462 done | 519 done |
463 pushd "${LLVM_BUILD_DIR}" | 520 # Run the LLVM and Clang tests. |
464 ${MAKE} check-all | 521 ninja -C "${LLVM_BUILD_DIR}" check-all |
465 popd | |
466 fi | 522 fi |
467 | 523 |
468 # After everything is done, log success for this revision. | 524 # After everything is done, log success for this revision. |
469 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" | 525 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" |
OLD | NEW |