| 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=216630 |
| 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_DIR}/../llvm-build/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 \ |
| 33 | cut -d '_' -f 2) | 37 | cut -d ' ' -f 2 | tr -cd '[0-9]') |
| 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. |
| 222 if ! which cmake > /dev/null; then |
| 223 echo "CMake needed to build clang; please install" |
| 224 exit 1 |
| 225 fi |
| 226 if ! which ninja > /dev/null; then |
| 227 echo "ninja needed to build clang, please install" |
| 228 exit 1 |
| 229 fi |
| 230 |
| 222 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" | 231 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" |
| 223 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ | 232 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ |
| 224 "${LLVM_DIR}"; then | 233 "${LLVM_DIR}"; then |
| 225 echo Checkout failed, retrying | 234 echo Checkout failed, retrying |
| 226 rm -rf "${LLVM_DIR}" | 235 rm -rf "${LLVM_DIR}" |
| 227 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" | 236 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" |
| 228 fi | 237 fi |
| 229 | 238 |
| 230 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" | 239 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" |
| 231 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" | 240 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" |
| 232 | 241 |
| 242 # We have moved from building compiler-rt in the LLVM tree, to a separate |
| 243 # directory. Nuke any previous checkout to avoid building it. |
| 244 rm -rf "${LLVM_DIR}/projects/compiler-rt" |
| 245 |
| 233 echo Getting compiler-rt r"${CLANG_REVISION}" in "${COMPILER_RT_DIR}" | 246 echo Getting compiler-rt r"${CLANG_REVISION}" in "${COMPILER_RT_DIR}" |
| 234 svn co --force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \ | 247 svn co --force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \ |
| 235 "${COMPILER_RT_DIR}" | 248 "${COMPILER_RT_DIR}" |
| 236 | 249 |
| 237 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes | 250 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes |
| 238 # (i.e. this is needed for bootstrap builds). | 251 # (i.e. this is needed for bootstrap builds). |
| 239 if [ "${OS}" = "Darwin" ]; then | 252 if [ "${OS}" = "Darwin" ]; then |
| 240 echo Getting libc++ r"${CLANG_REVISION}" in "${LIBCXX_DIR}" | 253 echo Getting libc++ r"${CLANG_REVISION}" in "${LIBCXX_DIR}" |
| 241 svn co --force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \ | 254 svn co --force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \ |
| 242 "${LIBCXX_DIR}" | 255 "${LIBCXX_DIR}" |
| 243 fi | 256 fi |
| 244 | 257 |
| 245 # While we're bundling our own libc++ on OS X, we need to compile libc++abi | 258 # While we're bundling our own libc++ on OS X, we need to compile libc++abi |
| 246 # into it too (since OS X 10.6 doesn't have libc++abi.dylib either). | 259 # into it too (since OS X 10.6 doesn't have libc++abi.dylib either). |
| 247 if [ "${OS}" = "Darwin" ]; then | 260 if [ "${OS}" = "Darwin" ]; then |
| 248 echo Getting libc++abi r"${CLANG_REVISION}" in "${LIBCXXABI_DIR}" | 261 echo Getting libc++abi r"${CLANG_REVISION}" in "${LIBCXXABI_DIR}" |
| 249 svn co --force "${LLVM_REPO_URL}/libcxxabi/trunk@${CLANG_REVISION}" \ | 262 svn co --force "${LLVM_REPO_URL}/libcxxabi/trunk@${CLANG_REVISION}" \ |
| 250 "${LIBCXXABI_DIR}" | 263 "${LIBCXXABI_DIR}" |
| 251 fi | 264 fi |
| 252 | 265 |
| 253 # Apply patch for test failing with --disable-pthreads (llvm.org/PR11974) | 266 # Apply patch for tests failing with --disable-pthreads (llvm.org/PR11974) |
| 254 pushd "${CLANG_DIR}" | 267 pushd "${CLANG_DIR}" |
| 255 svn revert test/Index/crash-recovery-modules.m | 268 svn revert test/Index/crash-recovery-modules.m |
| 256 cat << 'EOF' | | 269 cat << 'EOF' | |
| 257 --- third_party/llvm/tools/clang/test/Index/crash-recovery-modules.m (revisio
n 202554) | 270 --- third_party/llvm/tools/clang/test/Index/crash-recovery-modules.m (revisio
n 202554) |
| 258 +++ third_party/llvm/tools/clang/test/Index/crash-recovery-modules.m (working
copy) | 271 +++ third_party/llvm/tools/clang/test/Index/crash-recovery-modules.m (working
copy) |
| 259 @@ -12,6 +12,8 @@ | 272 @@ -12,6 +12,8 @@ |
| 260 | 273 |
| 261 // REQUIRES: crash-recovery | 274 // REQUIRES: crash-recovery |
| 262 // REQUIRES: shell | 275 // REQUIRES: shell |
| 263 +// XFAIL: * | 276 +// XFAIL: * |
| 264 +// (PR11974) | 277 +// (PR11974) |
| 265 | 278 |
| 266 @import Crash; | 279 @import Crash; |
| 267 EOF | 280 EOF |
| 268 patch -p4 | 281 patch -p4 |
| 269 popd | 282 popd |
| 270 | 283 |
| 284 pushd "${CLANG_DIR}" |
| 285 svn revert unittests/libclang/LibclangTest.cpp |
| 286 cat << 'EOF' | |
| 287 --- unittests/libclang/LibclangTest.cpp (revision 215949) |
| 288 +++ unittests/libclang/LibclangTest.cpp (working copy) |
| 289 @@ -431,7 +431,7 @@ |
| 290 EXPECT_EQ(0U, clang_getNumDiagnostics(ClangTU)); |
| 291 } |
| 292 |
| 293 -TEST_F(LibclangReparseTest, ReparseWithModule) { |
| 294 +TEST_F(LibclangReparseTest, DISABLED_ReparseWithModule) { |
| 295 const char *HeaderTop = "#ifndef H\n#define H\nstruct Foo { int bar;"; |
| 296 const char *HeaderBottom = "\n};\n#endif\n"; |
| 297 const char *MFile = "#include \"HeaderFile.h\"\nint main() {" |
| 298 EOF |
| 299 patch -p0 |
| 300 popd |
| 301 |
| 302 # Apply r216684 to fix ASan array cookie instrumentation problem. |
| 303 # (See https://code.google.com/p/chromium/issues/detail?id=400849#c17) |
| 304 pushd "${COMPILER_RT_DIR}" |
| 305 svn revert lib/asan/asan_rtl.cc |
| 306 cat << 'EOF' | |
| 307 --- a/lib/asan/asan_rtl.cc |
| 308 +++ b/lib/asan/asan_rtl.cc |
| 309 @@ -269,7 +269,7 @@ void InitializeFlags(Flags *f, const char *env) { |
| 310 f->allow_reexec = true; |
| 311 f->print_full_thread_history = true; |
| 312 f->poison_heap = true; |
| 313 - f->poison_array_cookie = true; |
| 314 + f->poison_array_cookie = false; |
| 315 f->poison_partial = true; |
| 316 // Turn off alloc/dealloc mismatch checker on Mac and Windows for now. |
| 317 // https://code.google.com/p/address-sanitizer/issues/detail?id=131 |
| 318 diff --git a/test/asan/TestCases/Linux/new_array_cookie_test.cc b/test/asan/Test
Cases/Linux/new_array_cookie_test.cc |
| 319 index 339120b..49545f0 100644 |
| 320 --- a/test/asan/TestCases/Linux/new_array_cookie_test.cc |
| 321 +++ b/test/asan/TestCases/Linux/new_array_cookie_test.cc |
| 322 @@ -1,6 +1,6 @@ |
| 323 // REQUIRES: asan-64-bits |
| 324 -// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s |
| 325 -// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s |
| 326 +// RUN: %clangxx_asan -O3 %s -o %t |
| 327 +// RUN %run %t |
| 328 // RUN: ASAN_OPTIONS=poison_array_cookie=1 not %run %t 2>&1 | FileCheck %s |
| 329 // RUN: ASAN_OPTIONS=poison_array_cookie=0 %run %t |
| 330 #include <stdio.h> |
| 331 EOF |
| 332 patch -p1 |
| 333 popd |
| 334 |
| 271 # Echo all commands. | 335 # Echo all commands. |
| 272 set -x | 336 set -x |
| 273 | 337 |
| 274 NUM_JOBS=3 | 338 # Set default values for CC and CXX if they're not set in the environment. |
| 275 if [[ "${OS}" = "Linux" ]]; then | 339 CC=${CC:-cc} |
| 276 NUM_JOBS="$(grep -c "^processor" /proc/cpuinfo)" | 340 CXX=${CXX:-c++} |
| 277 elif [ "${OS}" = "Darwin" -o "${OS}" = "FreeBSD" ]; then | |
| 278 NUM_JOBS="$(sysctl -n hw.ncpu)" | |
| 279 fi | |
| 280 | 341 |
| 281 if [[ -n "${gcc_toolchain}" ]]; then | 342 if [[ -n "${gcc_toolchain}" ]]; then |
| 282 # Use the specified gcc installation for building. | 343 # Use the specified gcc installation for building. |
| 283 export CC="$gcc_toolchain/bin/gcc" | 344 CC="$gcc_toolchain/bin/gcc" |
| 284 export CXX="$gcc_toolchain/bin/g++" | 345 CXX="$gcc_toolchain/bin/g++" |
| 285 # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap compiler, | 346 # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap compiler, |
| 286 # etc.) find the .so. | 347 # etc.) find the .so. |
| 287 export LD_LIBRARY_PATH="$(dirname $(${CXX} -print-file-name=libstdc++.so.6))" | 348 export LD_LIBRARY_PATH="$(dirname $(${CXX} -print-file-name=libstdc++.so.6))" |
| 288 fi | 349 fi |
| 289 | 350 |
| 290 export CFLAGS="" | 351 CFLAGS="" |
| 291 export CXXFLAGS="" | 352 CXXFLAGS="" |
| 353 LDFLAGS="" |
| 292 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is | 354 # 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++ | 355 # 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 | 356 # 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. | 357 # OS X versions as old as 10.7. |
| 296 # TODO(thakis): Some bots are still on 10.6, so for now bundle libc++.dylib. | 358 # 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 | 359 # 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. | 360 # change all MACOSX_DEPLOYMENT_TARGET values to 10.7. |
| 299 if [ "${OS}" = "Darwin" ]; then | 361 if [ "${OS}" = "Darwin" ]; then |
| 300 # When building on 10.9, /usr/include usually doesn't exist, and while | 362 # 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. | 363 # Xcode's clang automatically sets a sysroot, self-built clangs don't. |
| 302 export CFLAGS="-isysroot $(xcrun --show-sdk-path)" | 364 CFLAGS="-isysroot $(xcrun --show-sdk-path)" |
| 303 export CPPFLAGS="${CFLAGS}" | 365 CPPFLAGS="${CFLAGS}" |
| 304 export CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLA
GS}" | 366 CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLAGS}" |
| 305 fi | 367 fi |
| 306 | 368 |
| 307 # Build bootstrap clang if requested. | 369 # Build bootstrap clang if requested. |
| 308 if [[ -n "${bootstrap}" ]]; then | 370 if [[ -n "${bootstrap}" ]]; then |
| 309 ABS_INSTALL_DIR="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}" | 371 ABS_INSTALL_DIR="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}" |
| 310 echo "Building bootstrap compiler" | 372 echo "Building bootstrap compiler" |
| 311 mkdir -p "${LLVM_BOOTSTRAP_DIR}" | 373 mkdir -p "${LLVM_BOOTSTRAP_DIR}" |
| 312 pushd "${LLVM_BOOTSTRAP_DIR}" | 374 pushd "${LLVM_BOOTSTRAP_DIR}" |
| 313 if [[ ! -f ./config.status ]]; then | 375 |
| 314 # The bootstrap compiler only needs to be able to build the real compiler, | 376 cmake -GNinja \ |
| 315 # so it needs no cross-compiler output support. In general, the host | 377 -DCMAKE_BUILD_TYPE=Release \ |
| 316 # compiler should be as similar to the final compiler as possible, so do | 378 -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 317 # keep --disable-threads & co. | 379 -DLLVM_TARGETS_TO_BUILD=host \ |
| 318 ../llvm/configure \ | 380 -DLLVM_ENABLE_THREADS=OFF \ |
| 319 --enable-optimized \ | 381 -DCMAKE_INSTALL_PREFIX="${ABS_INSTALL_DIR}" \ |
| 320 --enable-targets=host-only \ | 382 -DCMAKE_C_COMPILER="${CC}" \ |
| 321 --enable-libedit=no \ | 383 -DCMAKE_CXX_COMPILER="${CXX}" \ |
| 322 --disable-threads \ | 384 -DCMAKE_C_FLAGS="${CFLAGS}" \ |
| 323 --disable-pthreads \ | 385 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ |
| 324 --without-llvmgcc \ | 386 ../llvm |
| 325 --without-llvmgxx \ | 387 |
| 326 --prefix="${ABS_INSTALL_DIR}" | 388 ninja |
| 389 if [[ -n "${run_tests}" ]]; then |
| 390 ninja check-all |
| 327 fi | 391 fi |
| 328 | 392 |
| 329 ${MAKE} -j"${NUM_JOBS}" | 393 ninja install |
| 330 if [[ -n "${run_tests}" ]]; then | |
| 331 ${MAKE} check-all | |
| 332 fi | |
| 333 | |
| 334 ${MAKE} install | |
| 335 if [[ -n "${gcc_toolchain}" ]]; then | 394 if [[ -n "${gcc_toolchain}" ]]; then |
| 336 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap | 395 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap |
| 337 # compiler can start. | 396 # compiler can start. |
| 338 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \ | 397 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \ |
| 339 "${ABS_INSTALL_DIR}/lib/" | 398 "${ABS_INSTALL_DIR}/lib/" |
| 340 fi | 399 fi |
| 341 | 400 |
| 342 popd | 401 popd |
| 343 export CC="${ABS_INSTALL_DIR}/bin/clang" | 402 CC="${ABS_INSTALL_DIR}/bin/clang" |
| 344 export CXX="${ABS_INSTALL_DIR}/bin/clang++" | 403 CXX="${ABS_INSTALL_DIR}/bin/clang++" |
| 345 | 404 |
| 346 if [[ -n "${gcc_toolchain}" ]]; then | 405 if [[ -n "${gcc_toolchain}" ]]; then |
| 347 # Tell the bootstrap compiler to use a specific gcc prefix to search | 406 # Tell the bootstrap compiler to use a specific gcc prefix to search |
| 348 # for standard library headers and shared object file. | 407 # for standard library headers and shared object file. |
| 349 export CFLAGS="--gcc-toolchain=${gcc_toolchain}" | 408 CFLAGS="--gcc-toolchain=${gcc_toolchain}" |
| 350 export CXXFLAGS="--gcc-toolchain=${gcc_toolchain}" | 409 CXXFLAGS="--gcc-toolchain=${gcc_toolchain}" |
| 351 fi | 410 fi |
| 352 | 411 |
| 353 echo "Building final compiler" | 412 echo "Building final compiler" |
| 354 fi | 413 fi |
| 355 | 414 |
| 356 # Build clang (in a separate directory). | 415 # Build clang (in a separate directory). |
| 357 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, | 416 # 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. | 417 # so if you change it you also need to change these links. |
| 359 mkdir -p "${LLVM_BUILD_DIR}" | 418 mkdir -p "${LLVM_BUILD_DIR}" |
| 360 pushd "${LLVM_BUILD_DIR}" | 419 pushd "${LLVM_BUILD_DIR}" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 378 | 437 |
| 379 pushd libcxxbuild | 438 pushd libcxxbuild |
| 380 ${CC:-cc} libcxx/*.o libcxxabi/*.o -o libc++.1.dylib -dynamiclib \ | 439 ${CC:-cc} libcxx/*.o libcxxabi/*.o -o libc++.1.dylib -dynamiclib \ |
| 381 -nodefaultlibs -current_version 1 -compatibility_version 1 \ | 440 -nodefaultlibs -current_version 1 -compatibility_version 1 \ |
| 382 -lSystem -install_name @executable_path/libc++.dylib \ | 441 -lSystem -install_name @executable_path/libc++.dylib \ |
| 383 -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib/libc++unexp.exp \ | 442 -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib/libc++unexp.exp \ |
| 384 -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib/notweak.exp \ | 443 -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib/notweak.exp \ |
| 385 -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib/weak.exp | 444 -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib/weak.exp |
| 386 ln -sf libc++.1.dylib libc++.dylib | 445 ln -sf libc++.1.dylib libc++.dylib |
| 387 popd | 446 popd |
| 388 export LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild" | 447 LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild" |
| 389 fi | 448 fi |
| 390 | 449 |
| 391 if [[ ! -f ./config.status ]]; then | 450 if [[ ! -f ./CMakeCache.txt ]]; then |
| 392 ../llvm/configure \ | 451 MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \ |
| 393 --enable-optimized \ | 452 -DCMAKE_BUILD_TYPE=Release \ |
| 394 --enable-libedit=no \ | 453 -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 395 --disable-threads \ | 454 -DLLVM_ENABLE_THREADS=OFF \ |
| 396 --disable-pthreads \ | 455 -DCMAKE_C_COMPILER="${CC}" \ |
| 397 --without-llvmgcc \ | 456 -DCMAKE_CXX_COMPILER="${CXX}" \ |
| 398 --without-llvmgxx | 457 -DCMAKE_C_FLAGS="${CFLAGS}" \ |
| 458 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ |
| 459 -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ |
| 460 -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ |
| 461 "${ABS_LLVM_DIR}" |
| 462 env |
| 399 fi | 463 fi |
| 400 | 464 |
| 401 if [[ -n "${gcc_toolchain}" ]]; then | 465 if [[ -n "${gcc_toolchain}" ]]; then |
| 402 # Copy in the right stdlibc++.so.6 so clang can start. | 466 # Copy in the right stdlibc++.so.6 so clang can start. |
| 403 mkdir -p Release+Asserts/lib | 467 mkdir -p lib |
| 404 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" \ | 468 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" lib/ |
| 405 Release+Asserts/lib/ | |
| 406 fi | 469 fi |
| 407 MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" | 470 |
| 471 ninja |
| 472 |
| 408 STRIP_FLAGS= | 473 STRIP_FLAGS= |
| 409 if [ "${OS}" = "Darwin" ]; then | 474 if [ "${OS}" = "Darwin" ]; then |
| 410 # See http://crbug.com/256342 | 475 # See http://crbug.com/256342 |
| 411 STRIP_FLAGS=-x | 476 STRIP_FLAGS=-x |
| 412 | 477 |
| 413 cp libcxxbuild/libc++.1.dylib Release+Asserts/bin | 478 cp libcxxbuild/libc++.1.dylib bin/ |
| 414 fi | 479 fi |
| 415 strip ${STRIP_FLAGS} Release+Asserts/bin/clang | 480 strip ${STRIP_FLAGS} bin/clang |
| 481 popd |
| 482 |
| 483 # Build compiler-rt out-of-tree. |
| 484 mkdir -p "${COMPILER_RT_BUILD_DIR}" |
| 485 pushd "${COMPILER_RT_BUILD_DIR}" |
| 486 |
| 487 MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \ |
| 488 -DCMAKE_BUILD_TYPE=Release \ |
| 489 -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 490 -DLLVM_ENABLE_THREADS=OFF \ |
| 491 -DCMAKE_C_COMPILER="${CC}" \ |
| 492 -DCMAKE_CXX_COMPILER="${CXX}" \ |
| 493 -DLLVM_CONFIG_PATH="${ABS_LLVM_BUILD_DIR}/bin/llvm-config" \ |
| 494 "${ABS_COMPILER_RT_DIR}" |
| 495 |
| 496 ninja |
| 497 |
| 498 # Copy selected output to the main tree. |
| 499 # Darwin doesn't support cp --parents, so pipe through tar instead. |
| 500 CLANG_VERSION=$("${ABS_LLVM_BUILD_DIR}/bin/clang" --version | \ |
| 501 sed -ne 's/clang version \([0-9]\.[0-9]\.[0-9]\).*/\1/p') |
| 502 ABS_LLVM_CLANG_LIB_DIR="${ABS_LLVM_BUILD_DIR}/lib/clang/${CLANG_VERSION}" |
| 503 tar -c *blacklist.txt | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv |
| 504 tar -c include/sanitizer | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv |
| 505 if [[ "${OS}" = "Darwin" ]]; then |
| 506 tar -c lib/darwin | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv |
| 507 else |
| 508 tar -c lib/linux | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv |
| 509 fi |
| 510 |
| 416 popd | 511 popd |
| 417 | 512 |
| 418 if [[ -n "${with_android}" ]]; then | 513 if [[ -n "${with_android}" ]]; then |
| 419 # Make a standalone Android toolchain. | 514 # Make a standalone Android toolchain. |
| 420 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ | 515 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ |
| 421 --platform=android-14 \ | 516 --platform=android-14 \ |
| 422 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \ | 517 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \ |
| 423 --system=linux-x86_64 \ | 518 --system=linux-x86_64 \ |
| 424 --stl=stlport | 519 --stl=stlport |
| 425 | 520 |
| 426 # Android NDK r9d copies a broken unwind.h into the toolchain, see | 521 # Android NDK r9d copies a broken unwind.h into the toolchain, see |
| 427 # http://crbug.com/357890 | 522 # http://crbug.com/357890 |
| 428 rm -v "${LLVM_BUILD_DIR}"/android-toolchain/include/c++/*/unwind.h | 523 rm -v "${LLVM_BUILD_DIR}"/android-toolchain/include/c++/*/unwind.h |
| 429 | 524 |
| 430 # Build ASan runtime for Android. | 525 # 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 | 526 mkdir -p ${LLVM_BUILD_DIR}/android |
| 432 # build the runtime, i.e. third_party/llvm/projects/compiler-rt. | 527 pushd ${LLVM_BUILD_DIR}/android |
| 433 pushd "${LLVM_BUILD_DIR}" | 528 MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \ |
| 434 ${MAKE} -C tools/clang/runtime/ \ | 529 -DCMAKE_BUILD_TYPE=Release \ |
| 435 LLVM_ANDROID_TOOLCHAIN_DIR="../../../llvm-build/android-toolchain" | 530 -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 531 -DLLVM_ENABLE_THREADS=OFF \ |
| 532 -DCMAKE_C_COMPILER=${PWD}/../bin/clang \ |
| 533 -DCMAKE_CXX_COMPILER=${PWD}/../bin/clang++ \ |
| 534 -DLLVM_CONFIG_PATH=${PWD}/../bin/llvm-config \ |
| 535 -DCMAKE_C_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../androi
d-toolchain/sysroot -B${PWD}/../android-toolchain" \ |
| 536 -DCMAKE_CXX_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../andr
oid-toolchain/sysroot -B${PWD}/../android-toolchain" \ |
| 537 -DANDROID=1 \ |
| 538 "${ABS_COMPILER_RT_DIR}" |
| 539 ninja clang_rt.asan-arm-android |
| 540 |
| 541 # And copy it into the main build tree. |
| 542 cp "$(find -name libclang_rt.asan-arm-android.so)" "${ABS_LLVM_CLANG_LIB_DIR}/
lib/linux/" |
| 436 popd | 543 popd |
| 437 fi | 544 fi |
| 438 | 545 |
| 439 # Build Chrome-specific clang tools. Paths in this list should be relative to | 546 # Build Chrome-specific clang tools. Paths in this list should be relative to |
| 440 # tools/clang. | 547 # tools/clang. |
| 441 # For each tool directory, copy it into the clang tree and use clang's build | 548 # For each tool directory, copy it into the clang tree and use clang's build |
| 442 # system to compile it. | 549 # system to compile it. |
| 443 for CHROME_TOOL_DIR in ${chrome_tools}; do | 550 for CHROME_TOOL_DIR in ${chrome_tools}; do |
| 444 TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}" | 551 TOOL_SRC_DIR="${PWD}/${THIS_DIR}/../${CHROME_TOOL_DIR}" |
| 445 TOOL_DST_DIR="${LLVM_DIR}/tools/clang/tools/chrome-${CHROME_TOOL_DIR}" | 552 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}" | 553 |
| 447 rm -rf "${TOOL_DST_DIR}" | |
| 448 cp -R "${TOOL_SRC_DIR}" "${TOOL_DST_DIR}" | |
| 449 rm -rf "${TOOL_BUILD_DIR}" | 554 rm -rf "${TOOL_BUILD_DIR}" |
| 450 mkdir -p "${TOOL_BUILD_DIR}" | 555 mkdir -p "${TOOL_BUILD_DIR}" |
| 451 cp "${TOOL_SRC_DIR}/Makefile" "${TOOL_BUILD_DIR}" | 556 pushd "${TOOL_BUILD_DIR}" |
| 452 MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" -C "${TOOL_BUILD_DIR}" | 557 MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \ |
| 558 -DLLVM_BUILD_DIR="${ABS_LLVM_BUILD_DIR}" \ |
| 559 -DLLVM_SRC_DIR="${ABS_LLVM_DIR}" \ |
| 560 -DCMAKE_C_COMPILER="${CC}" \ |
| 561 -DCMAKE_CXX_COMPILER="${CXX}" \ |
| 562 -DCMAKE_C_FLAGS="${CFLAGS}" \ |
| 563 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ |
| 564 -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ |
| 565 -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ |
| 566 "${TOOL_SRC_DIR}" |
| 567 ninja |
| 568 cp -v "${TOOL_BUILD_DIR}/lib"/* "${ABS_LLVM_BUILD_DIR}/lib/" |
| 569 popd |
| 453 done | 570 done |
| 454 | 571 |
| 455 if [[ -n "$run_tests" ]]; then | 572 if [[ -n "$run_tests" ]]; then |
| 456 # Run a few tests. | 573 # Run the tests for each chrome tool. |
| 457 for CHROME_TOOL_DIR in ${chrome_tools}; do | 574 for CHROME_TOOL_DIR in ${chrome_tools}; do |
| 458 TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}" | 575 TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}" |
| 576 TOOL_BUILD_DIR="${ABS_LLVM_BUILD_DIR}/tools/clang/tools/chrome-${CHROME_TOOL
_DIR}" |
| 459 if [[ -f "${TOOL_SRC_DIR}/tests/test.sh" ]]; then | 577 if [[ -f "${TOOL_SRC_DIR}/tests/test.sh" ]]; then |
| 460 "${TOOL_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" | 578 "${TOOL_SRC_DIR}/tests/test.sh" "${ABS_LLVM_BUILD_DIR}/bin/clang" "${TOOL_
BUILD_DIR}/lib"/* |
| 461 fi | 579 fi |
| 462 done | 580 done |
| 463 pushd "${LLVM_BUILD_DIR}" | 581 # Run the LLVM and Clang tests. |
| 464 ${MAKE} check-all | 582 ninja -C "${LLVM_BUILD_DIR}" check-all |
| 465 popd | |
| 466 fi | 583 fi |
| 467 | 584 |
| 468 # After everything is done, log success for this revision. | 585 # After everything is done, log success for this revision. |
| 469 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" | 586 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" |
| OLD | NEW |