| 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=179138 | 11 CLANG_REVISION=179138 |
| 12 # ASan Mac builders are pinned to this revision, see http://crbug.com/170629. | |
| 13 CLANG_ASAN_MAC_REVISION=${CLANG_REVISION} | |
| 14 | 12 |
| 15 THIS_DIR="$(dirname "${0}")" | 13 THIS_DIR="$(dirname "${0}")" |
| 16 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" | 14 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" |
| 17 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" | 15 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" |
| 18 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" | 16 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" |
| 19 CLANG_DIR="${LLVM_DIR}/tools/clang" | 17 CLANG_DIR="${LLVM_DIR}/tools/clang" |
| 20 CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" | 18 CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" |
| 21 COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" | 19 COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" |
| 22 ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk" | 20 ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk" |
| 23 STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" | 21 STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" |
| 24 | 22 |
| 25 # ${A:-a} returns $A if it's set, a else. | 23 # ${A:-a} returns $A if it's set, a else. |
| 26 LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} | 24 LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} |
| 27 | 25 |
| 28 # Die if any command dies. | 26 # Die if any command dies. |
| 29 set -e | 27 set -e |
| 30 | 28 |
| 31 OS="$(uname -s)" | 29 OS="$(uname -s)" |
| 32 | 30 |
| 33 # Parse command line options. | 31 # Parse command line options. |
| 34 force_local_build= | 32 force_local_build= |
| 35 mac_only= | 33 mac_only= |
| 36 run_tests= | 34 run_tests= |
| 37 bootstrap= | 35 bootstrap= |
| 38 with_android=yes | 36 with_android=yes |
| 39 # Temporary workaround for http://crbug.com/170629: use older Clang for ASan | |
| 40 # Mac builders. | |
| 41 is_asan_mac_builder_hackfix= | |
| 42 with_tools_extra= | 37 with_tools_extra= |
| 43 chrome_tools="plugins" | 38 chrome_tools="plugins" |
| 44 | 39 |
| 45 if [[ "${OS}" = "Darwin" ]]; then | 40 if [[ "${OS}" = "Darwin" ]]; then |
| 46 with_android= | 41 with_android= |
| 47 fi | 42 fi |
| 48 | 43 |
| 49 while [[ $# > 0 ]]; do | 44 while [[ $# > 0 ]]; do |
| 50 case $1 in | 45 case $1 in |
| 51 --bootstrap) | 46 --bootstrap) |
| 52 bootstrap=yes | 47 bootstrap=yes |
| 53 ;; | 48 ;; |
| 54 --force-local-build) | 49 --force-local-build) |
| 55 force_local_build=yes | 50 force_local_build=yes |
| 56 ;; | 51 ;; |
| 57 --mac-only) | 52 --mac-only) |
| 58 mac_only=yes | 53 mac_only=yes |
| 59 ;; | 54 ;; |
| 60 --run-tests) | 55 --run-tests) |
| 61 run_tests=yes | 56 run_tests=yes |
| 62 ;; | 57 ;; |
| 63 --without-android) | 58 --without-android) |
| 64 with_android= | 59 with_android= |
| 65 ;; | 60 ;; |
| 66 # Temporary workaround for http://crbug.com/170629 - use older Clang for | |
| 67 # ASan Mac builders. | |
| 68 --is-asan-mac-builder-hackfix) | |
| 69 is_asan_mac_builder_hackfix=yes | |
| 70 ;; | |
| 71 --with-tools-extra) | 61 --with-tools-extra) |
| 72 with_tools_extra=yes | 62 with_tools_extra=yes |
| 73 ;; | 63 ;; |
| 74 --with-chrome-tools) | 64 --with-chrome-tools) |
| 75 shift | 65 shift |
| 76 if [[ $# == 0 ]]; then | 66 if [[ $# == 0 ]]; then |
| 77 echo "--with-chrome-tools requires an argument." | 67 echo "--with-chrome-tools requires an argument." |
| 78 exit 1 | 68 exit 1 |
| 79 fi | 69 fi |
| 80 chrome_tools=$1 | 70 chrome_tools=$1 |
| 81 ;; | 71 ;; |
| 82 --help) | 72 --help) |
| 83 echo "usage: $0 [--force-local-build] [--mac-only] [--run-tests] " | 73 echo "usage: $0 [--force-local-build] [--mac-only] [--run-tests] " |
| 84 echo "--bootstrap: First build clang with CC, then with itself." | 74 echo "--bootstrap: First build clang with CC, then with itself." |
| 85 echo "--force-local-build: Don't try to download prebuilt binaries." | 75 echo "--force-local-build: Don't try to download prebuilt binaries." |
| 86 echo "--mac-only: Do initial download only on Mac systems." | 76 echo "--mac-only: Do initial download only on Mac systems." |
| 87 echo "--run-tests: Run tests after building. Only for local builds." | 77 echo "--run-tests: Run tests after building. Only for local builds." |
| 88 echo "--without-android: Don't build ASan Android runtime library." | 78 echo "--without-android: Don't build ASan Android runtime library." |
| 89 echo "--is-asan-mac-builder-hackfix: Use older Clang" \ | |
| 90 "to build ASan on Mac." | |
| 91 echo "--with-tools-extra: Also build the clang-tools-extra repository." | 79 echo "--with-tools-extra: Also build the clang-tools-extra repository." |
| 92 echo "--with-chrome-tools: Select which chrome tools to build." \ | 80 echo "--with-chrome-tools: Select which chrome tools to build." \ |
| 93 "Defaults to plugins." | 81 "Defaults to plugins." |
| 94 echo " Example: --with-chrome-tools 'plugins empty-string'" | 82 echo " Example: --with-chrome-tools 'plugins empty-string'" |
| 95 echo | 83 echo |
| 96 exit 1 | 84 exit 1 |
| 97 ;; | 85 ;; |
| 98 esac | 86 esac |
| 99 shift | 87 shift |
| 100 done | 88 done |
| 101 | 89 |
| 102 # Are we on a Chrome buildbot running ASan? | |
| 103 function on_asan_mac_host { | |
| 104 if [[ "${OS}" != "Darwin" ]]; then | |
| 105 return 1 | |
| 106 fi | |
| 107 HOST="$(hostname -s)" | |
| 108 # Old (10.6) Chrome Mac ASan Builder. Kept here till we fully migrate to 10.8 | |
| 109 if [[ "${HOST}" == "vm633-m1" ]]; then | |
| 110 return 0 | |
| 111 fi | |
| 112 # 10.8 Chrome Mac ASan Builder. | |
| 113 if [[ "${HOST}" == "vm672-m1" ]]; then | |
| 114 return 0 | |
| 115 fi | |
| 116 # Chrome Mac ASan LKGR. | |
| 117 if [[ "${HOST}" == "mini11-a1" ]]; then | |
| 118 return 0 | |
| 119 fi | |
| 120 # mac_asan trybots. These share machines with the mac_layout bots, so only | |
| 121 # pin clang if the slave is used for an _asan build, not for a layout build. | |
| 122 if [[ "${PWD}" != *asan* ]]; then | |
| 123 return 1 | |
| 124 fi | |
| 125 for num in {600..655} | |
| 126 do | |
| 127 if [[ "${HOST}" == "vm${num}-m4" ]]; then | |
| 128 return 0 | |
| 129 fi | |
| 130 done | |
| 131 return 1 | |
| 132 } | |
| 133 | |
| 134 # Use older Clang for ASan Mac builds. See http://crbug.com/170629. | |
| 135 if [[ -n "${is_asan_mac_builder_hackfix}" ]] || on_asan_mac_host; then | |
| 136 CLANG_REVISION=${CLANG_ASAN_MAC_REVISION} | |
| 137 fi | |
| 138 | |
| 139 # --mac-only prevents the initial download on non-mac systems, but if clang has | 90 # --mac-only prevents the initial download on non-mac systems, but if clang has |
| 140 # already been downloaded in the past, this script keeps it up to date even if | 91 # already been downloaded in the past, this script keeps it up to date even if |
| 141 # --mac-only is passed in and the system isn't a mac. People who don't like this | 92 # --mac-only is passed in and the system isn't a mac. People who don't like this |
| 142 # can just delete their third_party/llvm-build directory. | 93 # can just delete their third_party/llvm-build directory. |
| 143 if [[ -n "$mac_only" ]] && [[ "${OS}" != "Darwin" ]] && | 94 if [[ -n "$mac_only" ]] && [[ "${OS}" != "Darwin" ]] && |
| 144 [[ ! ( "$GYP_DEFINES" =~ .*(clang|tsan|asan)=1.* ) ]] && | 95 [[ ! ( "$GYP_DEFINES" =~ .*(clang|tsan|asan)=1.* ) ]] && |
| 145 ! [[ -d "${LLVM_BUILD_DIR}" ]]; then | 96 ! [[ -d "${LLVM_BUILD_DIR}" ]]; then |
| 146 exit 0 | 97 exit 0 |
| 147 fi | 98 fi |
| 148 | 99 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 # Run a few tests. | 362 # Run a few tests. |
| 412 PLUGIN_SRC_DIR="${THIS_DIR}/../plugins" | 363 PLUGIN_SRC_DIR="${THIS_DIR}/../plugins" |
| 413 "${PLUGIN_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" | 364 "${PLUGIN_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" |
| 414 cd "${LLVM_BUILD_DIR}" | 365 cd "${LLVM_BUILD_DIR}" |
| 415 make check-all | 366 make check-all |
| 416 cd - | 367 cd - |
| 417 fi | 368 fi |
| 418 | 369 |
| 419 # After everything is done, log success for this revision. | 370 # After everything is done, log success for this revision. |
| 420 echo "${CLANG_REVISION}" > "${STAMP_FILE}" | 371 echo "${CLANG_REVISION}" > "${STAMP_FILE}" |
| OLD | NEW |