Skip to content

Commit 825943e

Browse files
authored
[libc++] Run macOS buildbot under xcrun (#167072)
This ensures that run-buildbot can find the appropriate build tools without having to go through a bunch of hoops inside run-buildbot itself. When we eventually run the bootstrapping build on macOS, it also allows the bootstrapped Clang to find the SDK headers it requires. This also allows simplifying run-buildbot a bunch since we should be able to find build tools in the current $PATH.
1 parent 070f331 commit 825943e

File tree

2 files changed

+36
-61
lines changed

2 files changed

+36
-61
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ jobs:
222222
python3 -m venv .venv
223223
source .venv/bin/activate
224224
python -m pip install psutil
225-
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
225+
xcrun bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
226226
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
227227
if: always() # Upload artifacts even if the build or test suite fails
228228
with:

libcxx/utils/ci/run-buildbot

Lines changed: 35 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ CC The C compiler to use, this value is used by CMake. This
3535
CXX The C++ compiler to use, this value is used by CMake. This
3636
variable is optional.
3737
38-
CMAKE The CMake binary to use. This variable is optional.
39-
4038
CLANG_FORMAT The clang-format binary to use when generating the format
4139
ignore list.
4240
@@ -73,29 +71,6 @@ MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
7371
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
7472
INSTALL_DIR="${BUILD_DIR}/install"
7573

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"
89-
fi
90-
91-
if [ -z "${CMAKE}" ]; then
92-
if xcrun --find cmake &>/dev/null; then
93-
CMAKE="$(xcrun --find cmake)"
94-
else
95-
CMAKE="cmake"
96-
fi
97-
fi
98-
9974
function step() {
10075
endstep
10176
set +x
@@ -129,10 +104,10 @@ function generate-cmake-base() {
129104
step "Generating CMake"
130105

131106
# We can remove -DCMAKE_INSTALL_MESSAGE=NEVER once https://gitlab.kitware.com/cmake/cmake/-/issues/26085 is fixed.
132-
${CMAKE} \
107+
cmake \
133108
-S "${MONOREPO_ROOT}/runtimes" \
134109
-B "${BUILD_DIR}" \
135-
-GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
110+
-GNinja \
136111
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
137112
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
138113
-DLIBCXX_ENABLE_WERROR=YES \
@@ -168,25 +143,25 @@ function generate-cmake-android() {
168143

169144
function check-runtimes() {
170145
step "Building libc++ test dependencies"
171-
${NINJA} -vC "${BUILD_DIR}" cxx-test-depends
146+
ninja -vC "${BUILD_DIR}" cxx-test-depends
172147

173148
step "Running the libc++ tests"
174-
${NINJA} -vC "${BUILD_DIR}" check-cxx
149+
ninja -vC "${BUILD_DIR}" check-cxx
175150

176151
step "Running the libc++abi tests"
177-
${NINJA} -vC "${BUILD_DIR}" check-cxxabi
152+
ninja -vC "${BUILD_DIR}" check-cxxabi
178153

179154
step "Running the libunwind tests"
180-
${NINJA} -vC "${BUILD_DIR}" check-unwind
155+
ninja -vC "${BUILD_DIR}" check-unwind
181156
}
182157

183158
# TODO: The goal is to test this against all configurations. We should also move
184159
# this to the Lit test suite instead of being a separate CMake target.
185160
function check-abi-list() {
186161
step "Running the libc++ ABI list test"
187-
${NINJA} -vC "${BUILD_DIR}" check-cxx-abilist || (
162+
ninja -vC "${BUILD_DIR}" check-cxx-abilist || (
188163
error "Generating the libc++ ABI list after failed check"
189-
${NINJA} -vC "${BUILD_DIR}" generate-cxx-abilist
164+
ninja -vC "${BUILD_DIR}" generate-cxx-abilist
190165
false
191166
)
192167
}
@@ -212,10 +187,10 @@ function test-armv7m-picolibc() {
212187
# architecture name, which is not what Clang's driver expects to find.
213188
# The install location will however be wrong with
214189
# LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON, so we correct that below.
215-
${CMAKE} \
190+
cmake \
216191
-S "${MONOREPO_ROOT}/compiler-rt" \
217192
-B "${BUILD_DIR}/compiler-rt" \
218-
-GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
193+
-GNinja \
219194
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
220195
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
221196
-DCMAKE_C_FLAGS="${flags}" \
@@ -233,7 +208,7 @@ function test-armv7m-picolibc() {
233208
"${@}"
234209

235210
step "Installing compiler-rt"
236-
${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
211+
ninja -vC "${BUILD_DIR}/compiler-rt" install
237212
# Move compiler-rt libs into the same directory as all the picolib objects.
238213
mv "${INSTALL_DIR}/lib/armv7m-unknown-none-eabi"/* "${INSTALL_DIR}/lib"
239214

@@ -242,8 +217,8 @@ function test-armv7m-picolibc() {
242217

243218
# Print the version of a few tools to aid diagnostics in some cases
244219
step "Diagnose tools in use"
245-
${CMAKE} --version
246-
${NINJA} --version
220+
cmake --version
221+
ninja --version
247222
if [ ! -z "${CXX}" ]; then ${CXX} --version; fi
248223

249224
case "${BUILDER}" in
@@ -256,7 +231,7 @@ check-generated-output)
256231
# Reject patches that forgot to re-run the generator scripts.
257232
step "Making sure the generator scripts were run"
258233
set +x # Printing all the commands below just creates extremely confusing output
259-
${NINJA} -vC "${BUILD_DIR}" libcxx-generate-files
234+
ninja -vC "${BUILD_DIR}" libcxx-generate-files
260235
git diff | tee ${BUILD_DIR}/generated_output.patch
261236
git ls-files -o --exclude-standard | tee ${BUILD_DIR}/generated_output.status
262237
! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false
@@ -383,10 +358,10 @@ bootstrapping-build)
383358
clean
384359

385360
step "Generating CMake"
386-
${CMAKE} \
361+
cmake \
387362
-S "${MONOREPO_ROOT}/llvm" \
388363
-B "${BUILD_DIR}" \
389-
-GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
364+
-GNinja \
390365
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
391366
-DCMAKE_BUILD_TYPE=Release \
392367
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
@@ -400,13 +375,13 @@ bootstrapping-build)
400375
-DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests"
401376

402377
step "Running the libc++ and libc++abi tests"
403-
${NINJA} -vC "${BUILD_DIR}" check-runtimes
378+
ninja -vC "${BUILD_DIR}" check-runtimes
404379

405380
step "Installing libc++ and libc++abi to a fake location"
406-
${NINJA} -vC "${BUILD_DIR}" install-runtimes
381+
ninja -vC "${BUILD_DIR}" install-runtimes
407382

408383
step "Running the LLDB libc++ data formatter tests"
409-
${NINJA} -vC "${BUILD_DIR}" lldb-api-test-deps
384+
ninja -vC "${BUILD_DIR}" lldb-api-test-deps
410385
${BUILD_DIR}/bin/llvm-lit -sv --param dotest-args='--category libc++' "${MONOREPO_ROOT}/lldb/test/API"
411386

412387
ccache -s
@@ -572,10 +547,10 @@ apple-system|apple-system-hardened)
572547

573548
# In the Apple system configuration, we build libc++ and libunwind separately.
574549
step "Installing libc++ and libc++abi in Apple-system configuration"
575-
${CMAKE} \
550+
cmake \
576551
-S "${MONOREPO_ROOT}/runtimes" \
577552
-B "${BUILD_DIR}/cxx" \
578-
-GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
553+
-GNinja \
579554
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
580555
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/cxx" \
581556
-DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
@@ -588,10 +563,10 @@ apple-system|apple-system-hardened)
588563
-DLIBCXXABI_TEST_PARAMS="${params}"
589564

590565
step "Installing libunwind in Apple-system configuration"
591-
${CMAKE} \
566+
cmake \
592567
-S "${MONOREPO_ROOT}/runtimes" \
593568
-B "${BUILD_DIR}/unwind" \
594-
-GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
569+
-GNinja \
595570
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
596571
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/unwind" \
597572
-DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
@@ -601,13 +576,13 @@ apple-system|apple-system-hardened)
601576
-DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"
602577

603578
step "Running the libc++ tests"
604-
${NINJA} -vC "${BUILD_DIR}/cxx" check-cxx
579+
ninja -vC "${BUILD_DIR}/cxx" check-cxx
605580

606581
step "Running the libc++abi tests"
607-
${NINJA} -vC "${BUILD_DIR}/cxx" check-cxxabi
582+
ninja -vC "${BUILD_DIR}/cxx" check-cxxabi
608583

609584
step "Running the libunwind tests"
610-
${NINJA} -vC "${BUILD_DIR}/unwind" check-unwind
585+
ninja -vC "${BUILD_DIR}/unwind" check-unwind
611586
;;
612587
aarch64)
613588
clean
@@ -665,13 +640,13 @@ clang-cl-dll)
665640
# setting when cmake and the test driver does the right thing automatically.
666641
generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False"
667642
step "Running the libc++ tests"
668-
${NINJA} -vC "${BUILD_DIR}" check-cxx
643+
ninja -vC "${BUILD_DIR}" check-cxx
669644
;;
670645
clang-cl-static)
671646
clean
672647
generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF
673648
step "Running the libc++ tests"
674-
${NINJA} -vC "${BUILD_DIR}" check-cxx
649+
ninja -vC "${BUILD_DIR}" check-cxx
675650
;;
676651
clang-cl-no-vcruntime)
677652
clean
@@ -682,14 +657,14 @@ clang-cl-no-vcruntime)
682657
generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
683658
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared-no-vcruntime-clangcl.cfg.in"
684659
step "Running the libc++ tests"
685-
${NINJA} -vC "${BUILD_DIR}" check-cxx
660+
ninja -vC "${BUILD_DIR}" check-cxx
686661
;;
687662
clang-cl-debug)
688663
clean
689664
generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
690665
-DCMAKE_BUILD_TYPE=Debug
691666
step "Running the libc++ tests"
692-
${NINJA} -vC "${BUILD_DIR}" check-cxx
667+
ninja -vC "${BUILD_DIR}" check-cxx
693668
;;
694669
clang-cl-static-crt)
695670
clean
@@ -698,7 +673,7 @@ clang-cl-static-crt)
698673
generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \
699674
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
700675
step "Running the libc++ tests"
701-
${NINJA} -vC "${BUILD_DIR}" check-cxx
676+
ninja -vC "${BUILD_DIR}" check-cxx
702677
;;
703678
mingw-dll)
704679
clean
@@ -744,7 +719,7 @@ mingw-incomplete-sysroot)
744719
# Only test that building succeeds; there's not much extra value in running
745720
# the tests here, as it would be equivalent to the mingw-dll config above.
746721
step "Building the runtimes"
747-
${NINJA} -vC "${BUILD_DIR}"
722+
ninja -vC "${BUILD_DIR}"
748723
;;
749724
aix)
750725
clean
@@ -781,7 +756,7 @@ android-ndk-*)
781756
-DLIBCXX_TEST_PARAMS="${PARAMS}" \
782757
-DLIBCXXABI_TEST_PARAMS="${PARAMS}"
783758
check-abi-list
784-
${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi
759+
ninja -vC "${BUILD_DIR}" install-cxx install-cxxabi
785760

786761
# Start the emulator and make sure we can connect to the adb server running
787762
# inside of it.
@@ -794,9 +769,9 @@ android-ndk-*)
794769
adb shell mkdir -p /data/local/tmp/adb_run
795770
adb push "${BUILD_DIR}/lib/libc++_shared.so" /data/local/tmp/libc++/libc++_shared.so
796771
step "Running the libc++ tests"
797-
${NINJA} -vC "${BUILD_DIR}" check-cxx
772+
ninja -vC "${BUILD_DIR}" check-cxx
798773
step "Running the libc++abi tests"
799-
${NINJA} -vC "${BUILD_DIR}" check-cxxabi
774+
ninja -vC "${BUILD_DIR}" check-cxxabi
800775
;;
801776
#################################################################
802777
# Insert vendor-specific internal configurations below.

0 commit comments

Comments
 (0)