Skip to content

Commit 591678b

Browse files
[CI] Explicitly compute needed runtime targets
This patch adjusts the compute_projects script to explicitly determine what runtimes should be built and what runtimes should be tested. This is mainly to support enabling runtimes for LLDB testing but not test them unless we are building clang. Reviewers: Endilll, tstellar, DavidSpickett, lnihlen Reviewed By: DavidSpickett Pull Request: #142695
1 parent eccd81f commit 591678b

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

.ci/compute_projects.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@
5757
".ci": {"llvm", "clang", "lld", "lldb"},
5858
}
5959

60+
# This mapping describes runtimes that should be enabled for a specific project,
61+
# but not necessarily run for testing. The only case of this currently is lldb
62+
# which needs some runtimes enabled for tests.
63+
DEPENDENT_RUNTIMES_TO_BUILD = {"lldb": {"libcxx", "libcxxabi", "libunwind"}}
64+
65+
# This mapping describes runtimes that should be tested when the key project is
66+
# touched.
6067
DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}}
6168

6269
EXCLUDE_LINUX = {
@@ -180,16 +187,20 @@ def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
180187
def _compute_runtimes_to_test(projects_to_test: Set[str]) -> Set[str]:
181188
runtimes_to_test = set()
182189
for project_to_test in projects_to_test:
183-
if project_to_test not in DEPENDENT_RUNTIMES_TO_TEST:
184-
continue
185-
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[project_to_test])
190+
if project_to_test in DEPENDENT_RUNTIMES_TO_TEST:
191+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[project_to_test])
192+
if project_to_test in DEPENDENT_RUNTIMES_TO_BUILD:
193+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_BUILD[project_to_test])
186194
return runtimes_to_test
187195

188196

189-
def _compute_runtime_check_targets(runtimes_to_test: Set[str]) -> Set[str]:
197+
def _compute_runtime_check_targets(projects_to_test: Set[str]) -> Set[str]:
190198
check_targets = set()
191-
for runtime_to_test in runtimes_to_test:
192-
check_targets.add(PROJECT_CHECK_TARGETS[runtime_to_test])
199+
for project_to_test in projects_to_test:
200+
if project_to_test not in DEPENDENT_RUNTIMES_TO_TEST:
201+
continue
202+
for runtime_to_test in DEPENDENT_RUNTIMES_TO_TEST[project_to_test]:
203+
check_targets.add(PROJECT_CHECK_TARGETS[runtime_to_test])
193204
return check_targets
194205

195206

@@ -216,16 +227,16 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
216227
projects_to_test = _compute_projects_to_test(modified_projects, platform)
217228
projects_to_build = _compute_projects_to_build(projects_to_test)
218229
projects_check_targets = _compute_project_check_targets(projects_to_test)
219-
runtimes_to_test = _compute_runtimes_to_test(projects_to_test)
220-
runtimes_check_targets = _compute_runtime_check_targets(runtimes_to_test)
230+
runtimes_to_build = _compute_runtimes_to_test(projects_to_test)
231+
runtimes_check_targets = _compute_runtime_check_targets(projects_to_test)
221232
# We use a semicolon to separate the projects/runtimes as they get passed
222233
# to the CMake invocation and thus we need to use the CMake list separator
223234
# (;). We use spaces to separate the check targets as they end up getting
224235
# passed to ninja.
225236
return {
226237
"projects_to_build": ";".join(sorted(projects_to_build)),
227238
"project_check_targets": " ".join(sorted(projects_check_targets)),
228-
"runtimes_to_build": ";".join(sorted(runtimes_to_test)),
239+
"runtimes_to_build": ";".join(sorted(runtimes_to_build)),
229240
"runtimes_check_targets": " ".join(sorted(runtimes_check_targets)),
230241
}
231242

.ci/compute_projects_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ def test_ci(self):
205205
"check-cxx check-cxxabi check-unwind",
206206
)
207207

208+
def test_lldb(self):
209+
env_variables = compute_projects.get_env_variables(
210+
["lldb/CMakeLists.txt"], "Linux"
211+
)
212+
self.assertEqual(env_variables["projects_to_build"], "clang;lldb;llvm")
213+
self.assertEqual(env_variables["project_check_targets"], "check-lldb")
214+
self.assertEqual(
215+
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
216+
)
217+
self.assertEqual(env_variables["runtimes_check_targets"], "")
218+
208219

209220
if __name__ == "__main__":
210221
unittest.main()

.ci/monolithic-linux.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ trap at-exit EXIT
5555

5656
projects="${1}"
5757
targets="${2}"
58+
runtimes="${3}"
59+
runtime_targets="${4}"
5860

5961
lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests"
6062

@@ -70,7 +72,7 @@ export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
7072
# It will not be built unless it is used.
7173
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
7274
-D LLVM_ENABLE_PROJECTS="${projects}" \
73-
-D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
75+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
7476
-G Ninja \
7577
-D CMAKE_PREFIX_PATH="${HOME}/.local" \
7678
-D CMAKE_BUILD_TYPE=Release \
@@ -91,17 +93,9 @@ echo "--- ninja"
9193
# Targets are not escaped as they are passed as separate arguments.
9294
ninja -C "${BUILD_DIR}" -k 0 ${targets}
9395

94-
runtimes="${3}"
95-
runtime_targets="${4}"
96-
9796
# Compiling runtimes with just-built Clang and running their tests
9897
# as an additional testing for Clang.
99-
if [[ "${runtimes}" != "" ]]; then
100-
if [[ "${runtime_targets}" == "" ]]; then
101-
echo "Runtimes to build are specified, but targets are not."
102-
exit 1
103-
fi
104-
98+
if [[ "${runtimes_targets}" != "" ]]; then
10599
echo "--- cmake runtimes C++26"
106100

107101
cmake \

0 commit comments

Comments
 (0)