| 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. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 exit 1 | 158 exit 1 |
| 159 ;; | 159 ;; |
| 160 esac | 160 esac |
| 161 shift | 161 shift |
| 162 done | 162 done |
| 163 | 163 |
| 164 if [[ -n ${LLVM_FORCE_HEAD_REVISION:-''} ]]; then | 164 if [[ -n ${LLVM_FORCE_HEAD_REVISION:-''} ]]; then |
| 165 force_local_build=yes | 165 force_local_build=yes |
| 166 | 166 |
| 167 if ! [[ "$GYP_DEFINES" =~ .*OS=android.* ]]; then | 167 if ! [[ "$GYP_DEFINES" =~ .*OS=android.* ]]; then |
| 168 # Only build the Android ASan rt when targetting Android. | 168 # Only build the Android ASan rt on ToT bots when targetting Android. |
| 169 with_android= | 169 with_android= |
| 170 fi | 170 fi |
| 171 | 171 |
| 172 LLVM_BUILD_TOOLS_DIR="${ABS_LLVM_DIR}/../llvm-build-tools" | 172 LLVM_BUILD_TOOLS_DIR="${ABS_LLVM_DIR}/../llvm-build-tools" |
| 173 | 173 |
| 174 if [[ "${OS}" == "Linux" ]] && [[ -z "${gcc_toolchain}" ]]; then | 174 if [[ "${OS}" == "Linux" ]] && [[ -z "${gcc_toolchain}" ]]; then |
| 175 if [[ $(gcc -dumpversion) < "4.7.0" ]]; then | 175 if [[ $(gcc -dumpversion) < "4.7.0" ]]; then |
| 176 # We need a newer GCC version. | 176 # We need a newer GCC version. |
| 177 if [[ ! -e "${LLVM_BUILD_TOOLS_DIR}/gcc482" ]]; then | 177 if [[ ! -e "${LLVM_BUILD_TOOLS_DIR}/gcc482" ]]; then |
| 178 echo "Downloading pre-built GCC 4.8.2..." | 178 echo "Downloading pre-built GCC 4.8.2..." |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ | 309 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ |
| 310 "${LLVM_DIR}"; then | 310 "${LLVM_DIR}"; then |
| 311 echo Checkout failed, retrying | 311 echo Checkout failed, retrying |
| 312 rm -rf "${LLVM_DIR}" | 312 rm -rf "${LLVM_DIR}" |
| 313 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" | 313 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" |
| 314 fi | 314 fi |
| 315 | 315 |
| 316 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" | 316 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" |
| 317 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" | 317 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" |
| 318 | 318 |
| 319 # We have moved from building compiler-rt in the LLVM tree, to a separate | |
| 320 # directory. Nuke any previous checkout to avoid building it. | |
| 321 rm -rf "${LLVM_DIR}/projects/compiler-rt" | |
| 322 | |
| 323 echo Getting compiler-rt r"${CLANG_REVISION}" in "${COMPILER_RT_DIR}" | 319 echo Getting compiler-rt r"${CLANG_REVISION}" in "${COMPILER_RT_DIR}" |
| 324 svn co --force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \ | 320 svn co --force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \ |
| 325 "${COMPILER_RT_DIR}" | 321 "${COMPILER_RT_DIR}" |
| 326 | 322 |
| 327 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes | 323 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes |
| 328 # (i.e. this is needed for bootstrap builds). | 324 # (i.e. this is needed for bootstrap builds). |
| 329 if [ "${OS}" = "Darwin" ]; then | 325 if [ "${OS}" = "Darwin" ]; then |
| 330 echo Getting libc++ r"${CLANG_REVISION}" in "${LIBCXX_DIR}" | 326 echo Getting libc++ r"${CLANG_REVISION}" in "${LIBCXX_DIR}" |
| 331 svn co --force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \ | 327 svn co --force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \ |
| 332 "${LIBCXX_DIR}" | 328 "${LIBCXX_DIR}" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 -DCMAKE_BUILD_TYPE=Release \ | 573 -DCMAKE_BUILD_TYPE=Release \ |
| 578 -DLLVM_ENABLE_ASSERTIONS=ON \ | 574 -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 579 -DLLVM_ENABLE_THREADS=OFF \ | 575 -DLLVM_ENABLE_THREADS=OFF \ |
| 580 -DCMAKE_C_COMPILER="${CC}" \ | 576 -DCMAKE_C_COMPILER="${CC}" \ |
| 581 -DCMAKE_CXX_COMPILER="${CXX}" \ | 577 -DCMAKE_CXX_COMPILER="${CXX}" \ |
| 582 -DCMAKE_CXX_FLAGS="${COMPILER_RT_CXXFLAGS}" \ | 578 -DCMAKE_CXX_FLAGS="${COMPILER_RT_CXXFLAGS}" \ |
| 583 -DSANITIZER_MIN_OSX_VERSION="10.7" \ | 579 -DSANITIZER_MIN_OSX_VERSION="10.7" \ |
| 584 -DLLVM_CONFIG_PATH="${ABS_LLVM_BUILD_DIR}/bin/llvm-config" \ | 580 -DLLVM_CONFIG_PATH="${ABS_LLVM_BUILD_DIR}/bin/llvm-config" \ |
| 585 "${ABS_COMPILER_RT_DIR}" | 581 "${ABS_COMPILER_RT_DIR}" |
| 586 | 582 |
| 587 ninja | 583 ninja compiler-rt |
| 588 | 584 |
| 589 # Copy selected output to the main tree. | 585 # Copy select output to the main tree. |
| 590 # Darwin doesn't support cp --parents, so pipe through tar instead. | 586 # Darwin doesn't support cp --parents, so pipe through tar instead. |
| 591 CLANG_VERSION=$("${ABS_LLVM_BUILD_DIR}/bin/clang" --version | \ | 587 CLANG_VERSION=$("${ABS_LLVM_BUILD_DIR}/bin/clang" --version | \ |
| 592 sed -ne 's/clang version \([0-9]\.[0-9]\.[0-9]\).*/\1/p') | 588 sed -ne 's/clang version \([0-9]\.[0-9]\.[0-9]\).*/\1/p') |
| 593 ABS_LLVM_CLANG_LIB_DIR="${ABS_LLVM_BUILD_DIR}/lib/clang/${CLANG_VERSION}" | 589 ABS_LLVM_CLANG_LIB_DIR="${ABS_LLVM_BUILD_DIR}/lib/clang/${CLANG_VERSION}" |
| 590 # Blacklists: |
| 594 tar -c *blacklist.txt | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv | 591 tar -c *blacklist.txt | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv |
| 592 # Headers: |
| 595 tar -c include/sanitizer | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv | 593 tar -c include/sanitizer | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv |
| 594 # Static and dynamic libraries: |
| 596 if [[ "${OS}" = "Darwin" ]]; then | 595 if [[ "${OS}" = "Darwin" ]]; then |
| 597 tar -c lib/darwin | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv | 596 tar -c lib/darwin | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv |
| 598 else | 597 else |
| 599 tar -c lib/linux | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv | 598 tar -c lib/linux | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv |
| 600 fi | 599 fi |
| 601 | 600 |
| 602 popd | 601 popd |
| 603 | 602 |
| 604 if [[ -n "${with_android}" ]]; then | 603 if [[ -n "${with_android}" ]]; then |
| 605 # Make a standalone Android toolchain. | 604 # Make standalone Android toolchains. |
| 606 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ | 605 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ |
| 607 --platform=android-19 \ | 606 --platform=android-19 \ |
| 608 --install-dir="${LLVM_BUILD_DIR}/android-toolchain-arm" \ | 607 --install-dir="${LLVM_BUILD_DIR}/android-toolchain-arm" \ |
| 609 --system=linux-x86_64 \ | 608 --system=linux-x86_64 \ |
| 610 --stl=stlport \ | 609 --stl=stlport \ |
| 611 --toolchain=arm-linux-androideabi-4.9 | 610 --toolchain=arm-linux-androideabi-4.9 |
| 612 | 611 |
| 613 # Do the same for arm64. | 612 # Do the same for arm64. |
| 614 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ | 613 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ |
| 615 --platform=android-21 \ | 614 --platform=android-21 \ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 628 | 627 |
| 629 for target_arch in "aarch64" "arm" "i686"; do | 628 for target_arch in "aarch64" "arm" "i686"; do |
| 630 # Android NDK r9d copies a broken unwind.h into the toolchain, see | 629 # Android NDK r9d copies a broken unwind.h into the toolchain, see |
| 631 # http://crbug.com/357890 | 630 # http://crbug.com/357890 |
| 632 rm -v "${LLVM_BUILD_DIR}"/android-toolchain-${target_arch}/include/c++/*/unw
ind.h | 631 rm -v "${LLVM_BUILD_DIR}"/android-toolchain-${target_arch}/include/c++/*/unw
ind.h |
| 633 | 632 |
| 634 # Build ASan runtime for Android in a separate build tree. | 633 # Build ASan runtime for Android in a separate build tree. |
| 635 mkdir -p ${LLVM_BUILD_DIR}/android-${target_arch} | 634 mkdir -p ${LLVM_BUILD_DIR}/android-${target_arch} |
| 636 pushd ${LLVM_BUILD_DIR}/android-${target_arch} | 635 pushd ${LLVM_BUILD_DIR}/android-${target_arch} |
| 637 rm -fv CMakeCache.txt | 636 rm -fv CMakeCache.txt |
| 638 MACOSX_DEPLOYMENT_TARGET=${deployment_target} cmake -GNinja \ | 637 cmake -GNinja \ |
| 639 -DCMAKE_BUILD_TYPE=Release \ | 638 -DCMAKE_BUILD_TYPE=Release \ |
| 640 -DLLVM_ENABLE_ASSERTIONS=ON \ | 639 -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 641 -DLLVM_ENABLE_THREADS=OFF \ | 640 -DLLVM_ENABLE_THREADS=OFF \ |
| 642 -DCMAKE_C_COMPILER=${PWD}/../bin/clang \ | 641 -DCMAKE_C_COMPILER=${PWD}/../bin/clang \ |
| 643 -DCMAKE_CXX_COMPILER=${PWD}/../bin/clang++ \ | 642 -DCMAKE_CXX_COMPILER=${PWD}/../bin/clang++ \ |
| 644 -DLLVM_CONFIG_PATH=${PWD}/../bin/llvm-config \ | 643 -DLLVM_CONFIG_PATH=${PWD}/../bin/llvm-config \ |
| 645 -DCMAKE_C_FLAGS="--target=${target_arch}-linux-androideabi --sysroot=${P
WD}/../android-toolchain-${target_arch}/sysroot -B${PWD}/../android-toolchain-${
target_arch}" \ | 644 -DCMAKE_C_FLAGS="--target=${target_arch}-linux-androideabi --sysroot=${P
WD}/../android-toolchain-${target_arch}/sysroot -B${PWD}/../android-toolchain-${
target_arch}" \ |
| 646 -DCMAKE_CXX_FLAGS="--target=${target_arch}-linux-androideabi --sysroot=$
{PWD}/../android-toolchain-${target_arch}/sysroot -B${PWD}/../android-toolchain-
${target_arch}" \ | 645 -DCMAKE_CXX_FLAGS="--target=${target_arch}-linux-androideabi --sysroot=$
{PWD}/../android-toolchain-${target_arch}/sysroot -B${PWD}/../android-toolchain-
${target_arch}" \ |
| 647 -DANDROID=1 \ | 646 -DANDROID=1 \ |
| 648 "${ABS_COMPILER_RT_DIR}" | 647 "${ABS_COMPILER_RT_DIR}" |
| 649 ninja libclang_rt.asan-${target_arch}-android.so | 648 ninja libclang_rt.asan-${target_arch}-android.so |
| 650 | 649 |
| 651 # And copy it into the main build tree. | 650 # And copy it into the main build tree. |
| 652 cp "$(find -name libclang_rt.asan-${target_arch}-android.so)" "${ABS_LLVM_CL
ANG_LIB_DIR}/lib/linux/" | 651 cp "$(find -name libclang_rt.asan-${target_arch}-android.so)" "${ABS_LLVM_CL
ANG_LIB_DIR}/lib/linux/" |
| 653 popd | 652 popd |
| 654 done | 653 done |
| 655 fi | 654 fi |
| 656 | 655 |
| 657 if [[ -n "$run_tests" || -n "${LLVM_FORCE_HEAD_REVISION:-''}" ]]; then | 656 if [[ -n "$run_tests" || -n "${LLVM_FORCE_HEAD_REVISION:-''}" ]]; then |
| 658 # Run Chrome tool tests. | 657 # Run Chrome tool tests. |
| 659 ninja -C "${LLVM_BUILD_DIR}" cr-check-all | 658 ninja -C "${LLVM_BUILD_DIR}" cr-check-all |
| 660 fi | 659 fi |
| 661 if [[ -n "$run_tests" ]]; then | 660 if [[ -n "$run_tests" ]]; then |
| 662 # Run the LLVM and Clang tests. | 661 # Run the LLVM and Clang tests. |
| 663 ninja -C "${LLVM_BUILD_DIR}" check-all | 662 ninja -C "${LLVM_BUILD_DIR}" check-all |
| 664 fi | 663 fi |
| 665 | 664 |
| 666 # After everything is done, log success for this revision. | 665 # After everything is done, log success for this revision. |
| 667 echo "${PACKAGE_VERSION}" > "${STAMP_FILE}" | 666 echo "${PACKAGE_VERSION}" > "${STAMP_FILE}" |
| OLD | NEW |