793 lines · plain
1#!/usr/bin/env bash2# ===----------------------------------------------------------------------===##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-exception7#8# ===----------------------------------------------------------------------===##9 10set -e11set -o pipefail12unset LANG13unset LC_ALL14unset LC_COLLATE15 16PROGNAME="$(basename "${0}")"17 18function usage() {19cat <<EOF20Usage: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 try26 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 31Environment variables32CC The C compiler to use, this value is used by CMake. This33 variable is optional.34 35CXX The C++ compiler to use, this value is used by CMake. This36 variable is optional.37 38CLANG_FORMAT The clang-format binary to use when generating the format39 ignore list.40 41EOF42}43 44if [[ $# == 0 ]]; then45 usage46 exit 047fi48 49while [[ $# -gt 0 ]]; do50 case ${1} in51 -h|--help)52 usage53 exit 054 ;;55 --llvm-root)56 MONOREPO_ROOT="${2}"57 shift; shift58 ;;59 --build-dir)60 BUILD_DIR="${2}"61 shift; shift62 ;;63 *)64 BUILDER="${1}"65 shift66 ;;67 esac68done69 70MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"71BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"72INSTALL_DIR="${BUILD_DIR}/install"73 74function step() {75 endstep76 set +x77 if [[ ! -z ${GITHUB_ACTIONS+x} ]]; then78 echo "::group::$1"79 export IN_GROUP=180 else81 echo "--- $1"82 fi83 set -x84}85 86function endstep() {87 set +x88 if [[ ! -z ${GITHUB_ACTIONS+x} ]] && [[ ! -z ${IN_GROUP+x} ]]; then89 echo "::endgroup::"90 unset IN_GROUP91 fi92 set -x93}94 95function error() {96 echo "::error::$1"97}98 99function clean() {100 rm -rf "${BUILD_DIR}"101}102 103function generate-cmake-base() {104 step "Generating CMake"105 106 # We can remove -DCMAKE_INSTALL_MESSAGE=NEVER once https://gitlab.kitware.com/cmake/cmake/-/issues/26085 is fixed.107 cmake \108 -S "${MONOREPO_ROOT}/runtimes" \109 -B "${BUILD_DIR}" \110 -GNinja \111 -DCMAKE_BUILD_TYPE=RelWithDebInfo \112 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \113 -DLIBCXX_ENABLE_WERROR=YES \114 -DLIBCXXABI_ENABLE_WERROR=YES \115 -DLIBUNWIND_ENABLE_WERROR=YES \116 -DCMAKE_INSTALL_MESSAGE=NEVER \117 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \118 "${@}"119}120 121function generate-cmake() {122 generate-cmake-base \123 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \124 -DLIBCXX_CXX_ABI=libcxxabi \125 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \126 "${@}"127}128 129function generate-cmake-libcxx-win() {130 generate-cmake-base \131 -DLLVM_ENABLE_RUNTIMES="libcxx" \132 -DCMAKE_C_COMPILER=clang-cl \133 -DCMAKE_CXX_COMPILER=clang-cl \134 "${@}"135}136 137function generate-cmake-android() {138 generate-cmake-base \139 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \140 -DLIBCXX_CXX_ABI=libcxxabi \141 "${@}"142}143 144function check-runtimes() {145 step "Building libc++ test dependencies"146 ninja -vC "${BUILD_DIR}" cxx-test-depends147 148 step "Running the libc++ tests"149 ninja -vC "${BUILD_DIR}" check-cxx150 151 step "Running the libc++abi tests"152 ninja -vC "${BUILD_DIR}" check-cxxabi153 154 step "Running the libunwind tests"155 ninja -vC "${BUILD_DIR}" check-unwind156}157 158# TODO: The goal is to test this against all configurations. We should also move159# this to the Lit test suite instead of being a separate CMake target.160function check-abi-list() {161 step "Running the libc++ ABI list test"162 ninja -vC "${BUILD_DIR}" check-cxx-abilist || (163 error "Generating the libc++ ABI list after failed check"164 ninja -vC "${BUILD_DIR}" generate-cxx-abilist165 false166 )167}168 169function test-armv7m-picolibc() {170 clean171 172 # To make it easier to get this builder up and running, build picolibc173 # from scratch. Anecdotally, the build-picolibc script takes about 16 seconds.174 # This could be optimised by building picolibc into the Docker container.175 step "Building picolibc from source"176 ${MONOREPO_ROOT}/libcxx/utils/ci/build-picolibc.sh \177 --build-dir "${BUILD_DIR}" \178 --install-dir "${INSTALL_DIR}" \179 --target armv7m-none-eabi180 181 step "Generating CMake for compiler-rt"182 flags="--sysroot=${INSTALL_DIR}"183 # LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON means that we produce a file184 # libclang_rt.builtins.a that will be installed to185 # ${INSTALL_DIR}/lib/armv7m-unknown-none-eabi/.186 # With LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF, the filename includes the187 # architecture name, which is not what Clang's driver expects to find.188 # The install location will however be wrong with189 # LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON, so we correct that below.190 cmake \191 -S "${MONOREPO_ROOT}/compiler-rt" \192 -B "${BUILD_DIR}/compiler-rt" \193 -GNinja \194 -DCMAKE_BUILD_TYPE=RelWithDebInfo \195 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \196 -DCMAKE_C_FLAGS="${flags}" \197 -DCMAKE_CXX_FLAGS="${flags}" \198 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \199 "${@}"200 201 step "Generating CMake for libc++"202 generate-cmake \203 -DLIBCXX_TEST_CONFIG="armv7m-picolibc-libc++.cfg.in" \204 -DLIBCXXABI_TEST_CONFIG="armv7m-picolibc-libc++abi.cfg.in" \205 -DLIBUNWIND_TEST_CONFIG="armv7m-picolibc-libunwind.cfg.in" \206 -DCMAKE_C_FLAGS="${flags}" \207 -DCMAKE_CXX_FLAGS="${flags}" \208 -DRUNTIMES_USE_LIBC=picolibc \209 "${@}"210 211 step "Installing compiler-rt"212 ninja -vC "${BUILD_DIR}/compiler-rt" install213 # Move compiler-rt libs into the same directory as all the picolib objects.214 mv "${INSTALL_DIR}/lib/armv7m-unknown-none-eabi"/* "${INSTALL_DIR}/lib"215 216 check-runtimes217}218 219# Print the version of a few tools to aid diagnostics in some cases220step "Diagnose tools in use"221cmake --version222ninja --version223if [ ! -z "${CXX}" ]; then ${CXX} --version; fi224 225case "${BUILDER}" in226check-generated-output)227 # `! foo` doesn't work properly with `set -e`, use `! foo || false` instead.228 # https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not229 clean230 generate-cmake231 232 # Reject patches that forgot to re-run the generator scripts.233 step "Making sure the generator scripts were run"234 set +x # Printing all the commands below just creates extremely confusing output235 ninja -vC "${BUILD_DIR}" libcxx-generate-files236 git diff | tee ${BUILD_DIR}/generated_output.patch237 git ls-files -o --exclude-standard | tee ${BUILD_DIR}/generated_output.status238 ! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false239 if [ -s ${BUILD_DIR}/generated_output.status ]; then240 echo "It looks like not all the generator scripts were run,"241 echo "did you forget to build the libcxx-generate-files target?"242 echo "Did you add all new files it generated?"243 false244 fi245 246 # This depends on LC_COLLATE set at the top of this script.247 step "Reject patches that introduce non-ASCII characters or hard tabs."248 ! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test \249 --exclude '*.dat' \250 --exclude '*unicode*.cpp' \251 --exclude '*print*.sh.cpp' \252 --exclude 'escaped_output.*.pass.cpp' \253 --exclude 'format_tests.h' \254 --exclude 'format.functions.tests.h' \255 --exclude 'formatter.*.pass.cpp' \256 --exclude 'grep.pass.cpp' \257 --exclude 'locale-specific_form.pass.cpp' \258 --exclude 'ostream.pass.cpp' \259 --exclude 'transcoding.pass.cpp' \260 --exclude 'underflow.pass.cpp' \261 || false262;;263#264# Various Standard modes265#266frozen-cxx03-headers)267 clean268 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03-frozen.cmake"269 check-runtimes270 check-abi-list271;;272generic-cxx03)273 clean274 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake"275 check-runtimes276 check-abi-list277;;278generic-cxx11)279 clean280 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake"281 check-runtimes282 check-abi-list283;;284generic-cxx14)285 clean286 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake"287 check-runtimes288 check-abi-list289;;290generic-cxx17)291 clean292 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake"293 check-runtimes294 check-abi-list295;;296generic-cxx20)297 clean298 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake"299 check-runtimes300 check-abi-list301;;302generic-cxx23)303 clean304 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx23.cmake"305 check-runtimes306 check-abi-list307;;308generic-cxx26)309 clean310 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx26.cmake"311 check-runtimes312 check-abi-list313;;314#315# Other compiler support316#317generic-gcc)318 clean319 generate-cmake -DLIBCXX_ENABLE_WERROR=NO \320 -DLIBCXXABI_ENABLE_WERROR=NO \321 -DLIBUNWIND_ENABLE_WERROR=NO322 check-runtimes323;;324generic-gcc-cxx11)325 clean326 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" \327 -DLIBCXX_ENABLE_WERROR=NO \328 -DLIBCXXABI_ENABLE_WERROR=NO \329 -DLIBUNWIND_ENABLE_WERROR=NO330 check-runtimes331;;332#333# Sanitizers334#335generic-asan)336 clean337 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-asan.cmake"338 check-runtimes339;;340generic-msan)341 clean342 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-msan.cmake"343 check-runtimes344;;345generic-tsan)346 clean347 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-tsan.cmake"348 check-runtimes349;;350generic-ubsan)351 clean352 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-ubsan.cmake"353 check-runtimes354;;355#356# Various build configurations357#358bootstrapping-build)359 clean360 361 step "Generating CMake"362 cmake \363 -S "${MONOREPO_ROOT}/llvm" \364 -B "${BUILD_DIR}" \365 -GNinja \366 -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \367 -DCMAKE_BUILD_TYPE=Release \368 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \369 -DLLVM_ENABLE_PROJECTS="clang;lldb" \370 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt" \371 -DLLVM_RUNTIME_TARGETS="$(${CXX} --print-target-triple)" \372 -DLLVM_HOST_TRIPLE="$(${CXX} --print-target-triple)" \373 -DLLVM_TARGETS_TO_BUILD="host" \374 -DRUNTIMES_BUILD_ALLOW_DARWIN=ON \375 -DCOMPILER_RT_INCLUDE_TESTS=OFF \376 -DLLVM_ENABLE_ASSERTIONS=ON \377 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests"378 379 step "Running the libc++ and libc++abi tests"380 ninja -vC "${BUILD_DIR}" check-runtimes381 382 step "Installing libc++ and libc++abi to a fake location"383 ninja -vC "${BUILD_DIR}" install-runtimes384 385 step "Running the LLDB libc++ data formatter tests"386 ninja -vC "${BUILD_DIR}" lldb-api-test-deps387 ${BUILD_DIR}/bin/llvm-lit -sv --param dotest-args='--category libc++' "${MONOREPO_ROOT}/lldb/test/API"388 389 ccache -s390;;391generic-static)392 clean393 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-static.cmake"394 check-runtimes395;;396generic-merged)397 clean398 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-merged.cmake" \399 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in" \400 -DLIBCXXABI_TEST_CONFIG="llvm-libc++abi-merged.cfg.in" \401 -DLIBUNWIND_TEST_CONFIG="llvm-libunwind-merged.cfg.in"402 check-runtimes403;;404generic-hardening-mode-fast)405 clean406 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast.cmake"407 check-runtimes408 check-abi-list409;;410generic-hardening-mode-fast-with-abi-breaks)411 clean412 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast-with-abi-breaks.cmake"413 check-runtimes414 # Not checking ABI list since we purposefully enable ABI breaking changes415;;416generic-hardening-mode-extensive)417 clean418 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake"419 check-runtimes420 check-abi-list421;;422generic-hardening-mode-extensive-observe-semantic)423 clean424 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-extensive-observe-semantic.cmake"425 check-runtimes426 check-abi-list427;;428generic-hardening-mode-debug)429 clean430 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-debug.cmake"431 check-runtimes432 check-abi-list433;;434#435# Module builds436#437generic-modules)438 clean439 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules.cmake"440 check-runtimes441 check-abi-list442;;443generic-modules-cxx17-lsv)444 clean445 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules-cxx17-lsv.cmake"446 check-runtimes447 check-abi-list448;;449#450# Parts removed451#452generic-no-threads)453 clean454 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-threads.cmake"455 check-runtimes456;;457generic-no-filesystem)458 clean459 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-filesystem.cmake"460 check-runtimes461;;462generic-no-random_device)463 clean464 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-random_device.cmake"465 check-runtimes466;;467generic-no-localization)468 clean469 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"470 check-runtimes471;;472generic-no-terminal)473 clean474 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-terminal.cmake"475 check-runtimes476;;477generic-no-unicode)478 clean479 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake"480 check-runtimes481;;482generic-no-wide-characters)483 clean484 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-wide-characters.cmake"485 check-runtimes486;;487generic-no-tzdb)488 clean489 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-tzdb.cmake"490 check-runtimes491;;492generic-no-experimental)493 clean494 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-experimental.cmake"495 check-runtimes496 check-abi-list497;;498generic-no-exceptions)499 clean500 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-exceptions.cmake"501 check-runtimes502 check-abi-list503;;504generic-no-rtti)505 clean506 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-rtti.cmake"507 check-runtimes508;;509#510# Other miscellaneous jobs511#512generic-abi-unstable)513 clean514 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-abi-unstable.cmake"515 check-runtimes516;;517generic-optimized-speed)518 clean519 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-optimized-speed.cmake"520 check-runtimes521;;522apple-configuration)523 clean524 525 step "Installing libc++ with the Apple system configuration"526 arch="$(uname -m)"527 xcrun --sdk macosx \528 ${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh \529 --llvm-root ${MONOREPO_ROOT} \530 --build-dir ${BUILD_DIR} \531 --install-dir ${INSTALL_DIR} \532 --symbols-dir "${BUILD_DIR}/symbols" \533 --architectures "${arch}" \534 --version "999.99"535 536 step "Running tests against Apple-configured libc++"537 # TODO: It would be better to run the tests against the fake-installed version of libc++ instead538 xcrun --sdk macosx ninja -vC "${BUILD_DIR}/${arch}" check-cxx check-cxxabi check-cxx-abilist539;;540apple-system|apple-system-hardened)541 clean542 543 arch="$(uname -m)"544 version="$(sw_vers --productVersion)"545 params="target_triple=${arch}-apple-macosx${version}"546 if [[ "${BUILDER}" == *-hardened ]]; then547 params+=";hardening_mode=fast"548 fi549 550 # In the Apple system configuration, we build libc++ and libunwind separately.551 step "Installing libc++ and libc++abi in Apple-system configuration"552 cmake \553 -S "${MONOREPO_ROOT}/runtimes" \554 -B "${BUILD_DIR}/cxx" \555 -GNinja \556 -DCMAKE_BUILD_TYPE=RelWithDebInfo \557 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/cxx" \558 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \559 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \560 -DLIBCXX_CXX_ABI=libcxxabi \561 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \562 -DLIBCXX_TEST_CONFIG="apple-libc++-system.cfg.in" \563 -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-system.cfg.in" \564 -DLIBCXX_TEST_PARAMS="${params}" \565 -DLIBCXXABI_TEST_PARAMS="${params}"566 567 step "Installing libunwind in Apple-system configuration"568 cmake \569 -S "${MONOREPO_ROOT}/runtimes" \570 -B "${BUILD_DIR}/unwind" \571 -GNinja \572 -DCMAKE_BUILD_TYPE=RelWithDebInfo \573 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/unwind" \574 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \575 -DLLVM_ENABLE_RUNTIMES="libunwind" \576 -DLIBUNWIND_TEST_CONFIG="apple-libunwind-system.cfg.in" \577 -DLIBUNWIND_TEST_PARAMS="${params}" \578 -DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"579 580 step "Running the libc++ tests"581 ninja -vC "${BUILD_DIR}/cxx" check-cxx582 583 step "Running the libc++abi tests"584 ninja -vC "${BUILD_DIR}/cxx" check-cxxabi585 586 step "Running the libunwind tests"587 ninja -vC "${BUILD_DIR}/unwind" check-unwind588;;589aarch64)590 clean591 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake"592 check-runtimes593;;594aarch64-no-exceptions)595 clean596 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \597 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \598 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF599 check-runtimes600;;601# Aka Armv8 32 bit602armv8)603 clean604 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake"605 check-runtimes606;;607armv8-no-exceptions)608 clean609 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-no-exceptions.cmake"610 check-runtimes611;;612# Armv7 32 bit. One building Arm only one Thumb only code.613armv7)614 clean615 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake"616 check-runtimes617;;618armv7-no-exceptions)619 clean620 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-no-exceptions.cmake"621 check-runtimes622;;623armv7m-picolibc)624 test-armv7m-picolibc \625 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake"626;;627armv7m-picolibc-no-exceptions)628 test-armv7m-picolibc \629 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \630 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \631 -DLIBCXXABI_ENABLE_STATIC_UNWINDER=OFF \632 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \633 -DLIBCXX_ENABLE_RTTI=OFF634;;635clang-cl-dll)636 clean637 # TODO: Currently, building with the experimental library breaks running638 # tests (the test linking look for the c++experimental library with the639 # wrong name, and the statically linked c++experimental can't be linked640 # correctly when libc++ visibility attributes indicate dllimport linkage641 # anyway), thus just disable the experimental library. Remove this642 # setting when cmake and the test driver does the right thing automatically.643 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False"644 step "Running the libc++ tests"645 ninja -vC "${BUILD_DIR}" check-cxx646;;647clang-cl-static)648 clean649 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF650 step "Running the libc++ tests"651 ninja -vC "${BUILD_DIR}" check-cxx652;;653clang-cl-no-vcruntime)654 clean655 # Building libc++ in the same way as in clang-cl-dll above, but running656 # tests with -D_HAS_EXCEPTIONS=0, which users might set in certain657 # translation units while using libc++, even if libc++ is built with658 # exceptions enabled.659 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \660 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared-no-vcruntime-clangcl.cfg.in"661 step "Running the libc++ tests"662 ninja -vC "${BUILD_DIR}" check-cxx663;;664clang-cl-debug)665 clean666 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \667 -DCMAKE_BUILD_TYPE=Debug668 step "Running the libc++ tests"669 ninja -vC "${BUILD_DIR}" check-cxx670;;671clang-cl-static-crt)672 clean673 # Test linking a static libc++ with the static CRT ("MultiThreaded" denotes674 # the static CRT, as opposed to "MultiThreadedDLL" which is the default).675 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \676 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded677 step "Running the libc++ tests"678 ninja -vC "${BUILD_DIR}" check-cxx679;;680mingw-dll)681 clean682 generate-cmake \683 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"684 check-runtimes685;;686mingw-static)687 clean688 generate-cmake \689 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" \690 -DLIBCXX_ENABLE_SHARED=OFF \691 -DLIBUNWIND_ENABLE_SHARED=OFF692 check-runtimes693;;694mingw-dll-i686)695 clean696 generate-cmake \697 -DCMAKE_C_COMPILER=i686-w64-mingw32-clang \698 -DCMAKE_CXX_COMPILER=i686-w64-mingw32-clang++ \699 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"700 check-runtimes701;;702mingw-incomplete-sysroot)703 # When bringing up a new cross compiler from scratch, we build704 # libunwind/libcxx in a setup where the toolchain is incomplete and705 # unable to perform the normal linker checks; this requires a few706 # special cases in the CMake files.707 #708 # Building in an incomplete setup requires setting CMAKE_*_COMPILER_WORKS,709 # as CMake fails to probe the compiler. This case also requires710 # setting CMAKE_CXX_COMPILER_TARGET, as LLVM's heuristics for setting711 # the triple fails when CMake hasn't been able to probe the environment.712 # (This is what one has to do when building the initial libunwind/libcxx713 # for a new toolchain.)714 clean715 generate-cmake \716 -DCMAKE_C_COMPILER_WORKS=TRUE \717 -DCMAKE_CXX_COMPILER_WORKS=TRUE \718 -DCMAKE_C_COMPILER_TARGET=x86_64-w64-windows-gnu \719 -DCMAKE_CXX_COMPILER_TARGET=x86_64-w64-windows-gnu \720 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"721 # Only test that building succeeds; there's not much extra value in running722 # the tests here, as it would be equivalent to the mingw-dll config above.723 step "Building the runtimes"724 ninja -vC "${BUILD_DIR}"725;;726aix)727 clean728 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AIX.cmake" \729 -DLIBCXX_TEST_CONFIG="ibm-libc++-shared.cfg.in" \730 -DLIBCXXABI_TEST_CONFIG="ibm-libc++abi-shared.cfg.in" \731 -DLIBUNWIND_TEST_CONFIG="ibm-libunwind-shared.cfg.in"732 check-abi-list733 check-runtimes734;;735android-ndk-*)736 clean737 738 ANDROID_EMU_IMG="${BUILDER#android-ndk-}"739 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/emulator-functions.sh"740 if ! validate_emu_img "${ANDROID_EMU_IMG}"; then741 error "android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG})" >&2742 exit 1743 fi744 ARCH=$(arch_of_emu_img ${ANDROID_EMU_IMG})745 746 # Use the Android compiler by default.747 export CC=${CC:-/opt/android/clang/clang-current/bin/clang}748 export CXX=${CXX:-/opt/android/clang/clang-current/bin/clang++}749 750 # The NDK libc++_shared.so is always built against the oldest supported API751 # level. When tests are run against a device with a newer API level, test752 # programs can be built for any supported API level, but building for the753 # newest API (i.e. the system image's API) is probably the most interesting.754 PARAMS="executor=${MONOREPO_ROOT}/libcxx/utils/adb_run.py;target_triple=$(triple_of_arch ${ARCH})$(api_of_emu_img ${ANDROID_EMU_IMG})"755 generate-cmake-android -C "${MONOREPO_ROOT}/runtimes/cmake/android/Arch-${ARCH}.cmake" \756 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AndroidNDK.cmake" \757 -DCMAKE_SYSROOT=/opt/android/ndk/sysroot \758 -DLIBCXX_TEST_PARAMS="${PARAMS}" \759 -DLIBCXXABI_TEST_PARAMS="${PARAMS}"760 check-abi-list761 ninja -vC "${BUILD_DIR}" install-cxx install-cxxabi762 763 # Start the emulator and make sure we can connect to the adb server running764 # inside of it.765 "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/start-emulator.sh" ${ANDROID_EMU_IMG}766 trap "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/stop-emulator.sh" EXIT767 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/setup-env-for-emulator.sh"768 769 # Create adb_run early to avoid concurrent `mkdir -p` of common parent770 # directories.771 adb shell mkdir -p /data/local/tmp/adb_run772 adb push "${BUILD_DIR}/lib/libc++_shared.so" /data/local/tmp/libc++/libc++_shared.so773 step "Running the libc++ tests"774 ninja -vC "${BUILD_DIR}" check-cxx775 step "Running the libc++abi tests"776 ninja -vC "${BUILD_DIR}" check-cxxabi777;;778#################################################################779# Insert vendor-specific internal configurations below.780#781# This allows vendors to extend this file with their own internal782# configurations without running into merge conflicts with upstream.783#################################################################784 785#################################################################786*)787 echo "${BUILDER} is not a known configuration"788 exit 1789;;790esac791 792endstep # Make sure we close any still-open output group793