1*c303c47eSjoerg#!/usr/bin/env bash 2*c303c47eSjoerg#===----------------------------------------------------------------------===## 3*c303c47eSjoerg# 4*c303c47eSjoerg# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*c303c47eSjoerg# See https://llvm.org/LICENSE.txt for license information. 6*c303c47eSjoerg# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*c303c47eSjoerg# 8*c303c47eSjoerg#===----------------------------------------------------------------------===## 9*c303c47eSjoerg 10*c303c47eSjoergset -ex 11*c303c47eSjoergset -o pipefail 12*c303c47eSjoergunset LANG 13*c303c47eSjoergunset LC_ALL 14*c303c47eSjoergunset LC_COLLATE 15*c303c47eSjoerg 16*c303c47eSjoergPROGNAME="$(basename "${0}")" 17*c303c47eSjoerg 18*c303c47eSjoergfunction usage() { 19*c303c47eSjoergcat <<EOF 20*c303c47eSjoergUsage: 21*c303c47eSjoerg${PROGNAME} [options] <BUILDER> 22*c303c47eSjoerg 23*c303c47eSjoerg[-h|--help] Display this help and exit. 24*c303c47eSjoerg 25*c303c47eSjoerg--llvm-root <DIR> Path to the root of the LLVM monorepo. By default, we try 26*c303c47eSjoerg to figure it out based on the current working directory. 27*c303c47eSjoerg 28*c303c47eSjoerg--build-dir <DIR> The directory to use for building the library. By default, 29*c303c47eSjoerg this is '<llvm-root>/build/<builder>'. 30*c303c47eSjoerg 31*c303c47eSjoerg--osx-roots <DIR> Path to pre-downloaded macOS dylibs. By default, we download 32*c303c47eSjoerg them from Green Dragon. This is only relevant at all when 33*c303c47eSjoerg running back-deployment testing if one wants to override 34*c303c47eSjoerg the old dylibs we use to run the tests with different ones. 35*c303c47eSjoergEOF 36*c303c47eSjoerg} 37*c303c47eSjoerg 38*c303c47eSjoergwhile [[ $# -gt 0 ]]; do 39*c303c47eSjoerg case ${1} in 40*c303c47eSjoerg -h|--help) 41*c303c47eSjoerg usage 42*c303c47eSjoerg exit 0 43*c303c47eSjoerg ;; 44*c303c47eSjoerg --llvm-root) 45*c303c47eSjoerg MONOREPO_ROOT="${2}" 46*c303c47eSjoerg shift; shift 47*c303c47eSjoerg ;; 48*c303c47eSjoerg --build-dir) 49*c303c47eSjoerg BUILD_DIR="${2}" 50*c303c47eSjoerg shift; shift 51*c303c47eSjoerg ;; 52*c303c47eSjoerg --osx-roots) 53*c303c47eSjoerg OSX_ROOTS="${2}" 54*c303c47eSjoerg shift; shift 55*c303c47eSjoerg ;; 56*c303c47eSjoerg *) 57*c303c47eSjoerg BUILDER="${1}" 58*c303c47eSjoerg shift 59*c303c47eSjoerg ;; 60*c303c47eSjoerg esac 61*c303c47eSjoergdone 62*c303c47eSjoerg 63*c303c47eSjoergMONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}" 64*c303c47eSjoergBUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}" 65*c303c47eSjoergINSTALL_DIR="${BUILD_DIR}/install" 66*c303c47eSjoerg 67*c303c47eSjoerg# If we can find Ninja/CMake provided by Xcode, use those since we know their 68*c303c47eSjoerg# version will generally work with the Clang shipped in Xcode (e.g. if Clang 69*c303c47eSjoerg# knows about -std=c++20, the CMake bundled in Xcode will probably know about 70*c303c47eSjoerg# that flag too). 71*c303c47eSjoergif xcrun --find ninja &>/dev/null; then NINJA="$(xcrun --find ninja)"; else NINJA="ninja"; fi 72*c303c47eSjoergif xcrun --find cmake &>/dev/null; then CMAKE="$(xcrun --find cmake)"; else CMAKE="cmake"; fi 73*c303c47eSjoerg 74*c303c47eSjoergfunction clean() { 75*c303c47eSjoerg rm -rf "${BUILD_DIR}" 76*c303c47eSjoerg} 77*c303c47eSjoerg 78*c303c47eSjoergfunction generate-cmake-base() { 79*c303c47eSjoerg echo "--- Generating CMake" 80*c303c47eSjoerg ${CMAKE} \ 81*c303c47eSjoerg -B "${BUILD_DIR}" \ 82*c303c47eSjoerg -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ 83*c303c47eSjoerg -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 84*c303c47eSjoerg -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ 85*c303c47eSjoerg -DLLVM_LIT_ARGS="-sv --show-unsupported --xunit-xml-output test-results.xml" \ 86*c303c47eSjoerg "${@}" 87*c303c47eSjoerg} 88*c303c47eSjoerg 89*c303c47eSjoergfunction generate-cmake() { 90*c303c47eSjoerg generate-cmake-base \ 91*c303c47eSjoerg -S "${MONOREPO_ROOT}/llvm" \ 92*c303c47eSjoerg -DLLVM_ENABLE_PROJECTS="libcxx;libunwind;libcxxabi" \ 93*c303c47eSjoerg -DLIBCXX_CXX_ABI=libcxxabi \ 94*c303c47eSjoerg "${@}" 95*c303c47eSjoerg} 96*c303c47eSjoerg 97*c303c47eSjoergfunction generate-cmake-libcxx-win() { 98*c303c47eSjoerg # TODO: Clang-cl in MSVC configurations don't have access to compiler_rt 99*c303c47eSjoerg # builtins helpers for int128 division. See 100*c303c47eSjoerg # https://reviews.llvm.org/D91139#2429595 for a comment about longterm 101*c303c47eSjoerg # intent for handling the issue. In the meantime, define 102*c303c47eSjoerg # -D_LIBCPP_HAS_NO_INT128 (both when building the library itself and 103*c303c47eSjoerg # when building tests) to allow enabling filesystem for running tests, 104*c303c47eSjoerg # even if it uses a non-permanent ABI. 105*c303c47eSjoerg 106*c303c47eSjoerg generate-cmake-base \ 107*c303c47eSjoerg -S "${MONOREPO_ROOT}/libcxx" \ 108*c303c47eSjoerg -DCMAKE_C_COMPILER=clang-cl \ 109*c303c47eSjoerg -DCMAKE_CXX_COMPILER=clang-cl \ 110*c303c47eSjoerg -DLIBCXX_ENABLE_FILESYSTEM=YES \ 111*c303c47eSjoerg -DCMAKE_CXX_FLAGS="-D_LIBCPP_HAS_NO_INT128" \ 112*c303c47eSjoerg -DLIBCXX_TEST_COMPILER_FLAGS="-D_LIBCPP_HAS_NO_INT128" \ 113*c303c47eSjoerg "${@}" 114*c303c47eSjoerg} 115*c303c47eSjoerg 116*c303c47eSjoergfunction check-cxx-cxxabi() { 117*c303c47eSjoerg echo "--- Installing libc++ and libc++abi to a fake location" 118*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi 119*c303c47eSjoerg 120*c303c47eSjoerg echo "+++ Running the libc++ tests" 121*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" check-cxx 122*c303c47eSjoerg 123*c303c47eSjoerg echo "+++ Running the libc++abi tests" 124*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" check-cxxabi 125*c303c47eSjoerg} 126*c303c47eSjoerg 127*c303c47eSjoerg# TODO: The goal is to test this against all configurations. We should also move 128*c303c47eSjoerg# this to the Lit test suite instead of being a separate CMake target. 129*c303c47eSjoergfunction check-abi-list() { 130*c303c47eSjoerg echo "+++ Running the libc++ ABI list test" 131*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" check-cxx-abilist || ( 132*c303c47eSjoerg echo "+++ Generating the libc++ ABI list after failed check" 133*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" generate-cxx-abilist 134*c303c47eSjoerg false 135*c303c47eSjoerg ) 136*c303c47eSjoerg} 137*c303c47eSjoerg 138*c303c47eSjoergfunction check-cxx-benchmarks() { 139*c303c47eSjoerg echo "--- Running the benchmarks" 140*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" check-cxx-benchmarks 141*c303c47eSjoerg} 142*c303c47eSjoerg 143*c303c47eSjoerg# Print the version of a few tools to aid diagnostics in some cases 144*c303c47eSjoerg${CMAKE} --version 145*c303c47eSjoerg${NINJA} --version 146*c303c47eSjoerg 147*c303c47eSjoergcase "${BUILDER}" in 148*c303c47eSjoergcheck-format) 149*c303c47eSjoerg clean 150*c303c47eSjoerg echo "+++ Checking formatting" 151*c303c47eSjoerg # We need to set --extensions so that clang-format checks extensionless files. 152*c303c47eSjoerg mkdir -p ${BUILD_DIR} 153*c303c47eSjoerg git-clang-format \ 154*c303c47eSjoerg --binary /usr/bin/clang-format --diff \ 155*c303c47eSjoerg --extensions ',h,hh,hpp,hxx,c,cc,cxx,cpp' HEAD~1 \ 156*c303c47eSjoerg -- \ 157*c303c47eSjoerg libcxx/{benchmarks,include,src,test} \ 158*c303c47eSjoerg libcxxabi/{fuzz,include,src,test} \ 159*c303c47eSjoerg | tee ${BUILD_DIR}/clang-format.patch 160*c303c47eSjoerg # Check if the diff is empty, fail otherwise. 161*c303c47eSjoerg ! grep -q '^--- a' ${BUILD_DIR}/clang-format.patch 162*c303c47eSjoerg;; 163*c303c47eSjoergcheck-generated-output) 164*c303c47eSjoerg # `! foo` doesn't work properly with `set -e`, use `! foo || false` instead. 165*c303c47eSjoerg # https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not 166*c303c47eSjoerg clean 167*c303c47eSjoerg echo "+++ Checking the output of the generator scripts" 168*c303c47eSjoerg mkdir -p ${BUILD_DIR} 169*c303c47eSjoerg # Reject patches that don't update the generated output correctly. 170*c303c47eSjoerg python3 libcxx/utils/generate_feature_test_macro_components.py 171*c303c47eSjoerg python3 libcxx/utils/generate_header_inclusion_tests.py 172*c303c47eSjoerg python3 libcxx/utils/generate_header_tests.py 173*c303c47eSjoerg git diff | tee ${BUILD_DIR}/generated_output.patch 174*c303c47eSjoerg # Check if the diffs are empty, fail otherwise. 175*c303c47eSjoerg ! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false 176*c303c47eSjoerg # Reject patches that introduce non-ASCII characters or hard tabs. 177*c303c47eSjoerg # Depends on LC_COLLATE set at the top of this script. 178*c303c47eSjoerg ! grep -rn '[^ -~]' libcxx/include/ || false 179*c303c47eSjoerg # Check that no dependency cycles have been introduced. 180*c303c47eSjoerg python3 libcxx/utils/graph_header_deps.py >/dev/null 181*c303c47eSjoerg;; 182*c303c47eSjoerggeneric-cxx03) 183*c303c47eSjoerg export CC=clang 184*c303c47eSjoerg export CXX=clang++ 185*c303c47eSjoerg clean 186*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake" \ 187*c303c47eSjoerg -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/libcxx-trunk-shared.cfg.in" 188*c303c47eSjoerg check-cxx-cxxabi 189*c303c47eSjoerg check-abi-list 190*c303c47eSjoerg;; 191*c303c47eSjoerggeneric-cxx11) 192*c303c47eSjoerg export CC=clang 193*c303c47eSjoerg export CXX=clang++ 194*c303c47eSjoerg clean 195*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" \ 196*c303c47eSjoerg -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/libcxx-trunk-shared.cfg.in" 197*c303c47eSjoerg check-cxx-cxxabi 198*c303c47eSjoerg check-abi-list 199*c303c47eSjoerg;; 200*c303c47eSjoerggeneric-cxx14) 201*c303c47eSjoerg export CC=clang 202*c303c47eSjoerg export CXX=clang++ 203*c303c47eSjoerg clean 204*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake" \ 205*c303c47eSjoerg -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/libcxx-trunk-shared.cfg.in" 206*c303c47eSjoerg check-cxx-cxxabi 207*c303c47eSjoerg check-abi-list 208*c303c47eSjoerg;; 209*c303c47eSjoerggeneric-cxx17) 210*c303c47eSjoerg export CC=clang 211*c303c47eSjoerg export CXX=clang++ 212*c303c47eSjoerg clean 213*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake" \ 214*c303c47eSjoerg -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/libcxx-trunk-shared.cfg.in" 215*c303c47eSjoerg check-cxx-cxxabi 216*c303c47eSjoerg check-abi-list 217*c303c47eSjoerg;; 218*c303c47eSjoerggeneric-cxx20) 219*c303c47eSjoerg export CC=clang 220*c303c47eSjoerg export CXX=clang++ 221*c303c47eSjoerg clean 222*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake" \ 223*c303c47eSjoerg -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/libcxx-trunk-shared.cfg.in" 224*c303c47eSjoerg check-cxx-cxxabi 225*c303c47eSjoerg check-abi-list 226*c303c47eSjoerg;; 227*c303c47eSjoerggeneric-cxx2b) 228*c303c47eSjoerg export CC=clang-tot 229*c303c47eSjoerg export CXX=clang++-tot 230*c303c47eSjoerg clean 231*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx2b.cmake" \ 232*c303c47eSjoerg -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/libcxx-trunk-shared.cfg.in" 233*c303c47eSjoerg check-cxx-cxxabi 234*c303c47eSjoerg check-abi-list 235*c303c47eSjoerg;; 236*c303c47eSjoerggeneric-debug-iterators) 237*c303c47eSjoerg export CC=clang-tot 238*c303c47eSjoerg export CXX=clang++-tot 239*c303c47eSjoerg clean 240*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-debug-iterators.cmake" 241*c303c47eSjoerg check-cxx-cxxabi 242*c303c47eSjoerg check-abi-list 243*c303c47eSjoerg;; 244*c303c47eSjoerggeneric-noexceptions) 245*c303c47eSjoerg export CC=clang 246*c303c47eSjoerg export CXX=clang++ 247*c303c47eSjoerg clean 248*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-noexceptions.cmake" 249*c303c47eSjoerg check-cxx-cxxabi 250*c303c47eSjoerg;; 251*c303c47eSjoerggeneric-static) 252*c303c47eSjoerg export CC=clang 253*c303c47eSjoerg export CXX=clang++ 254*c303c47eSjoerg clean 255*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-static.cmake" \ 256*c303c47eSjoerg -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/libcxx-trunk-static.cfg.in" 257*c303c47eSjoerg check-cxx-cxxabi 258*c303c47eSjoerg;; 259*c303c47eSjoerggeneric-32bit) 260*c303c47eSjoerg export CC=clang 261*c303c47eSjoerg export CXX=clang++ 262*c303c47eSjoerg clean 263*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-32bits.cmake" 264*c303c47eSjoerg check-cxx-cxxabi 265*c303c47eSjoerg;; 266*c303c47eSjoerggeneric-gcc) 267*c303c47eSjoerg export CC=gcc 268*c303c47eSjoerg export CXX=g++ 269*c303c47eSjoerg clean 270*c303c47eSjoerg generate-cmake 271*c303c47eSjoerg check-cxx-cxxabi 272*c303c47eSjoerg;; 273*c303c47eSjoerggeneric-asan) 274*c303c47eSjoerg export CC=clang 275*c303c47eSjoerg export CXX=clang++ 276*c303c47eSjoerg clean 277*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-asan.cmake" 278*c303c47eSjoerg check-cxx-cxxabi 279*c303c47eSjoerg;; 280*c303c47eSjoerggeneric-msan) 281*c303c47eSjoerg export CC=clang 282*c303c47eSjoerg export CXX=clang++ 283*c303c47eSjoerg clean 284*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-msan.cmake" 285*c303c47eSjoerg check-cxx-cxxabi 286*c303c47eSjoerg;; 287*c303c47eSjoerggeneric-tsan) 288*c303c47eSjoerg export CC=clang 289*c303c47eSjoerg export CXX=clang++ 290*c303c47eSjoerg clean 291*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-tsan.cmake" 292*c303c47eSjoerg check-cxx-cxxabi 293*c303c47eSjoerg;; 294*c303c47eSjoerggeneric-ubsan) 295*c303c47eSjoerg export CC=clang 296*c303c47eSjoerg export CXX=clang++ 297*c303c47eSjoerg clean 298*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-ubsan.cmake" 299*c303c47eSjoerg check-cxx-cxxabi 300*c303c47eSjoerg;; 301*c303c47eSjoerggeneric-with_llvm_unwinder) 302*c303c47eSjoerg export CC=clang 303*c303c47eSjoerg export CXX=clang++ 304*c303c47eSjoerg clean 305*c303c47eSjoerg generate-cmake -DLIBCXXABI_USE_LLVM_UNWINDER=ON 306*c303c47eSjoerg check-cxx-cxxabi 307*c303c47eSjoerg;; 308*c303c47eSjoerggeneric-singlethreaded) 309*c303c47eSjoerg export CC=clang 310*c303c47eSjoerg export CXX=clang++ 311*c303c47eSjoerg clean 312*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-singlethreaded.cmake" 313*c303c47eSjoerg check-cxx-cxxabi 314*c303c47eSjoerg;; 315*c303c47eSjoerggeneric-no-debug) 316*c303c47eSjoerg export CC=clang 317*c303c47eSjoerg export CXX=clang++ 318*c303c47eSjoerg clean 319*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-debug.cmake" 320*c303c47eSjoerg check-cxx-cxxabi 321*c303c47eSjoerg;; 322*c303c47eSjoerggeneric-no-filesystem) 323*c303c47eSjoerg export CC=clang 324*c303c47eSjoerg export CXX=clang++ 325*c303c47eSjoerg clean 326*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-filesystem.cmake" 327*c303c47eSjoerg check-cxx-cxxabi 328*c303c47eSjoerg;; 329*c303c47eSjoerggeneric-no-random_device) 330*c303c47eSjoerg export CC=clang 331*c303c47eSjoerg export CXX=clang++ 332*c303c47eSjoerg clean 333*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-random_device.cmake" 334*c303c47eSjoerg check-cxx-cxxabi 335*c303c47eSjoerg;; 336*c303c47eSjoerggeneric-no-localization) 337*c303c47eSjoerg export CC=clang 338*c303c47eSjoerg export CXX=clang++ 339*c303c47eSjoerg clean 340*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake" 341*c303c47eSjoerg check-cxx-cxxabi 342*c303c47eSjoerg;; 343*c303c47eSjoergx86_64-apple-system) 344*c303c47eSjoerg export CC=clang 345*c303c47eSjoerg export CXX=clang++ 346*c303c47eSjoerg clean 347*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" 348*c303c47eSjoerg check-cxx-cxxabi 349*c303c47eSjoerg;; 350*c303c47eSjoergx86_64-apple-system-noexceptions) 351*c303c47eSjoerg export CC=clang 352*c303c47eSjoerg export CXX=clang++ 353*c303c47eSjoerg clean 354*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \ 355*c303c47eSjoerg -DLIBCXX_ENABLE_EXCEPTIONS=OFF \ 356*c303c47eSjoerg -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF 357*c303c47eSjoerg check-cxx-cxxabi 358*c303c47eSjoerg;; 359*c303c47eSjoergx86_64-apple-system-backdeployment-*) 360*c303c47eSjoerg clean 361*c303c47eSjoerg 362*c303c47eSjoerg if [[ "${OSX_ROOTS}" == "" ]]; then 363*c303c47eSjoerg echo "--- Downloading previous macOS dylibs" 364*c303c47eSjoerg PREVIOUS_DYLIBS_URL="https://dl.dropboxusercontent.com/s/liu4fmc53qzlfly/libcxx-roots.tar.gz" 365*c303c47eSjoerg OSX_ROOTS="${BUILD_DIR}/macos-roots" 366*c303c47eSjoerg mkdir -p "${OSX_ROOTS}" 367*c303c47eSjoerg curl "${PREVIOUS_DYLIBS_URL}" | tar -xz --strip-components=1 -C "${OSX_ROOTS}" 368*c303c47eSjoerg fi 369*c303c47eSjoerg 370*c303c47eSjoerg DEPLOYMENT_TARGET="${BUILDER#x86_64-apple-system-backdeployment-}" 371*c303c47eSjoerg 372*c303c47eSjoerg # TODO: On Apple platforms, we never produce libc++abi.1.dylib, always libc++abi.dylib. 373*c303c47eSjoerg # Fix that in the build so that the tests stop searching for @rpath/libc++abi.1.dylib. 374*c303c47eSjoerg cp "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.dylib" \ 375*c303c47eSjoerg "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.1.dylib" 376*c303c47eSjoerg 377*c303c47eSjoerg PARAMS="target_triple=x86_64-apple-macosx${DEPLOYMENT_TARGET}" 378*c303c47eSjoerg PARAMS+=";cxx_runtime_root=${OSX_ROOTS}/macOS/libc++/${DEPLOYMENT_TARGET}" 379*c303c47eSjoerg PARAMS+=";abi_runtime_root=${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}" 380*c303c47eSjoerg PARAMS+=";use_system_cxx_lib=True" 381*c303c47eSjoerg 382*c303c47eSjoerg export CC=clang 383*c303c47eSjoerg export CXX=clang++ 384*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \ 385*c303c47eSjoerg -DLIBCXX_TEST_PARAMS="${PARAMS}" \ 386*c303c47eSjoerg -DLIBCXXABI_TEST_PARAMS="${PARAMS}" 387*c303c47eSjoerg 388*c303c47eSjoerg check-cxx-cxxabi 389*c303c47eSjoerg;; 390*c303c47eSjoergbenchmarks) 391*c303c47eSjoerg export CC=clang 392*c303c47eSjoerg export CXX=clang++ 393*c303c47eSjoerg clean 394*c303c47eSjoerg generate-cmake 395*c303c47eSjoerg check-cxx-benchmarks 396*c303c47eSjoerg;; 397*c303c47eSjoergdocumentation) 398*c303c47eSjoerg export CC=clang 399*c303c47eSjoerg export CXX=clang++ 400*c303c47eSjoerg clean 401*c303c47eSjoerg generate-cmake -DLLVM_ENABLE_SPHINX=ON 402*c303c47eSjoerg 403*c303c47eSjoerg echo "+++ Generating documentation" 404*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" docs-libcxx-html 405*c303c47eSjoerg;; 406*c303c47eSjoergunified-standalone) 407*c303c47eSjoerg export CC=clang 408*c303c47eSjoerg export CXX=clang++ 409*c303c47eSjoerg 410*c303c47eSjoerg clean 411*c303c47eSjoerg 412*c303c47eSjoerg echo "--- Generating CMake" 413*c303c47eSjoerg ${CMAKE} \ 414*c303c47eSjoerg -S "${MONOREPO_ROOT}/libcxx/utils/ci/runtimes" \ 415*c303c47eSjoerg -B "${BUILD_DIR}" \ 416*c303c47eSjoerg -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ 417*c303c47eSjoerg -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 418*c303c47eSjoerg -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ 419*c303c47eSjoerg -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi;libunwind" 420*c303c47eSjoerg 421*c303c47eSjoerg check-cxx-cxxabi 422*c303c47eSjoerg;; 423*c303c47eSjoergruntimes-build) 424*c303c47eSjoerg export CC=clang 425*c303c47eSjoerg export CXX=clang++ 426*c303c47eSjoerg 427*c303c47eSjoerg clean 428*c303c47eSjoerg 429*c303c47eSjoerg echo "--- Generating CMake" 430*c303c47eSjoerg ${CMAKE} \ 431*c303c47eSjoerg -S "${MONOREPO_ROOT}/llvm" \ 432*c303c47eSjoerg -B "${BUILD_DIR}" \ 433*c303c47eSjoerg -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ 434*c303c47eSjoerg -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 435*c303c47eSjoerg -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ 436*c303c47eSjoerg -DLLVM_ENABLE_PROJECTS="clang" \ 437*c303c47eSjoerg -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \ 438*c303c47eSjoerg -DLLVM_RUNTIME_TARGETS="x86_64-unknown-linux-gnu" 439*c303c47eSjoerg 440*c303c47eSjoerg echo "+++ Running the libc++ and libc++abi tests" 441*c303c47eSjoerg ${NINJA} -C "${BUILD_DIR}" check-runtimes 442*c303c47eSjoerg 443*c303c47eSjoerg echo "--- Installing libc++ and libc++abi to a fake location" 444*c303c47eSjoerg ${NINJA} -C "${BUILD_DIR}" install-cxx install-cxxabi 445*c303c47eSjoerg;; 446*c303c47eSjoerglegacy-test-config) 447*c303c47eSjoerg export CC=clang 448*c303c47eSjoerg export CXX=clang++ 449*c303c47eSjoerg clean 450*c303c47eSjoerg generate-cmake -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/legacy.cfg.in" 451*c303c47eSjoerg check-cxx-cxxabi 452*c303c47eSjoerg;; 453*c303c47eSjoerglegacy-standalone) 454*c303c47eSjoerg export CC=clang 455*c303c47eSjoerg export CXX=clang++ 456*c303c47eSjoerg 457*c303c47eSjoerg clean 458*c303c47eSjoerg 459*c303c47eSjoerg echo "--- Generating CMake" 460*c303c47eSjoerg ${CMAKE} \ 461*c303c47eSjoerg -S "${MONOREPO_ROOT}/libcxx" \ 462*c303c47eSjoerg -B "${BUILD_DIR}/libcxx" \ 463*c303c47eSjoerg -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ 464*c303c47eSjoerg -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 465*c303c47eSjoerg -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ 466*c303c47eSjoerg -DLLVM_PATH="${MONOREPO_ROOT}/llvm" \ 467*c303c47eSjoerg -DLIBCXX_CXX_ABI=libcxxabi \ 468*c303c47eSjoerg -DLIBCXX_CXX_ABI_INCLUDE_PATHS="${MONOREPO_ROOT}/libcxxabi/include" \ 469*c303c47eSjoerg -DLIBCXX_CXX_ABI_LIBRARY_PATH="${BUILD_DIR}/libcxxabi/lib" 470*c303c47eSjoerg 471*c303c47eSjoerg ${CMAKE} \ 472*c303c47eSjoerg -S "${MONOREPO_ROOT}/libcxxabi" \ 473*c303c47eSjoerg -B "${BUILD_DIR}/libcxxabi" \ 474*c303c47eSjoerg -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ 475*c303c47eSjoerg -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 476*c303c47eSjoerg -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ 477*c303c47eSjoerg -DLLVM_PATH="${MONOREPO_ROOT}/llvm" \ 478*c303c47eSjoerg -DLIBCXXABI_LIBCXX_PATH="${MONOREPO_ROOT}/libcxx" \ 479*c303c47eSjoerg -DLIBCXXABI_LIBCXX_INCLUDES="${BUILD_DIR}/libcxx/include/c++/v1" \ 480*c303c47eSjoerg -DLIBCXXABI_LIBCXX_LIBRARY_PATH="${BUILD_DIR}/libcxx/lib" 481*c303c47eSjoerg 482*c303c47eSjoerg echo "+++ Generating libc++ headers" 483*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}/libcxx" generate-cxx-headers 484*c303c47eSjoerg 485*c303c47eSjoerg echo "+++ Building libc++abi" 486*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}/libcxxabi" cxxabi 487*c303c47eSjoerg 488*c303c47eSjoerg echo "+++ Building libc++" 489*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}/libcxx" cxx 490*c303c47eSjoerg 491*c303c47eSjoerg echo "+++ Running the libc++ tests" 492*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}/libcxx" check-cxx 493*c303c47eSjoerg 494*c303c47eSjoerg echo "+++ Running the libc++abi tests" 495*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}/libcxxabi" check-cxxabi 496*c303c47eSjoerg;; 497*c303c47eSjoergaarch64) 498*c303c47eSjoerg clean 499*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" 500*c303c47eSjoerg check-cxx-cxxabi 501*c303c47eSjoerg;; 502*c303c47eSjoergaarch64-noexceptions) 503*c303c47eSjoerg clean 504*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \ 505*c303c47eSjoerg -DLIBCXX_ENABLE_EXCEPTIONS=OFF \ 506*c303c47eSjoerg -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF 507*c303c47eSjoerg check-cxx-cxxabi 508*c303c47eSjoerg;; 509*c303c47eSjoerg# Aka Armv8 32 bit 510*c303c47eSjoergarmv8) 511*c303c47eSjoerg clean 512*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake" 513*c303c47eSjoerg check-cxx-cxxabi 514*c303c47eSjoerg;; 515*c303c47eSjoergarmv8-noexceptions) 516*c303c47eSjoerg clean 517*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-noexceptions.cmake" 518*c303c47eSjoerg check-cxx-cxxabi 519*c303c47eSjoerg;; 520*c303c47eSjoerg# Armv7 32 bit. One building Arm only one Thumb only code. 521*c303c47eSjoergarmv7) 522*c303c47eSjoerg clean 523*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake" 524*c303c47eSjoerg check-cxx-cxxabi 525*c303c47eSjoerg;; 526*c303c47eSjoergarmv7-noexceptions) 527*c303c47eSjoerg clean 528*c303c47eSjoerg generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-noexceptions.cmake" 529*c303c47eSjoerg check-cxx-cxxabi 530*c303c47eSjoerg;; 531*c303c47eSjoergwindows-dll) 532*c303c47eSjoerg clean 533*c303c47eSjoerg # TODO: Currently, building with the experimental library breaks running 534*c303c47eSjoerg # tests (the test linking look for the c++experimental library with the 535*c303c47eSjoerg # wrong name, and the statically linked c++experimental can't be linked 536*c303c47eSjoerg # correctly when libc++ visibility attributes indicate dllimport linkage 537*c303c47eSjoerg # anyway), thus just disable the experimental library. Remove this 538*c303c47eSjoerg # setting when cmake and the test driver does the right thing automatically. 539*c303c47eSjoerg generate-cmake-libcxx-win -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF 540*c303c47eSjoerg echo "+++ Running the libc++ tests" 541*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" check-cxx 542*c303c47eSjoerg;; 543*c303c47eSjoergwindows-static) 544*c303c47eSjoerg clean 545*c303c47eSjoerg generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF 546*c303c47eSjoerg echo "+++ Running the libc++ tests" 547*c303c47eSjoerg ${NINJA} -vC "${BUILD_DIR}" check-cxx 548*c303c47eSjoerg;; 549*c303c47eSjoerg*) 550*c303c47eSjoerg echo "${BUILDER} is not a known configuration" 551*c303c47eSjoerg exit 1 552*c303c47eSjoerg;; 553*c303c47eSjoergesac 554