Skip to content

Commit 1129186

Browse files
committed
[libc++] Fix local runs of the bootstrapping-build job
The bootstrapping-build job defined in run-buildbot required the CC and CXX environment variables to be defined even though run-buildbot documents these environment variables as being optional. It also required ccache, which may not be available for local builds. This patch tweaks the script slightly to better deal with the absence of these environment variables/tools.
1 parent 825943e commit 1129186

File tree

5 files changed

+105
-41
lines changed

5 files changed

+105
-41
lines changed

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ jobs:
223223
source .venv/bin/activate
224224
python -m pip install psutil
225225
xcrun bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
226+
env:
227+
CC: clang
228+
CXX: clang++
226229
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
227230
if: always() # Upload artifacts even if the build or test suite fails
228231
with:
@@ -241,16 +244,16 @@ jobs:
241244
fail-fast: false
242245
matrix:
243246
include:
244-
- { config: clang-cl-dll, mingw: false }
245-
- { config: clang-cl-static, mingw: false }
246-
- { config: clang-cl-no-vcruntime, mingw: false }
247-
- { config: clang-cl-debug, mingw: false }
248-
- { config: clang-cl-static-crt, mingw: false }
249-
- { config: mingw-dll, mingw: true }
250-
- { config: mingw-static, mingw: true }
251-
- { config: mingw-dll-i686, mingw: true }
252-
- { config: mingw-incomplete-sysroot, mingw: true }
253-
- { config: mingw-static, mingw: true, runner: windows-11-arm }
247+
- { config: clang-cl-dll, mingw: false, cc: clang-cl, cxx: clang-cl }
248+
- { config: clang-cl-static, mingw: false, cc: clang-cl, cxx: clang-cl }
249+
- { config: clang-cl-no-vcruntime, mingw: false, cc: clang-cl, cxx: clang-cl }
250+
- { config: clang-cl-debug, mingw: false, cc: clang-cl, cxx: clang-cl }
251+
- { config: clang-cl-static-crt, mingw: false, cc: clang-cl, cxx: clang-cl }
252+
- { config: mingw-dll, mingw: true, cc: clang-cl, cxx: clang-cl }
253+
- { config: mingw-dll, mingw: true, cc: i686-w64-mingw32-clang, cxx: i686-w64-mingw32-clang++ }
254+
- { config: mingw-static, mingw: true, cc: clang-cl, cxx: clang-cl }
255+
- { config: mingw-incomplete-sysroot, mingw: true, cc: clang-cl, cxx: clang-cl }
256+
- { config: mingw-static, mingw: true, cc: clang-cl, cxx: clang-cl, runner: windows-11-arm }
254257
runs-on: ${{ matrix.runner != '' && matrix.runner || 'windows-2022' }}
255258
steps:
256259
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -286,5 +289,7 @@ jobs:
286289
run: |
287290
echo "c:\Program Files\LLVM\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
288291
- name: Build and test
289-
run: |
290-
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
292+
run: bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
293+
env:
294+
CC: ${{ matrix.cc }}
295+
CXX: ${{ matrix.cxx }}

.github/workflows/libcxx-check-generated-files.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ jobs:
2222

2323
- name: Check generated files
2424
run: libcxx/utils/ci/run-buildbot check-generated-output
25+
env:
26+
CC: cc
27+
CXX: c++

libcxx/docs/AddingNewCIJobs.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ An example of a job definition is:
2828
2929
- label: "C++11"
3030
command: "libcxx/utils/ci/run-buildbot generic-cxx11"
31+
env:
32+
CC: clang
33+
CXX: clang++
3134
artifact_paths:
3235
- "**/test-results.xml"
3336
agents:

libcxx/utils/ci/buildkite-pipeline.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,55 +37,79 @@ steps:
3737
steps:
3838
- label: AArch64
3939
command: libcxx/utils/ci/run-buildbot aarch64
40+
env:
41+
CC: clang
42+
CXX: clang++
4043
agents:
4144
queue: libcxx-builders-linaro-arm
4245
arch: aarch64
4346
<<: *common
4447

4548
- label: AArch64 -fno-exceptions
4649
command: libcxx/utils/ci/run-buildbot aarch64-no-exceptions
50+
env:
51+
CC: clang
52+
CXX: clang++
4753
agents:
4854
queue: libcxx-builders-linaro-arm
4955
arch: aarch64
5056
<<: *common
5157

5258
- label: Armv8
5359
command: libcxx/utils/ci/run-buildbot armv8
60+
env:
61+
CC: clang
62+
CXX: clang++
5463
agents:
5564
queue: libcxx-builders-linaro-arm
5665
arch: armv8l
5766
<<: *common
5867

5968
- label: Armv8 -fno-exceptions
6069
command: libcxx/utils/ci/run-buildbot armv8-no-exceptions
70+
env:
71+
CC: clang
72+
CXX: clang++
6173
agents:
6274
queue: libcxx-builders-linaro-arm
6375
arch: armv8l
6476
<<: *common
6577

6678
- label: Armv7
6779
command: libcxx/utils/ci/run-buildbot armv7
80+
env:
81+
CC: clang
82+
CXX: clang++
6883
agents:
6984
queue: libcxx-builders-linaro-arm
7085
arch: armv8l
7186
<<: *common
7287

7388
- label: Armv7 -fno-exceptions
7489
command: libcxx/utils/ci/run-buildbot armv7-no-exceptions
90+
env:
91+
CC: clang
92+
CXX: clang++
7593
agents:
7694
queue: libcxx-builders-linaro-arm
7795
arch: armv8l
7896
<<: *common
7997

8098
- label: Armv7-M picolibc
8199
command: libcxx/utils/ci/run-buildbot armv7m-picolibc
100+
env:
101+
CC: clang
102+
CXX: clang++
82103
agents:
83104
queue: libcxx-builders-linaro-arm
84105
arch: aarch64
85106
<<: *common
86107

87108
- label: Armv7-M picolibc -fno-exceptions
88109
command: libcxx/utils/ci/run-buildbot armv7m-picolibc-no-exceptions
110+
env:
111+
CC: clang
112+
CXX: clang++
89113
agents:
90114
queue: libcxx-builders-linaro-arm
91115
arch: aarch64
@@ -131,13 +155,19 @@ steps:
131155
steps:
132156
- label: Android 5.0, x86 NDK
133157
command: libcxx/utils/ci/run-buildbot android-ndk-21-def-x86
158+
env:
159+
CC: /opt/android/clang/clang-current/bin/clang
160+
CXX: /opt/android/clang/clang-current/bin/clang++
134161
agents:
135162
queue: libcxx-builders
136163
os: android
137164
<<: *common
138165

139166
- label: Android 13, x86_64 NDK
140167
command: libcxx/utils/ci/run-buildbot android-ndk-33-goog-x86_64
168+
env:
169+
CC: /opt/android/clang/clang-current/bin/clang
170+
CXX: /opt/android/clang/clang-current/bin/clang++
141171
agents:
142172
queue: libcxx-builders
143173
os: android

libcxx/utils/ci/run-buildbot

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,41 @@ ${PROGNAME} [options] <BUILDER>
3030
3131
Environment variables
3232
CC The C compiler to use, this value is used by CMake. This
33-
variable is optional.
33+
variable is mandatory.
3434
3535
CXX The C++ compiler to use, this value is used by CMake. This
36-
variable is optional.
37-
38-
CLANG_FORMAT The clang-format binary to use when generating the format
39-
ignore list.
36+
variable is mandatory.
4037
38+
CCACHE The ccache binary to use. This variable is optional and is only
39+
used by the bootstrapping build.
4140
EOF
4241
}
4342

43+
function step() {
44+
endstep
45+
set +x
46+
if [[ ! -z ${GITHUB_ACTIONS+x} ]]; then
47+
echo "::group::$1"
48+
export IN_GROUP=1
49+
else
50+
echo "--- $1"
51+
fi
52+
set -x
53+
}
54+
55+
function endstep() {
56+
set +x
57+
if [[ ! -z ${GITHUB_ACTIONS+x} ]] && [[ ! -z ${IN_GROUP+x} ]]; then
58+
echo "::endgroup::"
59+
unset IN_GROUP
60+
fi
61+
set -x
62+
}
63+
64+
function error() {
65+
echo "::error::$1"
66+
}
67+
4468
if [[ $# == 0 ]]; then
4569
usage
4670
exit 0
@@ -96,6 +120,23 @@ function error() {
96120
echo "::error::$1"
97121
}
98122

123+
if [ -z ${CC+x} ]; then
124+
error "Environment variable CC must be defined"
125+
exit 1
126+
fi
127+
128+
if [ -z ${CXX+x} ]; then
129+
error "Environment variable CXX must be defined"
130+
exit 1
131+
fi
132+
133+
# Print the version of a few tools to aid diagnostics in some cases
134+
step "Diagnose tools in use"
135+
cmake --version
136+
ninja --version
137+
${CC} --version
138+
${CXX} --version
139+
99140
function clean() {
100141
rm -rf "${BUILD_DIR}"
101142
}
@@ -127,11 +168,7 @@ function generate-cmake() {
127168
}
128169

129170
function 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-
"${@}"
171+
generate-cmake-base -DLLVM_ENABLE_RUNTIMES="libcxx" "${@}"
135172
}
136173

137174
function generate-cmake-android() {
@@ -215,12 +252,6 @@ function test-armv7m-picolibc() {
215252
check-runtimes
216253
}
217254

218-
# Print the version of a few tools to aid diagnostics in some cases
219-
step "Diagnose tools in use"
220-
cmake --version
221-
ninja --version
222-
if [ ! -z "${CXX}" ]; then ${CXX} --version; fi
223-
224255
case "${BUILDER}" in
225256
check-generated-output)
226257
# `! foo` doesn't work properly with `set -e`, use `! foo || false` instead.
@@ -357,12 +388,16 @@ generic-ubsan)
357388
bootstrapping-build)
358389
clean
359390

391+
if [ ! -z ${CCACHE+x} ]; then
392+
COMPILER_LAUNCHER="-DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE}"
393+
fi
394+
360395
step "Generating CMake"
361396
cmake \
362397
-S "${MONOREPO_ROOT}/llvm" \
363398
-B "${BUILD_DIR}" \
364399
-GNinja \
365-
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
400+
${COMPILER_LAUNCHER} \
366401
-DCMAKE_BUILD_TYPE=Release \
367402
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
368403
-DLLVM_ENABLE_PROJECTS="clang;lldb" \
@@ -689,14 +724,6 @@ mingw-static)
689724
-DLIBUNWIND_ENABLE_SHARED=OFF
690725
check-runtimes
691726
;;
692-
mingw-dll-i686)
693-
clean
694-
generate-cmake \
695-
-DCMAKE_C_COMPILER=i686-w64-mingw32-clang \
696-
-DCMAKE_CXX_COMPILER=i686-w64-mingw32-clang++ \
697-
-C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
698-
check-runtimes
699-
;;
700727
mingw-incomplete-sysroot)
701728
# When bringing up a new cross compiler from scratch, we build
702729
# libunwind/libcxx in a setup where the toolchain is incomplete and
@@ -741,10 +768,6 @@ android-ndk-*)
741768
fi
742769
ARCH=$(arch_of_emu_img ${ANDROID_EMU_IMG})
743770

744-
# Use the Android compiler by default.
745-
export CC=${CC:-/opt/android/clang/clang-current/bin/clang}
746-
export CXX=${CXX:-/opt/android/clang/clang-current/bin/clang++}
747-
748771
# The NDK libc++_shared.so is always built against the oldest supported API
749772
# level. When tests are run against a device with a newer API level, test
750773
# programs can be built for any supported API level, but building for the

0 commit comments

Comments
 (0)