1#!/usr/bin/env bash 2#===----------------------------------------------------------------------===## 3# 4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5# See https://llvm.org/LICENSE.txt for license information. 6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7# 8#===----------------------------------------------------------------------===## 9 10set -ex 11set -o pipefail 12unset LANG 13unset LC_ALL 14unset LC_COLLATE 15 16PROGNAME="$(basename "${0}")" 17 18function usage() { 19cat <<EOF 20Usage: 21${PROGNAME} [options] <BUILDER> 22 23[-h|--help] Display this help and exit. 24 25--llvm-root <DIR> Path to the root of the LLVM monorepo. By default, we try 26 to figure it out based on the current working directory. 27 28--build-dir <DIR> The directory to use for building the library. By default, 29 this is '<llvm-root>/build/<builder>'. 30 31--osx-roots <DIR> Path to pre-downloaded macOS dylibs. By default, we download 32 them from Green Dragon. This is only relevant at all when 33 running back-deployment testing if one wants to override 34 the old dylibs we use to run the tests with different ones. 35Environment variables 36CC The C compiler to use, this value is used by CMake. This 37 variable is optional. 38 39CXX The C++ compiler to use, this value is used by CMake. This 40 variable is optional. 41 42CMAKE The CMake binary to use. This variable is optional. 43 44CLANG_FORMAT The clang-format binary to use when generating the format 45 ignore list. 46 47ENABLE_CLANG_TIDY Whether to compile and run clang-tidy checks. This variable 48 is optional. 49 50ENABLE_STD_MODULES Whether to enable or disable building the C++23 std 51 modules. This variable is optional. 52 TODO MODULES remove when all supported compilers support 53 modules. 54 55EOF 56} 57 58if [[ $# == 0 ]]; then 59 usage 60 exit 0 61fi 62 63while [[ $# -gt 0 ]]; do 64 case ${1} in 65 -h|--help) 66 usage 67 exit 0 68 ;; 69 --llvm-root) 70 MONOREPO_ROOT="${2}" 71 shift; shift 72 ;; 73 --build-dir) 74 BUILD_DIR="${2}" 75 shift; shift 76 ;; 77 --osx-roots) 78 OSX_ROOTS="${2}" 79 shift; shift 80 ;; 81 *) 82 BUILDER="${1}" 83 shift 84 ;; 85 esac 86done 87 88MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}" 89BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}" 90INSTALL_DIR="${BUILD_DIR}/install" 91 92# If we can find Ninja/CMake provided by Xcode, use those since we know their 93# version will generally work with the Clang shipped in Xcode (e.g. if Clang 94# knows about -std=c++20, the CMake bundled in Xcode will probably know about 95# that flag too). 96if xcrun --find ninja &>/dev/null; then 97 NINJA="$(xcrun --find ninja)" 98elif which ninja &>/dev/null; then 99 # The current implementation of modules needs the absolute path to the ninja 100 # binary. 101 # TODO MODULES Is this still needed when CMake has libc++ module support? 102 NINJA="$(which ninja)" 103else 104 NINJA="ninja" 105fi 106 107if [ -z "${CMAKE}" ]; then 108 if xcrun --find cmake &>/dev/null; then 109 CMAKE="$(xcrun --find cmake)" 110 else 111 CMAKE="cmake" 112 fi 113fi 114 115function clean() { 116 rm -rf "${BUILD_DIR}" 117} 118 119if [ -z "${ENABLE_CLANG_TIDY}" ]; then 120 ENABLE_CLANG_TIDY=Off 121fi 122 123if [ -n "${ENABLE_STD_MODULES}" ]; then 124 ENABLE_STD_MODULES="-DLIBCXX_ENABLE_STD_MODULES=${ENABLE_STD_MODULES}" 125fi 126 127function generate-cmake-base() { 128 echo "--- Generating CMake" 129 ${CMAKE} \ 130 -S "${MONOREPO_ROOT}/runtimes" \ 131 -B "${BUILD_DIR}" \ 132 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ 133 -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 134 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ 135 -DLIBCXX_ENABLE_WERROR=YES \ 136 -DLIBCXXABI_ENABLE_WERROR=YES \ 137 -DLIBUNWIND_ENABLE_WERROR=YES \ 138 -DLIBCXX_ENABLE_CLANG_TIDY=${ENABLE_CLANG_TIDY} \ 139 ${ENABLE_STD_MODULES} \ 140 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \ 141 "${@}" 142} 143 144function generate-cmake() { 145 generate-cmake-base \ 146 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ 147 -DLIBCXX_CXX_ABI=libcxxabi \ 148 "${@}" 149} 150 151function generate-cmake-libcxx-win() { 152 generate-cmake-base \ 153 -DLLVM_ENABLE_RUNTIMES="libcxx" \ 154 -DCMAKE_C_COMPILER=clang-cl \ 155 -DCMAKE_CXX_COMPILER=clang-cl \ 156 "${@}" 157} 158 159function generate-cmake-android() { 160 generate-cmake-base \ 161 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \ 162 -DLIBCXX_CXX_ABI=libcxxabi \ 163 "${@}" 164} 165 166function check-runtimes() { 167 echo "+++ Running the libc++ tests" 168 ${NINJA} -vC "${BUILD_DIR}" check-cxx 169 170 echo "+++ Running the libc++abi tests" 171 ${NINJA} -vC "${BUILD_DIR}" check-cxxabi 172 173 echo "+++ Running the libunwind tests" 174 ${NINJA} -vC "${BUILD_DIR}" check-unwind 175 176 # TODO: On macOS 13.5, the linker seems to have an issue where it will pick up 177 # a library if it exists inside a -L search path, even if we don't link 178 # against that library. This happens with libunwind.dylib if it is built 179 # at the point when we run the libc++ tests, which causes issues cause we 180 # are also linking against the system unwinder. 181 # 182 # I believe this is a linker regression and I reported it as rdar://115842730. 183 # It should be possible to move this installation step back to the top once 184 # that issue has been resolved, but in the meantime it doesn't really hurt to 185 # have it here. 186 echo "--- Installing libc++, libc++abi and libunwind to a fake location" 187 ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi install-unwind 188} 189 190# TODO: The goal is to test this against all configurations. We should also move 191# this to the Lit test suite instead of being a separate CMake target. 192function check-abi-list() { 193 echo "+++ Running the libc++ ABI list test" 194 ${NINJA} -vC "${BUILD_DIR}" check-cxx-abilist || ( 195 echo "+++ Generating the libc++ ABI list after failed check" 196 ${NINJA} -vC "${BUILD_DIR}" generate-cxx-abilist 197 false 198 ) 199} 200 201function check-cxx-benchmarks() { 202 echo "--- Running the benchmarks" 203 ${NINJA} -vC "${BUILD_DIR}" check-cxx-benchmarks 204} 205 206# Print the version of a few tools to aid diagnostics in some cases 207${CMAKE} --version 208${NINJA} --version 209 210if [ ! -z "${CXX}" ]; then ${CXX} --version; fi 211 212case "${BUILDER}" in 213check-generated-output) 214 # `! foo` doesn't work properly with `set -e`, use `! foo || false` instead. 215 # https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not 216 clean 217 generate-cmake 218 219 set +x # Printing all the commands below just creates extremely confusing output 220 221 # Reject patches that forgot to re-run the generator scripts. 222 echo "+++ Making sure the generator scripts were run" 223 ${NINJA} -vC "${BUILD_DIR}" libcxx-generate-files 224 git diff | tee ${BUILD_DIR}/generated_output.patch 225 git ls-files -o --exclude-standard | tee ${BUILD_DIR}/generated_output.status 226 ! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false 227 if [ -s ${BUILD_DIR}/generated_output.status ]; then 228 echo "It looks like not all the generator scripts were run," 229 echo "did you forget to build the libcxx-generate-files target?" 230 echo "Did you add all new files it generated?" 231 false 232 fi 233 234 # Reject patches that introduce non-ASCII characters or hard tabs. 235 # Depends on LC_COLLATE set at the top of this script. 236 set -x 237 ! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test libcxx/benchmarks \ 238 --exclude '*.dat' \ 239 --exclude '*unicode*.cpp' \ 240 --exclude '*print*.sh.cpp' \ 241 --exclude 'escaped_output.*.pass.cpp' \ 242 --exclude 'format_tests.h' \ 243 --exclude 'format.functions.tests.h' \ 244 --exclude 'formatter.*.pass.cpp' \ 245 --exclude 'grep.pass.cpp' \ 246 --exclude 'locale-specific_form.pass.cpp' \ 247 --exclude 'ostream.pass.cpp' \ 248 --exclude 'transcoding.pass.cpp' \ 249 --exclude 'underflow.pass.cpp' \ 250 || false 251;; 252# 253# Various Standard modes 254# 255generic-cxx03) 256 clean 257 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake" 258 check-runtimes 259 check-abi-list 260;; 261generic-cxx11) 262 clean 263 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" 264 check-runtimes 265 check-abi-list 266;; 267generic-cxx14) 268 clean 269 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake" 270 check-runtimes 271 check-abi-list 272;; 273generic-cxx17) 274 clean 275 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake" 276 check-runtimes 277 check-abi-list 278;; 279generic-cxx20) 280 clean 281 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake" 282 check-runtimes 283 check-abi-list 284;; 285generic-cxx23) 286 clean 287 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx23.cmake" 288 check-runtimes 289 check-abi-list 290;; 291generic-cxx26) 292 clean 293 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx26.cmake" 294 check-runtimes 295 check-abi-list 296;; 297# 298# Other compiler support 299# 300generic-gcc) 301 clean 302 generate-cmake -DLIBCXX_ENABLE_WERROR=NO \ 303 -DLIBCXXABI_ENABLE_WERROR=NO \ 304 -DLIBUNWIND_ENABLE_WERROR=NO 305 check-runtimes 306;; 307generic-gcc-cxx11) 308 clean 309 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" \ 310 -DLIBCXX_ENABLE_WERROR=NO \ 311 -DLIBCXXABI_ENABLE_WERROR=NO \ 312 -DLIBUNWIND_ENABLE_WERROR=NO 313 check-runtimes 314;; 315# 316# Sanitizers 317# 318generic-asan) 319 clean 320 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-asan.cmake" 321 check-runtimes 322;; 323generic-msan) 324 clean 325 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-msan.cmake" 326 check-runtimes 327;; 328generic-tsan) 329 clean 330 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-tsan.cmake" 331 check-runtimes 332;; 333generic-ubsan) 334 clean 335 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-ubsan.cmake" 336 check-runtimes 337;; 338# 339# Various build configurations 340# 341bootstrapping-build) 342 clean 343 344 echo "--- Generating CMake" 345 ${CMAKE} \ 346 -S "${MONOREPO_ROOT}/llvm" \ 347 -B "${BUILD_DIR}" \ 348 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ 349 -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \ 350 -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 351 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ 352 -DLLVM_ENABLE_PROJECTS="clang" \ 353 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ 354 -DLLVM_RUNTIME_TARGETS="$(${CXX} --print-target-triple)" \ 355 -DLLVM_TARGETS_TO_BUILD="host" \ 356 -DRUNTIMES_BUILD_ALLOW_DARWIN=ON \ 357 -DLLVM_ENABLE_ASSERTIONS=ON \ 358 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" 359 360 echo "+++ Running the libc++ and libc++abi tests" 361 ${NINJA} -vC "${BUILD_DIR}" check-runtimes 362 363 echo "--- Installing libc++ and libc++abi to a fake location" 364 ${NINJA} -vC "${BUILD_DIR}" install-runtimes 365 366 ccache -s 367;; 368generic-static) 369 clean 370 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-static.cmake" 371 check-runtimes 372;; 373generic-merged) 374 clean 375 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-merged.cmake" \ 376 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in" \ 377 -DLIBCXXABI_TEST_CONFIG="llvm-libc++abi-merged.cfg.in" \ 378 -DLIBUNWIND_TEST_CONFIG="llvm-libunwind-merged.cfg.in" 379 check-runtimes 380;; 381generic-hardening-mode-fast) 382 clean 383 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast.cmake" 384 check-runtimes 385 check-abi-list 386;; 387generic-hardening-mode-fast-with-abi-breaks) 388 clean 389 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast-with-abi-breaks.cmake" 390 check-runtimes 391 check-abi-list 392;; 393generic-hardening-mode-extensive) 394 clean 395 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake" 396 check-runtimes 397 check-abi-list 398;; 399generic-hardening-mode-debug) 400 clean 401 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-debug.cmake" 402 check-runtimes 403 check-abi-list 404;; 405generic-with_llvm_unwinder) 406 clean 407 generate-cmake -DLIBCXXABI_USE_LLVM_UNWINDER=ON 408 check-runtimes 409;; 410# 411# Module builds 412# 413generic-modules) 414 clean 415 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules.cmake" 416 check-runtimes 417 check-abi-list 418;; 419generic-modules-lsv) 420 clean 421 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules-lsv.cmake" 422 check-runtimes 423 check-abi-list 424;; 425# 426# Parts removed 427# 428generic-no-threads) 429 clean 430 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-threads.cmake" 431 check-runtimes 432;; 433generic-no-filesystem) 434 clean 435 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-filesystem.cmake" 436 check-runtimes 437;; 438generic-no-random_device) 439 clean 440 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-random_device.cmake" 441 check-runtimes 442;; 443generic-no-localization) 444 clean 445 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake" 446 check-runtimes 447;; 448generic-no-unicode) 449 clean 450 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake" 451 check-runtimes 452;; 453generic-no-wide-characters) 454 clean 455 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-wide-characters.cmake" 456 check-runtimes 457;; 458generic-no-tzdb) 459 clean 460 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-tzdb.cmake" 461 check-runtimes 462;; 463generic-no-experimental) 464 clean 465 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-experimental.cmake" 466 check-runtimes 467 check-abi-list 468;; 469generic-no-exceptions) 470 clean 471 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-exceptions.cmake" 472 check-runtimes 473 check-abi-list 474;; 475# 476# Other miscellaneous jobs 477# 478generic-abi-unstable) 479 clean 480 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-abi-unstable.cmake" 481 check-runtimes 482;; 483apple-system) 484 clean 485 486 arch="$(uname -m)" 487 xcrun --sdk macosx \ 488 ${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh \ 489 --llvm-root ${MONOREPO_ROOT} \ 490 --build-dir ${BUILD_DIR} \ 491 --install-dir ${INSTALL_DIR} \ 492 --symbols-dir "${BUILD_DIR}/symbols" \ 493 --architectures "${arch}" \ 494 --version "999.99" 495 496 # TODO: It would be better to run the tests against the fake-installed version of libc++ instead 497 xcrun --sdk macosx ninja -vC "${BUILD_DIR}/${arch}" check-cxx check-cxxabi check-cxx-abilist 498;; 499apple-system-backdeployment-hardened-*) 500 clean 501 502 if [[ "${OSX_ROOTS}" == "" ]]; then 503 echo "--- Downloading previous macOS dylibs" 504 PREVIOUS_DYLIBS_URL="https://dl.dropboxusercontent.com/s/gmcfxwgl9f9n6pu/libcxx-roots.tar.gz" 505 OSX_ROOTS="${BUILD_DIR}/macos-roots" 506 mkdir -p "${OSX_ROOTS}" 507 curl "${PREVIOUS_DYLIBS_URL}" | tar -xz --strip-components=1 -C "${OSX_ROOTS}" 508 fi 509 510 DEPLOYMENT_TARGET="${BUILDER#apple-system-backdeployment-hardened-}" 511 512 # TODO: On Apple platforms, we never produce libc++abi.1.dylib or libunwind.1.dylib, 513 # only libc++abi.dylib and libunwind.dylib. Fix that in the build so that the 514 # tests stop searching for @rpath/libc++abi.1.dylib and @rpath/libunwind.1.dylib. 515 cp "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.dylib" \ 516 "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.1.dylib" 517 cp "${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}/libunwind.dylib" \ 518 "${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}/libunwind.1.dylib" 519 520 arch="$(uname -m)" 521 PARAMS="target_triple=${arch}-apple-macosx${DEPLOYMENT_TARGET}" 522 PARAMS+=";cxx_runtime_root=${OSX_ROOTS}/macOS/libc++/${DEPLOYMENT_TARGET}" 523 PARAMS+=";abi_runtime_root=${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}" 524 PARAMS+=";unwind_runtime_root=${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}" 525 PARAMS+=";hardening_mode=fast" 526 527 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \ 528 -DLIBCXX_TEST_CONFIG="apple-libc++-backdeployment.cfg.in" \ 529 -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-backdeployment.cfg.in" \ 530 -DLIBUNWIND_TEST_CONFIG="apple-libunwind-backdeployment.cfg.in" \ 531 -DLIBCXX_TEST_PARAMS="${PARAMS}" \ 532 -DLIBCXXABI_TEST_PARAMS="${PARAMS}" \ 533 -DLIBUNWIND_TEST_PARAMS="${PARAMS}" 534 535 check-runtimes 536;; 537apple-system-backdeployment-*) 538 clean 539 540 if [[ "${OSX_ROOTS}" == "" ]]; then 541 echo "--- Downloading previous macOS dylibs" 542 PREVIOUS_DYLIBS_URL="https://dl.dropboxusercontent.com/s/gmcfxwgl9f9n6pu/libcxx-roots.tar.gz" 543 OSX_ROOTS="${BUILD_DIR}/macos-roots" 544 mkdir -p "${OSX_ROOTS}" 545 curl "${PREVIOUS_DYLIBS_URL}" | tar -xz --strip-components=1 -C "${OSX_ROOTS}" 546 fi 547 548 DEPLOYMENT_TARGET="${BUILDER#apple-system-backdeployment-}" 549 550 # TODO: On Apple platforms, we never produce libc++abi.1.dylib or libunwind.1.dylib, 551 # only libc++abi.dylib and libunwind.dylib. Fix that in the build so that the 552 # tests stop searching for @rpath/libc++abi.1.dylib and @rpath/libunwind.1.dylib. 553 cp "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.dylib" \ 554 "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.1.dylib" 555 cp "${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}/libunwind.dylib" \ 556 "${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}/libunwind.1.dylib" 557 558 arch="$(uname -m)" 559 PARAMS="target_triple=${arch}-apple-macosx${DEPLOYMENT_TARGET}" 560 PARAMS+=";cxx_runtime_root=${OSX_ROOTS}/macOS/libc++/${DEPLOYMENT_TARGET}" 561 PARAMS+=";abi_runtime_root=${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}" 562 PARAMS+=";unwind_runtime_root=${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}" 563 564 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \ 565 -DLIBCXX_TEST_CONFIG="apple-libc++-backdeployment.cfg.in" \ 566 -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-backdeployment.cfg.in" \ 567 -DLIBUNWIND_TEST_CONFIG="apple-libunwind-backdeployment.cfg.in" \ 568 -DLIBCXX_TEST_PARAMS="${PARAMS}" \ 569 -DLIBCXXABI_TEST_PARAMS="${PARAMS}" \ 570 -DLIBUNWIND_TEST_PARAMS="${PARAMS}" 571 572 check-runtimes 573;; 574benchmarks) 575 clean 576 generate-cmake 577 check-cxx-benchmarks 578;; 579aarch64) 580 clean 581 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" 582 check-runtimes 583;; 584aarch64-no-exceptions) 585 clean 586 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \ 587 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \ 588 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF 589 check-runtimes 590;; 591# Aka Armv8 32 bit 592armv8) 593 clean 594 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake" 595 check-runtimes 596;; 597armv8-no-exceptions) 598 clean 599 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-no-exceptions.cmake" 600 check-runtimes 601;; 602# Armv7 32 bit. One building Arm only one Thumb only code. 603armv7) 604 clean 605 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake" 606 check-runtimes 607;; 608armv7-no-exceptions) 609 clean 610 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-no-exceptions.cmake" 611 check-runtimes 612;; 613armv7m-picolibc) 614 clean 615 616 # To make it easier to get this builder up and running, build picolibc 617 # from scratch. Anecdotally, the build-picolibc script takes about 16 seconds. 618 # This could be optimised by building picolibc into the Docker container. 619 ${MONOREPO_ROOT}/libcxx/utils/ci/build-picolibc.sh \ 620 --build-dir "${BUILD_DIR}" \ 621 --install-dir "${INSTALL_DIR}" \ 622 --target armv7m-none-eabi 623 624 echo "--- Generating CMake" 625 flags="--sysroot=${INSTALL_DIR}" 626 ${CMAKE} \ 627 -S "${MONOREPO_ROOT}/compiler-rt" \ 628 -B "${BUILD_DIR}/compiler-rt" \ 629 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ 630 -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 631 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ 632 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \ 633 -DCMAKE_C_FLAGS="${flags}" \ 634 -DCMAKE_CXX_FLAGS="${flags}" \ 635 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON 636 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \ 637 -DLIBCXX_TEST_CONFIG="armv7m-picolibc-libc++.cfg.in" \ 638 -DLIBCXXABI_TEST_CONFIG="armv7m-picolibc-libc++abi.cfg.in" \ 639 -DLIBUNWIND_TEST_CONFIG="armv7m-picolibc-libunwind.cfg.in" \ 640 -DCMAKE_C_FLAGS="${flags}" \ 641 -DCMAKE_CXX_FLAGS="${flags}" 642 643 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install 644 mv "${BUILD_DIR}/install/lib/armv7m-none-eabi"/* "${BUILD_DIR}/install/lib" 645 646 check-runtimes 647;; 648clang-cl-dll) 649 clean 650 # TODO: Currently, building with the experimental library breaks running 651 # tests (the test linking look for the c++experimental library with the 652 # wrong name, and the statically linked c++experimental can't be linked 653 # correctly when libc++ visibility attributes indicate dllimport linkage 654 # anyway), thus just disable the experimental library. Remove this 655 # setting when cmake and the test driver does the right thing automatically. 656 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" 657 echo "+++ Running the libc++ tests" 658 ${NINJA} -vC "${BUILD_DIR}" check-cxx 659;; 660clang-cl-static) 661 clean 662 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF 663 echo "+++ Running the libc++ tests" 664 ${NINJA} -vC "${BUILD_DIR}" check-cxx 665;; 666clang-cl-no-vcruntime) 667 clean 668 # Building libc++ in the same way as in clang-cl-dll above, but running 669 # tests with -D_HAS_EXCEPTIONS=0, which users might set in certain 670 # translation units while using libc++, even if libc++ is built with 671 # exceptions enabled. 672 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \ 673 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared-no-vcruntime-clangcl.cfg.in" 674 echo "+++ Running the libc++ tests" 675 ${NINJA} -vC "${BUILD_DIR}" check-cxx 676;; 677clang-cl-debug) 678 clean 679 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \ 680 -DCMAKE_BUILD_TYPE=Debug 681 echo "+++ Running the libc++ tests" 682 ${NINJA} -vC "${BUILD_DIR}" check-cxx 683;; 684clang-cl-static-crt) 685 clean 686 # Test linking a static libc++ with the static CRT ("MultiThreaded" denotes 687 # the static CRT, as opposed to "MultiThreadedDLL" which is the default). 688 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \ 689 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded 690 echo "+++ Running the libc++ tests" 691 ${NINJA} -vC "${BUILD_DIR}" check-cxx 692;; 693mingw-dll) 694 clean 695 # Explicitly specify the compiler with a triple prefix. The CI 696 # environment has got two installations of Clang; the default one 697 # defaults to MSVC mode, while there's an installation of llvm-mingw 698 # further back in PATH. By calling the compiler with an explicit 699 # triple prefix, we use the one that is bundled with a mingw sysroot. 700 generate-cmake \ 701 -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \ 702 -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++ \ 703 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" 704 check-runtimes 705;; 706mingw-static) 707 clean 708 generate-cmake \ 709 -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \ 710 -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++ \ 711 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" \ 712 -DLIBCXX_ENABLE_SHARED=OFF \ 713 -DLIBUNWIND_ENABLE_SHARED=OFF 714 check-runtimes 715;; 716mingw-dll-i686) 717 clean 718 generate-cmake \ 719 -DCMAKE_C_COMPILER=i686-w64-mingw32-clang \ 720 -DCMAKE_CXX_COMPILER=i686-w64-mingw32-clang++ \ 721 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" 722 check-runtimes 723;; 724aix) 725 clean 726 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AIX.cmake" \ 727 -DLIBCXX_TEST_CONFIG="ibm-libc++-shared.cfg.in" \ 728 -DLIBCXXABI_TEST_CONFIG="ibm-libc++abi-shared.cfg.in" \ 729 -DLIBUNWIND_TEST_CONFIG="ibm-libunwind-shared.cfg.in" 730 check-abi-list 731 check-runtimes 732;; 733android-ndk-*) 734 clean 735 736 ANDROID_EMU_IMG="${BUILDER#android-ndk-}" 737 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/emulator-functions.sh" 738 if ! validate_emu_img "${ANDROID_EMU_IMG}"; then 739 echo "error: android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG})" >&2 740 exit 1 741 fi 742 ARCH=$(arch_of_emu_img ${ANDROID_EMU_IMG}) 743 744 # Use the Android compiler by default. 745 export CC=${CC:-/opt/android/clang/clang-current/bin/clang} 746 export CXX=${CXX:-/opt/android/clang/clang-current/bin/clang++} 747 748 # The NDK libc++_shared.so is always built against the oldest supported API 749 # level. When tests are run against a device with a newer API level, test 750 # programs can be built for any supported API level, but building for the 751 # newest API (i.e. the system image's API) is probably the most interesting. 752 PARAMS="target_triple=$(triple_of_arch ${ARCH})$(api_of_emu_img ${ANDROID_EMU_IMG})" 753 generate-cmake-android -C "${MONOREPO_ROOT}/runtimes/cmake/android/Arch-${ARCH}.cmake" \ 754 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AndroidNDK.cmake" \ 755 -DCMAKE_SYSROOT=/opt/android/ndk/sysroot \ 756 -DLIBCXX_TEST_PARAMS="${PARAMS}" \ 757 -DLIBCXXABI_TEST_PARAMS="${PARAMS}" 758 ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi 759 760 # Start the emulator and make sure we can connect to the adb server running 761 # inside of it. 762 "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/start-emulator.sh" ${ANDROID_EMU_IMG} 763 trap "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/stop-emulator.sh" EXIT 764 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/setup-env-for-emulator.sh" 765 766 # Create adb_run early to avoid concurrent `mkdir -p` of common parent 767 # directories. 768 adb shell mkdir -p /data/local/tmp/adb_run 769 adb push "${BUILD_DIR}/lib/libc++_shared.so" /data/local/tmp/libc++/libc++_shared.so 770 echo "+++ Running the libc++ tests" 771 ${NINJA} -vC "${BUILD_DIR}" check-cxx 772 echo "+++ Running the libc++abi tests" 773 ${NINJA} -vC "${BUILD_DIR}" check-cxxabi 774;; 775################################################################# 776# Insert vendor-specific internal configurations below. 777# 778# This allows vendors to extend this file with their own internal 779# configurations without running into merge conflicts with upstream. 780################################################################# 781 782################################################################# 783*) 784 echo "${BUILDER} is not a known configuration" 785 exit 1 786;; 787esac 788