[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / libcxx / utils / ci / run-buildbot
blobf1ede6474eb9ee93c59b41018445e00b5b38be91
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 frozen-cxx03-headers)
285 clean
286 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03-frozen.cmake"
287 check-runtimes
288 check-abi-list
290 generic-cxx03)
291 clean
292 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake"
293 check-runtimes
294 check-abi-list
296 generic-cxx11)
297 clean
298 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake"
299 check-runtimes
300 check-abi-list
302 generic-cxx14)
303 clean
304 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake"
305 check-runtimes
306 check-abi-list
308 generic-cxx17)
309 clean
310 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake"
311 check-runtimes
312 check-abi-list
314 generic-cxx20)
315 clean
316 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake"
317 check-runtimes
318 check-abi-list
320 generic-cxx23)
321 clean
322 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx23.cmake"
323 check-runtimes
324 check-abi-list
326 generic-cxx26)
327 clean
328 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx26.cmake"
329 check-runtimes
330 check-abi-list
333 # Other compiler support
335 generic-gcc)
336 clean
337 generate-cmake -DLIBCXX_ENABLE_WERROR=NO \
338 -DLIBCXXABI_ENABLE_WERROR=NO \
339 -DLIBUNWIND_ENABLE_WERROR=NO
340 check-runtimes
342 generic-gcc-cxx11)
343 clean
344 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" \
345 -DLIBCXX_ENABLE_WERROR=NO \
346 -DLIBCXXABI_ENABLE_WERROR=NO \
347 -DLIBUNWIND_ENABLE_WERROR=NO
348 check-runtimes
351 # Sanitizers
353 generic-asan)
354 clean
355 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-asan.cmake"
356 check-runtimes
358 generic-msan)
359 clean
360 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-msan.cmake"
361 check-runtimes
363 generic-tsan)
364 clean
365 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-tsan.cmake"
366 check-runtimes
368 generic-ubsan)
369 clean
370 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-ubsan.cmake"
371 check-runtimes
374 # Various build configurations
376 bootstrapping-build)
377 clean
379 step "Generating CMake"
380 ${CMAKE} \
381 -S "${MONOREPO_ROOT}/llvm" \
382 -B "${BUILD_DIR}" \
383 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
384 -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
385 -DCMAKE_BUILD_TYPE=Release \
386 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
387 -DLLVM_ENABLE_PROJECTS="clang;lldb" \
388 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
389 -DLLVM_RUNTIME_TARGETS="$(${CXX} --print-target-triple)" \
390 -DLLVM_HOST_TRIPLE="$(${CXX} --print-target-triple)" \
391 -DLLVM_TARGETS_TO_BUILD="host" \
392 -DRUNTIMES_BUILD_ALLOW_DARWIN=ON \
393 -DLLVM_ENABLE_ASSERTIONS=ON \
394 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests"
396 step "Running the libc++ and libc++abi tests"
397 ${NINJA} -vC "${BUILD_DIR}" check-runtimes
399 step "Installing libc++ and libc++abi to a fake location"
400 ${NINJA} -vC "${BUILD_DIR}" install-runtimes
402 step "Running the LLDB libc++ data formatter tests"
403 ${NINJA} -vC "${BUILD_DIR}" lldb-api-test-deps
404 ${BUILD_DIR}/bin/llvm-lit -sv --param dotest-args='--category libc++' "${MONOREPO_ROOT}/lldb/test/API"
406 ccache -s
408 generic-static)
409 clean
410 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-static.cmake"
411 check-runtimes
413 generic-merged)
414 clean
415 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-merged.cmake" \
416 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in" \
417 -DLIBCXXABI_TEST_CONFIG="llvm-libc++abi-merged.cfg.in" \
418 -DLIBUNWIND_TEST_CONFIG="llvm-libunwind-merged.cfg.in"
419 check-runtimes
421 generic-hardening-mode-fast)
422 clean
423 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast.cmake"
424 check-runtimes
425 check-abi-list
427 generic-hardening-mode-fast-with-abi-breaks)
428 clean
429 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast-with-abi-breaks.cmake"
430 check-runtimes
431 # Not checking ABI list since we purposefully enable ABI breaking changes
433 generic-hardening-mode-extensive)
434 clean
435 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake"
436 check-runtimes
437 check-abi-list
439 generic-hardening-mode-debug)
440 clean
441 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-debug.cmake"
442 check-runtimes
443 check-abi-list
446 # Module builds
448 generic-modules)
449 clean
450 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules.cmake"
451 check-runtimes
452 check-abi-list
454 generic-modules-lsv)
455 clean
456 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules-lsv.cmake"
457 check-runtimes
458 check-abi-list
461 # Parts removed
463 generic-no-threads)
464 clean
465 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-threads.cmake"
466 check-runtimes
468 generic-no-filesystem)
469 clean
470 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-filesystem.cmake"
471 check-runtimes
473 generic-no-random_device)
474 clean
475 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-random_device.cmake"
476 check-runtimes
478 generic-no-localization)
479 clean
480 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"
481 check-runtimes
483 generic-no-terminal)
484 clean
485 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-terminal.cmake"
486 check-runtimes
488 generic-no-unicode)
489 clean
490 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake"
491 check-runtimes
493 generic-no-wide-characters)
494 clean
495 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-wide-characters.cmake"
496 check-runtimes
498 generic-no-tzdb)
499 clean
500 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-tzdb.cmake"
501 check-runtimes
503 generic-no-experimental)
504 clean
505 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-experimental.cmake"
506 check-runtimes
507 check-abi-list
509 generic-no-exceptions)
510 clean
511 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-exceptions.cmake"
512 check-runtimes
513 check-abi-list
515 generic-no-rtti)
516 clean
517 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-rtti.cmake"
518 check-runtimes
521 # Other miscellaneous jobs
523 generic-abi-unstable)
524 clean
525 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-abi-unstable.cmake"
526 check-runtimes
528 generic-optimized-speed)
529 clean
530 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-optimized-speed.cmake"
531 check-runtimes
533 apple-configuration)
534 clean
536 step "Installing libc++ with the Apple system configuration"
537 arch="$(uname -m)"
538 xcrun --sdk macosx \
539 ${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh \
540 --llvm-root ${MONOREPO_ROOT} \
541 --build-dir ${BUILD_DIR} \
542 --install-dir ${INSTALL_DIR} \
543 --symbols-dir "${BUILD_DIR}/symbols" \
544 --architectures "${arch}" \
545 --version "999.99"
547 step "Running tests against Apple-configured libc++"
548 # TODO: It would be better to run the tests against the fake-installed version of libc++ instead
549 xcrun --sdk macosx ninja -vC "${BUILD_DIR}/${arch}" check-cxx check-cxxabi check-cxx-abilist
551 apple-system-hardened)
552 clean
554 arch="$(uname -m)"
555 version="$(sw_vers --productVersion)"
556 params="target_triple=${arch}-apple-macosx${version}"
557 params+=";hardening_mode=fast"
559 # In the Apple system configuration, we build libc++ and libunwind separately.
560 step "Installing libc++ and libc++abi in Apple-system configuration"
561 ${CMAKE} \
562 -S "${MONOREPO_ROOT}/runtimes" \
563 -B "${BUILD_DIR}/cxx" \
564 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
565 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
566 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/cxx" \
567 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
568 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
569 -DLIBCXX_CXX_ABI=libcxxabi \
570 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
571 -DLIBCXX_TEST_CONFIG="apple-libc++-system.cfg.in" \
572 -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-system.cfg.in" \
573 -DLIBCXX_TEST_PARAMS="${params}" \
574 -DLIBCXXABI_TEST_PARAMS="${params}"
576 step "Installing libunwind in Apple-system configuration"
577 ${CMAKE} \
578 -S "${MONOREPO_ROOT}/runtimes" \
579 -B "${BUILD_DIR}/unwind" \
580 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
581 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
582 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/unwind" \
583 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
584 -DLLVM_ENABLE_RUNTIMES="libunwind" \
585 -DLIBUNWIND_TEST_CONFIG="apple-libunwind-system.cfg.in" \
586 -DLIBUNWIND_TEST_PARAMS="${params}" \
587 -DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"
589 step "Running the libc++ tests"
590 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxx
592 step "Running the libc++abi tests"
593 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxxabi
595 step "Running the libunwind tests"
596 ${NINJA} -vC "${BUILD_DIR}/unwind" check-unwind
598 apple-system)
599 clean
601 arch="$(uname -m)"
602 version="$(sw_vers --productVersion)"
603 params="target_triple=${arch}-apple-macosx${version}"
605 # In the Apple system configuration, we build libc++ and libunwind separately.
606 step "Installing libc++ and libc++abi in Apple-system configuration"
607 ${CMAKE} \
608 -S "${MONOREPO_ROOT}/runtimes" \
609 -B "${BUILD_DIR}/cxx" \
610 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
611 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
612 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/cxx" \
613 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
614 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
615 -DLIBCXX_CXX_ABI=libcxxabi \
616 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
617 -DLIBCXX_TEST_CONFIG="apple-libc++-system.cfg.in" \
618 -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-system.cfg.in" \
619 -DLIBCXX_TEST_PARAMS="${params}" \
620 -DLIBCXXABI_TEST_PARAMS="${params}"
622 step "Installing libunwind in Apple-system configuration"
623 ${CMAKE} \
624 -S "${MONOREPO_ROOT}/runtimes" \
625 -B "${BUILD_DIR}/unwind" \
626 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
627 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
628 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/unwind" \
629 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
630 -DLLVM_ENABLE_RUNTIMES="libunwind" \
631 -DLIBUNWIND_TEST_CONFIG="apple-libunwind-system.cfg.in" \
632 -DLIBUNWIND_TEST_PARAMS="${params}" \
633 -DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"
635 step "Running the libc++ tests"
636 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxx
638 step "Running the libc++abi tests"
639 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxxabi
641 step "Running the libunwind tests"
642 ${NINJA} -vC "${BUILD_DIR}/unwind" check-unwind
644 aarch64)
645 clean
646 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake"
647 check-runtimes
649 aarch64-no-exceptions)
650 clean
651 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \
652 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
653 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF
654 check-runtimes
656 # Aka Armv8 32 bit
657 armv8)
658 clean
659 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake"
660 check-runtimes
662 armv8-no-exceptions)
663 clean
664 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-no-exceptions.cmake"
665 check-runtimes
667 # Armv7 32 bit. One building Arm only one Thumb only code.
668 armv7)
669 clean
670 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake"
671 check-runtimes
673 armv7-no-exceptions)
674 clean
675 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-no-exceptions.cmake"
676 check-runtimes
678 armv7m-picolibc)
679 test-armv7m-picolibc \
680 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake"
682 armv7m-picolibc-no-exceptions)
683 test-armv7m-picolibc \
684 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \
685 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \
686 -DLIBCXXABI_ENABLE_STATIC_UNWINDER=OFF \
687 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
688 -DLIBCXX_ENABLE_RTTI=OFF
690 clang-cl-dll)
691 clean
692 # TODO: Currently, building with the experimental library breaks running
693 # tests (the test linking look for the c++experimental library with the
694 # wrong name, and the statically linked c++experimental can't be linked
695 # correctly when libc++ visibility attributes indicate dllimport linkage
696 # anyway), thus just disable the experimental library. Remove this
697 # setting when cmake and the test driver does the right thing automatically.
698 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False"
699 step "Running the libc++ tests"
700 ${NINJA} -vC "${BUILD_DIR}" check-cxx
702 clang-cl-static)
703 clean
704 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF
705 step "Running the libc++ tests"
706 ${NINJA} -vC "${BUILD_DIR}" check-cxx
708 clang-cl-no-vcruntime)
709 clean
710 # Building libc++ in the same way as in clang-cl-dll above, but running
711 # tests with -D_HAS_EXCEPTIONS=0, which users might set in certain
712 # translation units while using libc++, even if libc++ is built with
713 # exceptions enabled.
714 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
715 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared-no-vcruntime-clangcl.cfg.in"
716 step "Running the libc++ tests"
717 ${NINJA} -vC "${BUILD_DIR}" check-cxx
719 clang-cl-debug)
720 clean
721 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
722 -DCMAKE_BUILD_TYPE=Debug
723 step "Running the libc++ tests"
724 ${NINJA} -vC "${BUILD_DIR}" check-cxx
726 clang-cl-static-crt)
727 clean
728 # Test linking a static libc++ with the static CRT ("MultiThreaded" denotes
729 # the static CRT, as opposed to "MultiThreadedDLL" which is the default).
730 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \
731 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
732 step "Running the libc++ tests"
733 ${NINJA} -vC "${BUILD_DIR}" check-cxx
735 mingw-dll)
736 clean
737 generate-cmake \
738 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
739 check-runtimes
741 mingw-static)
742 clean
743 generate-cmake \
744 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" \
745 -DLIBCXX_ENABLE_SHARED=OFF \
746 -DLIBUNWIND_ENABLE_SHARED=OFF
747 check-runtimes
749 mingw-dll-i686)
750 clean
751 generate-cmake \
752 -DCMAKE_C_COMPILER=i686-w64-mingw32-clang \
753 -DCMAKE_CXX_COMPILER=i686-w64-mingw32-clang++ \
754 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
755 check-runtimes
757 mingw-incomplete-sysroot)
758 # When bringing up a new cross compiler from scratch, we build
759 # libunwind/libcxx in a setup where the toolchain is incomplete and
760 # unable to perform the normal linker checks; this requires a few
761 # special cases in the CMake files.
763 # Building in an incomplete setup requires setting CMAKE_*_COMPILER_WORKS,
764 # as CMake fails to probe the compiler. This case also requires
765 # setting CMAKE_CXX_COMPILER_TARGET, as LLVM's heuristics for setting
766 # the triple fails when CMake hasn't been able to probe the environment.
767 # (This is what one has to do when building the initial libunwind/libcxx
768 # for a new toolchain.)
769 clean
770 generate-cmake \
771 -DCMAKE_C_COMPILER_WORKS=TRUE \
772 -DCMAKE_CXX_COMPILER_WORKS=TRUE \
773 -DCMAKE_C_COMPILER_TARGET=x86_64-w64-windows-gnu \
774 -DCMAKE_CXX_COMPILER_TARGET=x86_64-w64-windows-gnu \
775 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
776 # Only test that building succeeds; there's not much extra value in running
777 # the tests here, as it would be equivalent to the mingw-dll config above.
778 step "Building the runtimes"
779 ${NINJA} -vC "${BUILD_DIR}"
781 aix)
782 clean
783 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AIX.cmake" \
784 -DLIBCXX_TEST_CONFIG="ibm-libc++-shared.cfg.in" \
785 -DLIBCXXABI_TEST_CONFIG="ibm-libc++abi-shared.cfg.in" \
786 -DLIBUNWIND_TEST_CONFIG="ibm-libunwind-shared.cfg.in"
787 check-abi-list
788 check-runtimes
790 android-ndk-*)
791 clean
793 ANDROID_EMU_IMG="${BUILDER#android-ndk-}"
794 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/emulator-functions.sh"
795 if ! validate_emu_img "${ANDROID_EMU_IMG}"; then
796 error "android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG})" >&2
797 exit 1
799 ARCH=$(arch_of_emu_img ${ANDROID_EMU_IMG})
801 # Use the Android compiler by default.
802 export CC=${CC:-/opt/android/clang/clang-current/bin/clang}
803 export CXX=${CXX:-/opt/android/clang/clang-current/bin/clang++}
805 # The NDK libc++_shared.so is always built against the oldest supported API
806 # level. When tests are run against a device with a newer API level, test
807 # programs can be built for any supported API level, but building for the
808 # newest API (i.e. the system image's API) is probably the most interesting.
809 PARAMS="executor=${MONOREPO_ROOT}/libcxx/utils/adb_run.py;target_triple=$(triple_of_arch ${ARCH})$(api_of_emu_img ${ANDROID_EMU_IMG})"
810 generate-cmake-android -C "${MONOREPO_ROOT}/runtimes/cmake/android/Arch-${ARCH}.cmake" \
811 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AndroidNDK.cmake" \
812 -DCMAKE_SYSROOT=/opt/android/ndk/sysroot \
813 -DLIBCXX_TEST_PARAMS="${PARAMS}" \
814 -DLIBCXXABI_TEST_PARAMS="${PARAMS}"
815 check-abi-list
816 ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi
818 # Start the emulator and make sure we can connect to the adb server running
819 # inside of it.
820 "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/start-emulator.sh" ${ANDROID_EMU_IMG}
821 trap "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/stop-emulator.sh" EXIT
822 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/setup-env-for-emulator.sh"
824 # Create adb_run early to avoid concurrent `mkdir -p` of common parent
825 # directories.
826 adb shell mkdir -p /data/local/tmp/adb_run
827 adb push "${BUILD_DIR}/lib/libc++_shared.so" /data/local/tmp/libc++/libc++_shared.so
828 step "Running the libc++ tests"
829 ${NINJA} -vC "${BUILD_DIR}" check-cxx
830 step "Running the libc++abi tests"
831 ${NINJA} -vC "${BUILD_DIR}" check-cxxabi
833 #################################################################
834 # Insert vendor-specific internal configurations below.
836 # This allows vendors to extend this file with their own internal
837 # configurations without running into merge conflicts with upstream.
838 #################################################################
840 #################################################################
842 echo "${BUILDER} is not a known configuration"
843 exit 1
845 esac
847 endstep # Make sure we close any still-open output group