[Frontend] Remove unused includes (NFC) (#116927)
[llvm-project.git] / libcxx / utils / ci / run-buildbot
blob3df7b00a8aa09d4e304f4429e6388673c93da5ee
1 #!/usr/bin/env bash
2 # ===----------------------------------------------------------------------===##
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
8 # ===----------------------------------------------------------------------===##
10 set -e
11 set -o pipefail
12 unset LANG
13 unset LC_ALL
14 unset LC_COLLATE
16 PROGNAME="$(basename "${0}")"
18 function usage() {
19 cat <<EOF
20 Usage:
21 ${PROGNAME} [options] <BUILDER>
23 [-h|--help] Display this help and exit.
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.
28 --build-dir <DIR> The directory to use for building the library. By default,
29 this is '<llvm-root>/build/<builder>'.
31 Environment variables
32 CC The C compiler to use, this value is used by CMake. This
33 variable is optional.
35 CXX The C++ compiler to use, this value is used by CMake. This
36 variable is optional.
38 CMAKE The CMake binary to use. This variable is optional.
40 CLANG_FORMAT The clang-format binary to use when generating the format
41 ignore list.
43 EOF
46 if [[ $# == 0 ]]; then
47 usage
48 exit 0
51 while [[ $# -gt 0 ]]; do
52 case ${1} in
53 -h|--help)
54 usage
55 exit 0
57 --llvm-root)
58 MONOREPO_ROOT="${2}"
59 shift; shift
61 --build-dir)
62 BUILD_DIR="${2}"
63 shift; shift
66 BUILDER="${1}"
67 shift
69 esac
70 done
72 MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
73 BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
74 INSTALL_DIR="${BUILD_DIR}/install"
76 # If we can find Ninja/CMake provided by Xcode, use those since we know their
77 # version will generally work with the Clang shipped in Xcode (e.g. if Clang
78 # knows about -std=c++20, the CMake bundled in Xcode will probably know about
79 # that flag too).
80 if xcrun --find ninja &>/dev/null; then
81 NINJA="$(xcrun --find ninja)"
82 elif which ninja &>/dev/null; then
83 # The current implementation of modules needs the absolute path to the ninja
84 # binary.
85 # TODO MODULES Is this still needed when CMake has libc++ module support?
86 NINJA="$(which ninja)"
87 else
88 NINJA="ninja"
91 if [ -z "${CMAKE}" ]; then
92 if xcrun --find cmake &>/dev/null; then
93 CMAKE="$(xcrun --find cmake)"
94 else
95 CMAKE="cmake"
99 function step() {
100 endstep
101 set +x
102 if [[ ! -z ${GITHUB_ACTIONS+x} ]]; then
103 echo "::group::$1"
104 export IN_GROUP=1
105 else
106 echo "--- $1"
108 set -x
111 function endstep() {
112 set +x
113 if [[ ! -z ${GITHUB_ACTIONS+x} ]] && [[ ! -z ${IN_GROUP+x} ]]; then
114 echo "::endgroup::"
115 unset IN_GROUP
117 set -x
120 function error() {
121 echo "::error::$1"
124 function clean() {
125 rm -rf "${BUILD_DIR}"
128 function generate-cmake-base() {
129 step "Generating CMake"
130 ${CMAKE} \
131 -S "${MONOREPO_ROOT}/runtimes" \
132 -B "${BUILD_DIR}" \
133 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
134 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
135 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
136 -DLIBCXX_ENABLE_WERROR=YES \
137 -DLIBCXXABI_ENABLE_WERROR=YES \
138 -DLIBUNWIND_ENABLE_WERROR=YES \
139 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
140 "${@}"
143 function generate-cmake() {
144 generate-cmake-base \
145 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
146 -DLIBCXX_CXX_ABI=libcxxabi \
147 "${@}"
150 function generate-cmake-libcxx-win() {
151 generate-cmake-base \
152 -DLLVM_ENABLE_RUNTIMES="libcxx" \
153 -DCMAKE_C_COMPILER=clang-cl \
154 -DCMAKE_CXX_COMPILER=clang-cl \
155 "${@}"
158 function generate-cmake-android() {
159 generate-cmake-base \
160 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
161 -DLIBCXX_CXX_ABI=libcxxabi \
162 "${@}"
165 function check-runtimes() {
166 step "Building libc++ test dependencies"
167 ${NINJA} -vC "${BUILD_DIR}" cxx-test-depends
169 step "Running the libc++ tests"
170 ${NINJA} -vC "${BUILD_DIR}" check-cxx
172 step "Running the libc++abi tests"
173 ${NINJA} -vC "${BUILD_DIR}" check-cxxabi
175 step "Running the libunwind tests"
176 ${NINJA} -vC "${BUILD_DIR}" check-unwind
179 # TODO: The goal is to test this against all configurations. We should also move
180 # this to the Lit test suite instead of being a separate CMake target.
181 function check-abi-list() {
182 step "Running the libc++ ABI list test"
183 ${NINJA} -vC "${BUILD_DIR}" check-cxx-abilist || (
184 error "Generating the libc++ ABI list after failed check"
185 ${NINJA} -vC "${BUILD_DIR}" generate-cxx-abilist
186 false
190 function test-armv7m-picolibc() {
191 clean
193 # To make it easier to get this builder up and running, build picolibc
194 # from scratch. Anecdotally, the build-picolibc script takes about 16 seconds.
195 # This could be optimised by building picolibc into the Docker container.
196 step "Building picolibc from source"
197 ${MONOREPO_ROOT}/libcxx/utils/ci/build-picolibc.sh \
198 --build-dir "${BUILD_DIR}" \
199 --install-dir "${INSTALL_DIR}" \
200 --target armv7m-none-eabi
202 step "Generating CMake for compiler-rt"
203 flags="--sysroot=${INSTALL_DIR}"
204 ${CMAKE} \
205 -S "${MONOREPO_ROOT}/compiler-rt" \
206 -B "${BUILD_DIR}/compiler-rt" \
207 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
208 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
209 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
210 -DCMAKE_C_FLAGS="${flags}" \
211 -DCMAKE_CXX_FLAGS="${flags}" \
212 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
213 "${@}"
215 step "Generating CMake for libc++"
216 generate-cmake \
217 -DLIBCXX_TEST_CONFIG="armv7m-picolibc-libc++.cfg.in" \
218 -DLIBCXXABI_TEST_CONFIG="armv7m-picolibc-libc++abi.cfg.in" \
219 -DLIBUNWIND_TEST_CONFIG="armv7m-picolibc-libunwind.cfg.in" \
220 -DCMAKE_C_FLAGS="${flags}" \
221 -DCMAKE_CXX_FLAGS="${flags}" \
222 "${@}"
224 step "Installing compiler-rt"
225 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
227 # Prior to clang 19, armv7m-none-eabi normalised to armv7m-none-unknown-eabi.
228 # clang 19 changed this to armv7m-unknown-none-eabi. So for as long as 18.x
229 # is supported, we have to ask clang what the triple will be.
230 NORMALISED_TARGET_TRIPLE=$(${CC-cc} --target=armv7m-none-eabi -print-target-triple)
231 # Without this step linking fails later in the build.
232 mv "${BUILD_DIR}/install/lib/${NORMALISED_TARGET_TRIPLE}"/* "${BUILD_DIR}/install/lib"
234 check-runtimes
237 # Print the version of a few tools to aid diagnostics in some cases
238 step "Diagnose tools in use"
239 ${CMAKE} --version
240 ${NINJA} --version
241 if [ ! -z "${CXX}" ]; then ${CXX} --version; fi
243 case "${BUILDER}" in
244 check-generated-output)
245 # `! foo` doesn't work properly with `set -e`, use `! foo || false` instead.
246 # https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not
247 clean
248 generate-cmake
250 # Reject patches that forgot to re-run the generator scripts.
251 step "Making sure the generator scripts were run"
252 set +x # Printing all the commands below just creates extremely confusing output
253 ${NINJA} -vC "${BUILD_DIR}" libcxx-generate-files
254 git diff | tee ${BUILD_DIR}/generated_output.patch
255 git ls-files -o --exclude-standard | tee ${BUILD_DIR}/generated_output.status
256 ! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false
257 if [ -s ${BUILD_DIR}/generated_output.status ]; then
258 echo "It looks like not all the generator scripts were run,"
259 echo "did you forget to build the libcxx-generate-files target?"
260 echo "Did you add all new files it generated?"
261 false
264 # This depends on LC_COLLATE set at the top of this script.
265 step "Reject patches that introduce non-ASCII characters or hard tabs."
266 ! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test \
267 --exclude '*.dat' \
268 --exclude '*unicode*.cpp' \
269 --exclude '*print*.sh.cpp' \
270 --exclude 'escaped_output.*.pass.cpp' \
271 --exclude 'format_tests.h' \
272 --exclude 'format.functions.tests.h' \
273 --exclude 'formatter.*.pass.cpp' \
274 --exclude 'grep.pass.cpp' \
275 --exclude 'locale-specific_form.pass.cpp' \
276 --exclude 'ostream.pass.cpp' \
277 --exclude 'transcoding.pass.cpp' \
278 --exclude 'underflow.pass.cpp' \
279 || false
282 # Various Standard modes
284 generic-cxx03)
285 clean
286 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake"
287 check-runtimes
288 check-abi-list
290 generic-cxx11)
291 clean
292 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake"
293 check-runtimes
294 check-abi-list
296 generic-cxx14)
297 clean
298 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake"
299 check-runtimes
300 check-abi-list
302 generic-cxx17)
303 clean
304 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake"
305 check-runtimes
306 check-abi-list
308 generic-cxx20)
309 clean
310 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake"
311 check-runtimes
312 check-abi-list
314 generic-cxx23)
315 clean
316 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx23.cmake"
317 check-runtimes
318 check-abi-list
320 generic-cxx26)
321 clean
322 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx26.cmake"
323 check-runtimes
324 check-abi-list
327 # Other compiler support
329 generic-gcc)
330 clean
331 generate-cmake -DLIBCXX_ENABLE_WERROR=NO \
332 -DLIBCXXABI_ENABLE_WERROR=NO \
333 -DLIBUNWIND_ENABLE_WERROR=NO
334 check-runtimes
336 generic-gcc-cxx11)
337 clean
338 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" \
339 -DLIBCXX_ENABLE_WERROR=NO \
340 -DLIBCXXABI_ENABLE_WERROR=NO \
341 -DLIBUNWIND_ENABLE_WERROR=NO
342 check-runtimes
345 # Sanitizers
347 generic-asan)
348 clean
349 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-asan.cmake"
350 check-runtimes
352 generic-msan)
353 clean
354 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-msan.cmake"
355 check-runtimes
357 generic-tsan)
358 clean
359 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-tsan.cmake"
360 check-runtimes
362 generic-ubsan)
363 clean
364 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-ubsan.cmake"
365 check-runtimes
368 # Various build configurations
370 bootstrapping-build)
371 clean
373 step "Generating CMake"
374 ${CMAKE} \
375 -S "${MONOREPO_ROOT}/llvm" \
376 -B "${BUILD_DIR}" \
377 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
378 -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
379 -DCMAKE_BUILD_TYPE=Release \
380 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
381 -DLLVM_ENABLE_PROJECTS="clang;lldb" \
382 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
383 -DLLVM_RUNTIME_TARGETS="$(${CXX} --print-target-triple)" \
384 -DLLVM_HOST_TRIPLE="$(${CXX} --print-target-triple)" \
385 -DLLVM_TARGETS_TO_BUILD="host" \
386 -DRUNTIMES_BUILD_ALLOW_DARWIN=ON \
387 -DLLVM_ENABLE_ASSERTIONS=ON \
388 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests"
390 step "Running the LLDB libc++ data formatter tests"
391 ${NINJA} -vC "${BUILD_DIR}" lldb-api-test-deps
392 ${BUILD_DIR}/bin/llvm-lit -sv --param dotest-args='--category libc++' "${MONOREPO_ROOT}/lldb/test/API"
394 step "Running the libc++ and libc++abi tests"
395 ${NINJA} -vC "${BUILD_DIR}" check-runtimes
397 step "Installing libc++ and libc++abi to a fake location"
398 ${NINJA} -vC "${BUILD_DIR}" install-runtimes
400 ccache -s
402 generic-static)
403 clean
404 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-static.cmake"
405 check-runtimes
407 generic-merged)
408 clean
409 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-merged.cmake" \
410 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in" \
411 -DLIBCXXABI_TEST_CONFIG="llvm-libc++abi-merged.cfg.in" \
412 -DLIBUNWIND_TEST_CONFIG="llvm-libunwind-merged.cfg.in"
413 check-runtimes
415 generic-hardening-mode-fast)
416 clean
417 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast.cmake"
418 check-runtimes
419 check-abi-list
421 generic-hardening-mode-fast-with-abi-breaks)
422 clean
423 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast-with-abi-breaks.cmake"
424 check-runtimes
425 # Not checking ABI list since we purposefully enable ABI breaking changes
427 generic-hardening-mode-extensive)
428 clean
429 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake"
430 check-runtimes
431 check-abi-list
433 generic-hardening-mode-debug)
434 clean
435 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-debug.cmake"
436 check-runtimes
437 check-abi-list
440 # Module builds
442 generic-modules)
443 clean
444 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules.cmake"
445 check-runtimes
446 check-abi-list
448 generic-modules-lsv)
449 clean
450 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules-lsv.cmake"
451 check-runtimes
452 check-abi-list
455 # Parts removed
457 generic-no-threads)
458 clean
459 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-threads.cmake"
460 check-runtimes
462 generic-no-filesystem)
463 clean
464 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-filesystem.cmake"
465 check-runtimes
467 generic-no-random_device)
468 clean
469 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-random_device.cmake"
470 check-runtimes
472 generic-no-localization)
473 clean
474 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"
475 check-runtimes
477 generic-no-terminal)
478 clean
479 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-terminal.cmake"
480 check-runtimes
482 generic-no-unicode)
483 clean
484 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake"
485 check-runtimes
487 generic-no-wide-characters)
488 clean
489 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-wide-characters.cmake"
490 check-runtimes
492 generic-no-tzdb)
493 clean
494 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-tzdb.cmake"
495 check-runtimes
497 generic-no-experimental)
498 clean
499 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-experimental.cmake"
500 check-runtimes
501 check-abi-list
503 generic-no-exceptions)
504 clean
505 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-exceptions.cmake"
506 check-runtimes
507 check-abi-list
509 generic-no-rtti)
510 clean
511 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-rtti.cmake"
512 check-runtimes
515 # Other miscellaneous jobs
517 generic-abi-unstable)
518 clean
519 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-abi-unstable.cmake"
520 check-runtimes
522 generic-optimized-speed)
523 clean
524 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-optimized-speed.cmake"
525 check-runtimes
527 apple-configuration)
528 clean
530 step "Installing libc++ with the Apple system configuration"
531 arch="$(uname -m)"
532 xcrun --sdk macosx \
533 ${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh \
534 --llvm-root ${MONOREPO_ROOT} \
535 --build-dir ${BUILD_DIR} \
536 --install-dir ${INSTALL_DIR} \
537 --symbols-dir "${BUILD_DIR}/symbols" \
538 --architectures "${arch}" \
539 --version "999.99"
541 step "Running tests against Apple-configured libc++"
542 # TODO: It would be better to run the tests against the fake-installed version of libc++ instead
543 xcrun --sdk macosx ninja -vC "${BUILD_DIR}/${arch}" check-cxx check-cxxabi check-cxx-abilist
545 apple-system-hardened)
546 clean
548 arch="$(uname -m)"
549 version="$(sw_vers --productVersion)"
550 params="target_triple=${arch}-apple-macosx${version}"
551 params+=";hardening_mode=fast"
553 # In the Apple system configuration, we build libc++ and libunwind separately.
554 step "Installing libc++ and libc++abi in Apple-system configuration"
555 ${CMAKE} \
556 -S "${MONOREPO_ROOT}/runtimes" \
557 -B "${BUILD_DIR}/cxx" \
558 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
559 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
560 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/cxx" \
561 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
562 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
563 -DLIBCXX_CXX_ABI=libcxxabi \
564 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
565 -DLIBCXX_TEST_CONFIG="apple-libc++-system.cfg.in" \
566 -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-system.cfg.in" \
567 -DLIBCXX_TEST_PARAMS="${params}" \
568 -DLIBCXXABI_TEST_PARAMS="${params}"
570 step "Installing libunwind in Apple-system configuration"
571 ${CMAKE} \
572 -S "${MONOREPO_ROOT}/runtimes" \
573 -B "${BUILD_DIR}/unwind" \
574 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
575 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
576 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/unwind" \
577 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
578 -DLLVM_ENABLE_RUNTIMES="libunwind" \
579 -DLIBUNWIND_TEST_CONFIG="apple-libunwind-system.cfg.in" \
580 -DLIBUNWIND_TEST_PARAMS="${params}" \
581 -DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"
583 step "Running the libc++ tests"
584 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxx
586 step "Running the libc++abi tests"
587 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxxabi
589 step "Running the libunwind tests"
590 ${NINJA} -vC "${BUILD_DIR}/unwind" check-unwind
592 apple-system)
593 clean
595 arch="$(uname -m)"
596 version="$(sw_vers --productVersion)"
597 params="target_triple=${arch}-apple-macosx${version}"
599 # In the Apple system configuration, we build libc++ and libunwind separately.
600 step "Installing libc++ and libc++abi in Apple-system configuration"
601 ${CMAKE} \
602 -S "${MONOREPO_ROOT}/runtimes" \
603 -B "${BUILD_DIR}/cxx" \
604 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
605 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
606 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/cxx" \
607 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
608 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
609 -DLIBCXX_CXX_ABI=libcxxabi \
610 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
611 -DLIBCXX_TEST_CONFIG="apple-libc++-system.cfg.in" \
612 -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-system.cfg.in" \
613 -DLIBCXX_TEST_PARAMS="${params}" \
614 -DLIBCXXABI_TEST_PARAMS="${params}"
616 step "Installing libunwind in Apple-system configuration"
617 ${CMAKE} \
618 -S "${MONOREPO_ROOT}/runtimes" \
619 -B "${BUILD_DIR}/unwind" \
620 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
621 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
622 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/unwind" \
623 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
624 -DLLVM_ENABLE_RUNTIMES="libunwind" \
625 -DLIBUNWIND_TEST_CONFIG="apple-libunwind-system.cfg.in" \
626 -DLIBUNWIND_TEST_PARAMS="${params}" \
627 -DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"
629 step "Running the libc++ tests"
630 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxx
632 step "Running the libc++abi tests"
633 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxxabi
635 step "Running the libunwind tests"
636 ${NINJA} -vC "${BUILD_DIR}/unwind" check-unwind
638 aarch64)
639 clean
640 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake"
641 check-runtimes
643 aarch64-no-exceptions)
644 clean
645 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \
646 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
647 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF
648 check-runtimes
650 # Aka Armv8 32 bit
651 armv8)
652 clean
653 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake"
654 check-runtimes
656 armv8-no-exceptions)
657 clean
658 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-no-exceptions.cmake"
659 check-runtimes
661 # Armv7 32 bit. One building Arm only one Thumb only code.
662 armv7)
663 clean
664 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake"
665 check-runtimes
667 armv7-no-exceptions)
668 clean
669 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-no-exceptions.cmake"
670 check-runtimes
672 armv7m-picolibc)
673 test-armv7m-picolibc \
674 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake"
676 armv7m-picolibc-no-exceptions)
677 test-armv7m-picolibc \
678 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \
679 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \
680 -DLIBCXXABI_ENABLE_STATIC_UNWINDER=OFF \
681 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
682 -DLIBCXX_ENABLE_RTTI=OFF
684 clang-cl-dll)
685 clean
686 # TODO: Currently, building with the experimental library breaks running
687 # tests (the test linking look for the c++experimental library with the
688 # wrong name, and the statically linked c++experimental can't be linked
689 # correctly when libc++ visibility attributes indicate dllimport linkage
690 # anyway), thus just disable the experimental library. Remove this
691 # setting when cmake and the test driver does the right thing automatically.
692 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False"
693 step "Running the libc++ tests"
694 ${NINJA} -vC "${BUILD_DIR}" check-cxx
696 clang-cl-static)
697 clean
698 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF
699 step "Running the libc++ tests"
700 ${NINJA} -vC "${BUILD_DIR}" check-cxx
702 clang-cl-no-vcruntime)
703 clean
704 # Building libc++ in the same way as in clang-cl-dll above, but running
705 # tests with -D_HAS_EXCEPTIONS=0, which users might set in certain
706 # translation units while using libc++, even if libc++ is built with
707 # exceptions enabled.
708 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
709 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared-no-vcruntime-clangcl.cfg.in"
710 step "Running the libc++ tests"
711 ${NINJA} -vC "${BUILD_DIR}" check-cxx
713 clang-cl-debug)
714 clean
715 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
716 -DCMAKE_BUILD_TYPE=Debug
717 step "Running the libc++ tests"
718 ${NINJA} -vC "${BUILD_DIR}" check-cxx
720 clang-cl-static-crt)
721 clean
722 # Test linking a static libc++ with the static CRT ("MultiThreaded" denotes
723 # the static CRT, as opposed to "MultiThreadedDLL" which is the default).
724 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \
725 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
726 step "Running the libc++ tests"
727 ${NINJA} -vC "${BUILD_DIR}" check-cxx
729 mingw-dll)
730 clean
731 generate-cmake \
732 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
733 check-runtimes
735 mingw-static)
736 clean
737 generate-cmake \
738 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" \
739 -DLIBCXX_ENABLE_SHARED=OFF \
740 -DLIBUNWIND_ENABLE_SHARED=OFF
741 check-runtimes
743 mingw-dll-i686)
744 clean
745 generate-cmake \
746 -DCMAKE_C_COMPILER=i686-w64-mingw32-clang \
747 -DCMAKE_CXX_COMPILER=i686-w64-mingw32-clang++ \
748 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
749 check-runtimes
751 mingw-incomplete-sysroot)
752 # When bringing up a new cross compiler from scratch, we build
753 # libunwind/libcxx in a setup where the toolchain is incomplete and
754 # unable to perform the normal linker checks; this requires a few
755 # special cases in the CMake files.
757 # Building in an incomplete setup requires setting CMAKE_*_COMPILER_WORKS,
758 # as CMake fails to probe the compiler. This case also requires
759 # setting CMAKE_CXX_COMPILER_TARGET, as LLVM's heuristics for setting
760 # the triple fails when CMake hasn't been able to probe the environment.
761 # (This is what one has to do when building the initial libunwind/libcxx
762 # for a new toolchain.)
763 clean
764 generate-cmake \
765 -DCMAKE_C_COMPILER_WORKS=TRUE \
766 -DCMAKE_CXX_COMPILER_WORKS=TRUE \
767 -DCMAKE_C_COMPILER_TARGET=x86_64-w64-windows-gnu \
768 -DCMAKE_CXX_COMPILER_TARGET=x86_64-w64-windows-gnu \
769 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
770 # Only test that building succeeds; there's not much extra value in running
771 # the tests here, as it would be equivalent to the mingw-dll config above.
772 step "Building the runtimes"
773 ${NINJA} -vC "${BUILD_DIR}"
775 aix)
776 clean
777 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AIX.cmake" \
778 -DLIBCXX_TEST_CONFIG="ibm-libc++-shared.cfg.in" \
779 -DLIBCXXABI_TEST_CONFIG="ibm-libc++abi-shared.cfg.in" \
780 -DLIBUNWIND_TEST_CONFIG="ibm-libunwind-shared.cfg.in"
781 check-abi-list
782 check-runtimes
784 android-ndk-*)
785 clean
787 ANDROID_EMU_IMG="${BUILDER#android-ndk-}"
788 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/emulator-functions.sh"
789 if ! validate_emu_img "${ANDROID_EMU_IMG}"; then
790 error "android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG})" >&2
791 exit 1
793 ARCH=$(arch_of_emu_img ${ANDROID_EMU_IMG})
795 # Use the Android compiler by default.
796 export CC=${CC:-/opt/android/clang/clang-current/bin/clang}
797 export CXX=${CXX:-/opt/android/clang/clang-current/bin/clang++}
799 # The NDK libc++_shared.so is always built against the oldest supported API
800 # level. When tests are run against a device with a newer API level, test
801 # programs can be built for any supported API level, but building for the
802 # newest API (i.e. the system image's API) is probably the most interesting.
803 PARAMS="executor=${MONOREPO_ROOT}/libcxx/utils/adb_run.py;target_triple=$(triple_of_arch ${ARCH})$(api_of_emu_img ${ANDROID_EMU_IMG})"
804 generate-cmake-android -C "${MONOREPO_ROOT}/runtimes/cmake/android/Arch-${ARCH}.cmake" \
805 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AndroidNDK.cmake" \
806 -DCMAKE_SYSROOT=/opt/android/ndk/sysroot \
807 -DLIBCXX_TEST_PARAMS="${PARAMS}" \
808 -DLIBCXXABI_TEST_PARAMS="${PARAMS}"
809 check-abi-list
810 ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi
812 # Start the emulator and make sure we can connect to the adb server running
813 # inside of it.
814 "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/start-emulator.sh" ${ANDROID_EMU_IMG}
815 trap "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/stop-emulator.sh" EXIT
816 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/setup-env-for-emulator.sh"
818 # Create adb_run early to avoid concurrent `mkdir -p` of common parent
819 # directories.
820 adb shell mkdir -p /data/local/tmp/adb_run
821 adb push "${BUILD_DIR}/lib/libc++_shared.so" /data/local/tmp/libc++/libc++_shared.so
822 step "Running the libc++ tests"
823 ${NINJA} -vC "${BUILD_DIR}" check-cxx
824 step "Running the libc++abi tests"
825 ${NINJA} -vC "${BUILD_DIR}" check-cxxabi
827 #################################################################
828 # Insert vendor-specific internal configurations below.
830 # This allows vendors to extend this file with their own internal
831 # configurations without running into merge conflicts with upstream.
832 #################################################################
834 #################################################################
836 echo "${BUILDER} is not a known configuration"
837 exit 1
839 esac
841 endstep # Make sure we close any still-open output group