77#
88# ===----------------------------------------------------------------------===##
99
10- set -ex
10+ set -e
1111set -o pipefail
1212unset LANG
1313unset LC_ALL
@@ -104,12 +104,37 @@ if [ -z "${CMAKE}" ]; then
104104 fi
105105fi
106106
107+ function step() {
108+ endstep
109+ set +x
110+ if [[ -v GITHUB_ACTIONS ]]; then
111+ echo " ::group::$1 "
112+ export IN_GROUP=1
113+ else
114+ echo " --- $1 "
115+ fi
116+ set -x
117+ }
118+
119+ function endstep() {
120+ set +x
121+ if [[ -v GITHUB_ACTIONS ]] && [[ -v IN_GROUP ]]; then
122+ echo " ::endgroup::"
123+ unset IN_GROUP
124+ fi
125+ set -x
126+ }
127+
128+ function error() {
129+ echo " ::error::$1 "
130+ }
131+
107132function clean() {
108133 rm -rf " ${BUILD_DIR} "
109134}
110135
111136function generate-cmake-base() {
112- echo " --- Generating CMake"
137+ step " Generating CMake"
113138 ${CMAKE} \
114139 -S " ${MONOREPO_ROOT} /runtimes" \
115140 -B " ${BUILD_DIR} " \
@@ -146,29 +171,32 @@ function generate-cmake-android() {
146171}
147172
148173function check-runtimes() {
149- echo " +++ Running the libc++ tests"
174+ step " Building libc++ test dependencies"
175+ ${NINJA} -vC " ${BUILD_DIR} " cxx-test-depends
176+
177+ step " Running the libc++ tests"
150178 ${NINJA} -vC " ${BUILD_DIR} " check-cxx
151179
152- echo " +++ Running the libc++abi tests"
180+ step " Running the libc++abi tests"
153181 ${NINJA} -vC " ${BUILD_DIR} " check-cxxabi
154182
155- echo " +++ Running the libunwind tests"
183+ step " Running the libunwind tests"
156184 ${NINJA} -vC " ${BUILD_DIR} " check-unwind
157185}
158186
159187# TODO: The goal is to test this against all configurations. We should also move
160188# this to the Lit test suite instead of being a separate CMake target.
161189function check-abi-list() {
162- echo " +++ Running the libc++ ABI list test"
190+ step " Running the libc++ ABI list test"
163191 ${NINJA} -vC " ${BUILD_DIR} " check-cxx-abilist || (
164- echo " +++ Generating the libc++ ABI list after failed check"
192+ error " Generating the libc++ ABI list after failed check"
165193 ${NINJA} -vC " ${BUILD_DIR} " generate-cxx-abilist
166194 false
167195 )
168196}
169197
170198function check-cxx-benchmarks() {
171- echo " --- Running the benchmarks"
199+ step " Running the benchmarks"
172200 ${NINJA} -vC " ${BUILD_DIR} " check-cxx-benchmarks
173201}
174202
@@ -178,12 +206,13 @@ function test-armv7m-picolibc() {
178206 # To make it easier to get this builder up and running, build picolibc
179207 # from scratch. Anecdotally, the build-picolibc script takes about 16 seconds.
180208 # This could be optimised by building picolibc into the Docker container.
209+ step " Building picolibc from source"
181210 ${MONOREPO_ROOT} /libcxx/utils/ci/build-picolibc.sh \
182211 --build-dir " ${BUILD_DIR} " \
183212 --install-dir " ${INSTALL_DIR} " \
184213 --target armv7m-none-eabi
185214
186- echo " --- Generating CMake"
215+ step " Generating CMake for compiler-rt "
187216 flags=" --sysroot=${INSTALL_DIR} "
188217 ${CMAKE} \
189218 -S " ${MONOREPO_ROOT} /compiler-rt" \
@@ -195,6 +224,8 @@ function test-armv7m-picolibc() {
195224 -DCMAKE_CXX_FLAGS=" ${flags} " \
196225 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
197226 " ${@ } "
227+
228+ step " Generating CMake for libc++"
198229 generate-cmake \
199230 -DLIBCXX_TEST_CONFIG=" armv7m-picolibc-libc++.cfg.in" \
200231 -DLIBCXXABI_TEST_CONFIG=" armv7m-picolibc-libc++abi.cfg.in" \
@@ -203,6 +234,7 @@ function test-armv7m-picolibc() {
203234 -DCMAKE_CXX_FLAGS=" ${flags} " \
204235 " ${@ } "
205236
237+ step " Installing compiler-rt"
206238 ${NINJA} -vC " ${BUILD_DIR} /compiler-rt" install
207239
208240 # Prior to clang 19, armv7m-none-eabi normalised to armv7m-none-unknown-eabi.
@@ -216,9 +248,9 @@ function test-armv7m-picolibc() {
216248}
217249
218250# Print the version of a few tools to aid diagnostics in some cases
251+ step " Diagnose tools in use"
219252${CMAKE} --version
220253${NINJA} --version
221-
222254if [ ! -z " ${CXX} " ]; then ${CXX} --version; fi
223255
224256case " ${BUILDER} " in
@@ -228,10 +260,9 @@ check-generated-output)
228260 clean
229261 generate-cmake
230262
231- set +x # Printing all the commands below just creates extremely confusing output
232-
233263 # Reject patches that forgot to re-run the generator scripts.
234- echo " +++ Making sure the generator scripts were run"
264+ step " Making sure the generator scripts were run"
265+ set +x # Printing all the commands below just creates extremely confusing output
235266 ${NINJA} -vC " ${BUILD_DIR} " libcxx-generate-files
236267 git diff | tee ${BUILD_DIR} /generated_output.patch
237268 git ls-files -o --exclude-standard | tee ${BUILD_DIR} /generated_output.status
@@ -243,9 +274,8 @@ check-generated-output)
243274 false
244275 fi
245276
246- # Reject patches that introduce non-ASCII characters or hard tabs.
247- # Depends on LC_COLLATE set at the top of this script.
248- set -x
277+ # This depends on LC_COLLATE set at the top of this script.
278+ step " Reject patches that introduce non-ASCII characters or hard tabs."
249279 ! grep -rn ' [^ -~]' libcxx/include libcxx/src libcxx/test libcxx/benchmarks \
250280 --exclude ' *.dat' \
251281 --exclude ' *unicode*.cpp' \
@@ -353,7 +383,7 @@ generic-ubsan)
353383bootstrapping-build)
354384 clean
355385
356- echo " --- Generating CMake"
386+ step " Generating CMake"
357387 ${CMAKE} \
358388 -S " ${MONOREPO_ROOT} /llvm" \
359389 -B " ${BUILD_DIR} " \
@@ -370,14 +400,14 @@ bootstrapping-build)
370400 -DLLVM_ENABLE_ASSERTIONS=ON \
371401 -DLLVM_LIT_ARGS=" -sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests"
372402
373- echo " +++ Running the LLDB libc++ data formatter tests"
403+ step " Running the LLDB libc++ data formatter tests"
374404 ${NINJA} -vC " ${BUILD_DIR} " lldb-api-test-deps
375405 ${BUILD_DIR} /bin/llvm-lit -sv --param dotest-args=' --category libc++' " ${MONOREPO_ROOT} /lldb/test/API"
376406
377- echo " --- Running the libc++ and libc++abi tests"
407+ step " Running the libc++ and libc++abi tests"
378408 ${NINJA} -vC " ${BUILD_DIR} " check-runtimes
379409
380- echo " +++ Installing libc++ and libc++abi to a fake location"
410+ step " Installing libc++ and libc++abi to a fake location"
381411 ${NINJA} -vC " ${BUILD_DIR} " install-runtimes
382412
383413 ccache -s
@@ -510,6 +540,7 @@ generic-optimized-speed)
510540apple-configuration)
511541 clean
512542
543+ step " Installing libc++ with the Apple system configuration"
513544 arch=" $( uname -m) "
514545 xcrun --sdk macosx \
515546 ${MONOREPO_ROOT} /libcxx/utils/ci/apple-install-libcxx.sh \
@@ -520,6 +551,7 @@ apple-configuration)
520551 --architectures " ${arch} " \
521552 --version " 999.99"
522553
554+ step " Running tests against Apple-configured libc++"
523555 # TODO: It would be better to run the tests against the fake-installed version of libc++ instead
524556 xcrun --sdk macosx ninja -vC " ${BUILD_DIR} /${arch} " check-cxx check-cxxabi check-cxx-abilist
525557;;
@@ -532,6 +564,7 @@ apple-system-hardened)
532564 params+=" ;hardening_mode=fast"
533565
534566 # In the Apple system configuration, we build libc++ and libunwind separately.
567+ step " Installing libc++ and libc++abi in Apple-system configuration"
535568 ${CMAKE} \
536569 -S " ${MONOREPO_ROOT} /runtimes" \
537570 -B " ${BUILD_DIR} /cxx" \
@@ -547,6 +580,7 @@ apple-system-hardened)
547580 -DLIBCXX_TEST_PARAMS=" ${params} " \
548581 -DLIBCXXABI_TEST_PARAMS=" ${params} "
549582
583+ step " Installing libunwind in Apple-system configuration"
550584 ${CMAKE} \
551585 -S " ${MONOREPO_ROOT} /runtimes" \
552586 -B " ${BUILD_DIR} /unwind" \
@@ -559,13 +593,13 @@ apple-system-hardened)
559593 -DLIBUNWIND_TEST_PARAMS=" ${params} " \
560594 -DCMAKE_INSTALL_NAME_DIR=" /usr/lib/system"
561595
562- echo " +++ Running the libc++ tests"
596+ step " Running the libc++ tests"
563597 ${NINJA} -vC " ${BUILD_DIR} /cxx" check-cxx
564598
565- echo " +++ Running the libc++abi tests"
599+ step " Running the libc++abi tests"
566600 ${NINJA} -vC " ${BUILD_DIR} /cxx" check-cxxabi
567601
568- echo " +++ Running the libunwind tests"
602+ step " Running the libunwind tests"
569603 ${NINJA} -vC " ${BUILD_DIR} /unwind" check-unwind
570604;;
571605apple-system)
@@ -576,6 +610,7 @@ apple-system)
576610 params=" target_triple=${arch} -apple-macosx${version} "
577611
578612 # In the Apple system configuration, we build libc++ and libunwind separately.
613+ step " Installing libc++ and libc++abi in Apple-system configuration"
579614 ${CMAKE} \
580615 -S " ${MONOREPO_ROOT} /runtimes" \
581616 -B " ${BUILD_DIR} /cxx" \
@@ -591,6 +626,7 @@ apple-system)
591626 -DLIBCXX_TEST_PARAMS=" ${params} " \
592627 -DLIBCXXABI_TEST_PARAMS=" ${params} "
593628
629+ step " Installing libunwind in Apple-system configuration"
594630 ${CMAKE} \
595631 -S " ${MONOREPO_ROOT} /runtimes" \
596632 -B " ${BUILD_DIR} /unwind" \
@@ -603,13 +639,13 @@ apple-system)
603639 -DLIBUNWIND_TEST_PARAMS=" ${params} " \
604640 -DCMAKE_INSTALL_NAME_DIR=" /usr/lib/system"
605641
606- echo " +++ Running the libc++ tests"
642+ step " Running the libc++ tests"
607643 ${NINJA} -vC " ${BUILD_DIR} /cxx" check-cxx
608644
609- echo " +++ Running the libc++abi tests"
645+ step " Running the libc++abi tests"
610646 ${NINJA} -vC " ${BUILD_DIR} /cxx" check-cxxabi
611647
612- echo " +++ Running the libunwind tests"
648+ step " Running the libunwind tests"
613649 ${NINJA} -vC " ${BUILD_DIR} /unwind" check-unwind
614650;;
615651benchmarks)
@@ -672,13 +708,13 @@ clang-cl-dll)
672708 # anyway), thus just disable the experimental library. Remove this
673709 # setting when cmake and the test driver does the right thing automatically.
674710 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS=" enable_experimental=False"
675- echo " +++ Running the libc++ tests"
711+ step " Running the libc++ tests"
676712 ${NINJA} -vC " ${BUILD_DIR} " check-cxx
677713;;
678714clang-cl-static)
679715 clean
680716 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF
681- echo " +++ Running the libc++ tests"
717+ step " Running the libc++ tests"
682718 ${NINJA} -vC " ${BUILD_DIR} " check-cxx
683719;;
684720clang-cl-no-vcruntime)
@@ -689,14 +725,14 @@ clang-cl-no-vcruntime)
689725 # exceptions enabled.
690726 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS=" enable_experimental=False" \
691727 -DLIBCXX_TEST_CONFIG=" llvm-libc++-shared-no-vcruntime-clangcl.cfg.in"
692- echo " +++ Running the libc++ tests"
728+ step " Running the libc++ tests"
693729 ${NINJA} -vC " ${BUILD_DIR} " check-cxx
694730;;
695731clang-cl-debug)
696732 clean
697733 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS=" enable_experimental=False" \
698734 -DCMAKE_BUILD_TYPE=Debug
699- echo " +++ Running the libc++ tests"
735+ step " Running the libc++ tests"
700736 ${NINJA} -vC " ${BUILD_DIR} " check-cxx
701737;;
702738clang-cl-static-crt)
@@ -705,7 +741,7 @@ clang-cl-static-crt)
705741 # the static CRT, as opposed to "MultiThreadedDLL" which is the default).
706742 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \
707743 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
708- echo " +++ Running the libc++ tests"
744+ step " Running the libc++ tests"
709745 ${NINJA} -vC " ${BUILD_DIR} " check-cxx
710746;;
711747mingw-dll)
@@ -751,6 +787,7 @@ mingw-incomplete-sysroot)
751787 -C " ${MONOREPO_ROOT} /libcxx/cmake/caches/MinGW.cmake"
752788 # Only test that building succeeds; there's not much extra value in running
753789 # the tests here, as it would be equivalent to the mingw-dll config above.
790+ step " Building the runtimes"
754791 ${NINJA} -vC " ${BUILD_DIR} "
755792;;
756793aix)
@@ -768,7 +805,7 @@ android-ndk-*)
768805 ANDROID_EMU_IMG=" ${BUILDER# android-ndk-} "
769806 . " ${MONOREPO_ROOT} /libcxx/utils/ci/vendor/android/emulator-functions.sh"
770807 if ! validate_emu_img " ${ANDROID_EMU_IMG} " ; then
771- echo " error: android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG} )" >&2
808+ error " android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG} )" >&2
772809 exit 1
773810 fi
774811 ARCH=$( arch_of_emu_img ${ANDROID_EMU_IMG} )
@@ -800,9 +837,9 @@ android-ndk-*)
800837 # directories.
801838 adb shell mkdir -p /data/local/tmp/adb_run
802839 adb push " ${BUILD_DIR} /lib/libc++_shared.so" /data/local/tmp/libc++/libc++_shared.so
803- echo " +++ Running the libc++ tests"
840+ step " Running the libc++ tests"
804841 ${NINJA} -vC " ${BUILD_DIR} " check-cxx
805- echo " +++ Running the libc++abi tests"
842+ step " Running the libc++abi tests"
806843 ${NINJA} -vC " ${BUILD_DIR} " check-cxxabi
807844;;
808845# ################################################################
@@ -818,3 +855,5 @@ android-ndk-*)
818855 exit 1
819856;;
820857esac
858+
859+ endstep # Make sure we close any still-open output group
0 commit comments