Skip to content

Commit 1b278fc

Browse files
[CI] Migrate to runtimes build
This patch migrates the premerge pipeline to use LLVM_ENABLE_RUNTIMES to build libc and compiler-rt. Pull Request: llvm#142696
1 parent ee7ad96 commit 1b278fc

File tree

4 files changed

+124
-49
lines changed

4 files changed

+124
-49
lines changed

.ci/compute_projects.py

Lines changed: 73 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
},
5050
"lld": {"bolt", "cross-project-tests"},
5151
# TODO(issues/132795): LLDB should be enabled on clang changes.
52-
"clang": {"clang-tools-extra", "compiler-rt", "cross-project-tests"},
53-
"clang-tools-extra": {"libc"},
52+
"clang": {"clang-tools-extra", "cross-project-tests"},
5453
"mlir": {"flang"},
5554
# Test everything if ci scripts are changed.
5655
# FIXME: Figure out what is missing and add here.
@@ -64,7 +63,14 @@
6463

6564
# This mapping describes runtimes that should be tested when the key project is
6665
# touched.
67-
DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}}
66+
DEPENDENT_RUNTIMES_TO_TEST = {
67+
"clang": {"compiler-rt"},
68+
}
69+
DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG = {
70+
"llvm": {"libcxx", "libcxxabi", "libunwind"},
71+
"clang": {"libcxx", "libcxxabi", "libunwind"},
72+
".ci": {"libcxx", "libcxxabi", "libunwind"},
73+
}
6874

6975
EXCLUDE_LINUX = {
7076
"cross-project-tests", # TODO(issues/132796): Tests are failing.
@@ -93,9 +99,6 @@
9399
"cross-project-tests",
94100
"flang",
95101
"libc",
96-
"libcxx",
97-
"libcxxabi",
98-
"libunwind",
99102
"lldb",
100103
"openmp",
101104
"polly",
@@ -122,10 +125,10 @@
122125
"polly": "check-polly",
123126
}
124127

125-
RUNTIMES = {"libcxx", "libcxxabi", "libunwind"}
128+
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
126129

127130

128-
def _add_dependencies(projects: Set[str]) -> Set[str]:
131+
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
129132
projects_with_dependents = set(projects)
130133
current_projects_count = 0
131134
while current_projects_count != len(projects_with_dependents):
@@ -134,9 +137,25 @@ def _add_dependencies(projects: Set[str]) -> Set[str]:
134137
if project not in PROJECT_DEPENDENCIES:
135138
continue
136139
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
140+
for runtime in runtimes:
141+
if runtime not in PROJECT_DEPENDENCIES:
142+
continue
143+
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
137144
return projects_with_dependents
138145

139146

147+
def _exclude_projects(current_projects: Set[str], platform: str) -> Set[str]:
148+
if platform == "Linux":
149+
to_exclude = EXCLUDE_LINUX
150+
elif platform == "Windows":
151+
to_exclude = EXCLUDE_WINDOWS
152+
elif platform == "Darwin":
153+
to_exclude = EXCLUDE_MAC
154+
else:
155+
raise ValueError(f"Unexpected platform: {platform}")
156+
return current_projects.difference(to_exclude)
157+
158+
140159
def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
141160
projects_to_test = set()
142161
for modified_project in modified_projects:
@@ -154,25 +173,14 @@ def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set
154173
):
155174
continue
156175
projects_to_test.add(dependent_project)
157-
if platform == "Linux":
158-
for to_exclude in EXCLUDE_LINUX:
159-
if to_exclude in projects_to_test:
160-
projects_to_test.remove(to_exclude)
161-
elif platform == "Windows":
162-
for to_exclude in EXCLUDE_WINDOWS:
163-
if to_exclude in projects_to_test:
164-
projects_to_test.remove(to_exclude)
165-
elif platform == "Darwin":
166-
for to_exclude in EXCLUDE_MAC:
167-
if to_exclude in projects_to_test:
168-
projects_to_test.remove(to_exclude)
169-
else:
170-
raise ValueError("Unexpected platform.")
176+
projects_to_test = _exclude_projects(projects_to_test, platform)
171177
return projects_to_test
172178

173179

174-
def _compute_projects_to_build(projects_to_test: Set[str]) -> Set[str]:
175-
return _add_dependencies(projects_to_test)
180+
def _compute_projects_to_build(
181+
projects_to_test: Set[str], runtimes: Set[str]
182+
) -> Set[str]:
183+
return _add_dependencies(projects_to_test, runtimes)
176184

177185

178186
def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
@@ -184,24 +192,36 @@ def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
184192
return check_targets
185193

186194

187-
def _compute_runtimes_to_test(projects_to_test: Set[str]) -> Set[str]:
195+
def _compute_runtimes_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
188196
runtimes_to_test = set()
189-
for project_to_test in projects_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])
194-
return runtimes_to_test
197+
for modified_project in modified_projects:
198+
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST:
199+
continue
200+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
201+
return _exclude_projects(runtimes_to_test, platform)
195202

196203

197-
def _compute_runtime_check_targets(projects_to_test: Set[str]) -> Set[str]:
198-
check_targets = set()
199-
for project_to_test in projects_to_test:
200-
if project_to_test not in DEPENDENT_RUNTIMES_TO_TEST:
204+
def _compute_runtimes_to_test_multiconfig(
205+
modified_projects: Set[str], platform: str
206+
) -> Set[str]:
207+
runtimes_to_test = set()
208+
for modified_project in modified_projects:
209+
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG:
201210
continue
202-
for runtime_to_test in DEPENDENT_RUNTIMES_TO_TEST[project_to_test]:
203-
check_targets.add(PROJECT_CHECK_TARGETS[runtime_to_test])
204-
return check_targets
211+
runtimes_to_test.update(
212+
DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG[modified_project]
213+
)
214+
return _exclude_projects(runtimes_to_test, platform)
215+
216+
217+
def _compute_runtimes_to_build(
218+
runtimes_to_test: Set[str], modified_projects: Set[str], platform: str
219+
) -> Set[str]:
220+
runtimes_to_build = set(runtimes_to_test)
221+
for modified_project in modified_projects:
222+
if modified_project in DEPENDENT_RUNTIMES_TO_BUILD:
223+
runtimes_to_build.update(DEPENDENT_RUNTIMES_TO_BUILD[modified_project])
224+
return _exclude_projects(runtimes_to_build, platform)
205225

206226

207227
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
@@ -225,10 +245,19 @@ def _get_modified_projects(modified_files: list[str]) -> Set[str]:
225245
def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
226246
modified_projects = _get_modified_projects(modified_files)
227247
projects_to_test = _compute_projects_to_test(modified_projects, platform)
228-
projects_to_build = _compute_projects_to_build(projects_to_test)
248+
runtimes_to_test = _compute_runtimes_to_test(modified_projects, platform)
249+
runtimes_to_test_multiconfig = _compute_runtimes_to_test_multiconfig(
250+
modified_projects, platform
251+
)
252+
runtimes_to_build = _compute_runtimes_to_build(
253+
runtimes_to_test | runtimes_to_test_multiconfig, modified_projects, platform
254+
)
255+
projects_to_build = _compute_projects_to_build(projects_to_test, runtimes_to_build)
229256
projects_check_targets = _compute_project_check_targets(projects_to_test)
230-
runtimes_to_build = _compute_runtimes_to_test(projects_to_test)
231-
runtimes_check_targets = _compute_runtime_check_targets(projects_to_test)
257+
runtimes_check_targets = _compute_project_check_targets(runtimes_to_test)
258+
runtimes_check_targets_multiconfig = _compute_project_check_targets(
259+
runtimes_to_test_multiconfig
260+
)
232261
# We use a semicolon to separate the projects/runtimes as they get passed
233262
# to the CMake invocation and thus we need to use the CMake list separator
234263
# (;). We use spaces to separate the check targets as they end up getting
@@ -238,6 +267,9 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
238267
"project_check_targets": " ".join(sorted(projects_check_targets)),
239268
"runtimes_to_build": ";".join(sorted(runtimes_to_build)),
240269
"runtimes_check_targets": " ".join(sorted(runtimes_check_targets)),
270+
"runtimes_check_targets_multiconfig": " ".join(
271+
sorted(runtimes_check_targets_multiconfig)
272+
),
241273
}
242274

243275

.ci/compute_projects_test.py

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ def test_llvm(self):
2626
)
2727
self.assertEqual(
2828
env_variables["runtimes_check_targets"],
29+
"",
30+
)
31+
self.assertEqual(
32+
env_variables["runtimes_check_targets_multiconfig"],
2933
"check-cxx check-cxxabi check-unwind",
3034
)
3135

@@ -46,6 +50,10 @@ def test_llvm_windows(self):
4650
)
4751
self.assertEqual(
4852
env_variables["runtimes_check_targets"],
53+
"",
54+
)
55+
self.assertEqual(
56+
env_variables["runtimes_check_targets_multiconfig"],
4957
"check-cxx check-cxxabi check-unwind",
5058
)
5159

@@ -66,6 +74,10 @@ def test_llvm_mac(self):
6674
)
6775
self.assertEqual(
6876
env_variables["runtimes_check_targets"],
77+
"",
78+
)
79+
self.assertEqual(
80+
env_variables["runtimes_check_targets_multiconfig"],
6981
"check-cxx check-cxxabi check-unwind",
7082
)
7183

@@ -75,17 +87,21 @@ def test_clang(self):
7587
)
7688
self.assertEqual(
7789
env_variables["projects_to_build"],
78-
"clang;clang-tools-extra;compiler-rt;lld;llvm",
90+
"clang;clang-tools-extra;lld;llvm",
7991
)
8092
self.assertEqual(
8193
env_variables["project_check_targets"],
82-
"check-clang check-clang-tools check-compiler-rt",
94+
"check-clang check-clang-tools",
8395
)
8496
self.assertEqual(
85-
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
97+
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
8698
)
8799
self.assertEqual(
88100
env_variables["runtimes_check_targets"],
101+
"check-compiler-rt",
102+
)
103+
self.assertEqual(
104+
env_variables["runtimes_check_targets_multiconfig"],
89105
"check-cxx check-cxxabi check-unwind",
90106
)
91107

@@ -104,6 +120,10 @@ def test_clang_windows(self):
104120
)
105121
self.assertEqual(
106122
env_variables["runtimes_check_targets"],
123+
"",
124+
)
125+
self.assertEqual(
126+
env_variables["runtimes_check_targets_multiconfig"],
107127
"check-cxx check-cxxabi check-unwind",
108128
)
109129

@@ -115,6 +135,7 @@ def test_bolt(self):
115135
self.assertEqual(env_variables["project_check_targets"], "check-bolt")
116136
self.assertEqual(env_variables["runtimes_to_build"], "")
117137
self.assertEqual(env_variables["runtimes_check_targets"], "")
138+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
118139

119140
def test_lldb(self):
120141
env_variables = compute_projects.get_env_variables(
@@ -124,6 +145,7 @@ def test_lldb(self):
124145
self.assertEqual(env_variables["project_check_targets"], "check-lldb")
125146
self.assertEqual(env_variables["runtimes_to_build"], "")
126147
self.assertEqual(env_variables["runtimes_check_targets"], "")
148+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
127149

128150
def test_mlir(self):
129151
env_variables = compute_projects.get_env_variables(
@@ -135,6 +157,7 @@ def test_mlir(self):
135157
)
136158
self.assertEqual(env_variables["runtimes_to_build"], "")
137159
self.assertEqual(env_variables["runtimes_check_targets"], "")
160+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
138161

139162
def test_flang(self):
140163
env_variables = compute_projects.get_env_variables(
@@ -144,6 +167,7 @@ def test_flang(self):
144167
self.assertEqual(env_variables["project_check_targets"], "check-flang")
145168
self.assertEqual(env_variables["runtimes_to_build"], "")
146169
self.assertEqual(env_variables["runtimes_check_targets"], "")
170+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
147171

148172
def test_invalid_subproject(self):
149173
env_variables = compute_projects.get_env_variables(
@@ -153,13 +177,15 @@ def test_invalid_subproject(self):
153177
self.assertEqual(env_variables["project_check_targets"], "")
154178
self.assertEqual(env_variables["runtimes_to_build"], "")
155179
self.assertEqual(env_variables["runtimes_check_targets"], "")
180+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
156181

157182
def test_top_level_file(self):
158183
env_variables = compute_projects.get_env_variables(["README.md"], "Linux")
159184
self.assertEqual(env_variables["projects_to_build"], "")
160185
self.assertEqual(env_variables["project_check_targets"], "")
161186
self.assertEqual(env_variables["runtimes_to_build"], "")
162187
self.assertEqual(env_variables["runtimes_check_targets"], "")
188+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
163189

164190
def test_exclude_runtiems_in_projects(self):
165191
env_variables = compute_projects.get_env_variables(
@@ -169,6 +195,7 @@ def test_exclude_runtiems_in_projects(self):
169195
self.assertEqual(env_variables["project_check_targets"], "")
170196
self.assertEqual(env_variables["runtimes_to_build"], "")
171197
self.assertEqual(env_variables["runtimes_check_targets"], "")
198+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
172199

173200
def test_exclude_docs(self):
174201
env_variables = compute_projects.get_env_variables(
@@ -178,6 +205,7 @@ def test_exclude_docs(self):
178205
self.assertEqual(env_variables["project_check_targets"], "")
179206
self.assertEqual(env_variables["runtimes_to_build"], "")
180207
self.assertEqual(env_variables["runtimes_check_targets"], "")
208+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
181209

182210
def test_exclude_gn(self):
183211
env_variables = compute_projects.get_env_variables(
@@ -187,6 +215,7 @@ def test_exclude_gn(self):
187215
self.assertEqual(env_variables["project_check_targets"], "")
188216
self.assertEqual(env_variables["runtimes_to_build"], "")
189217
self.assertEqual(env_variables["runtimes_check_targets"], "")
218+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
190219

191220
def test_ci(self):
192221
env_variables = compute_projects.get_env_variables(
@@ -198,10 +227,15 @@ def test_ci(self):
198227
"check-clang check-lld check-lldb check-llvm",
199228
)
200229
self.assertEqual(
201-
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
230+
env_variables["runtimes_to_build"],
231+
"libcxx;libcxxabi;libunwind",
202232
)
203233
self.assertEqual(
204234
env_variables["runtimes_check_targets"],
235+
"",
236+
)
237+
self.assertEqual(
238+
env_variables["runtimes_check_targets_multiconfig"],
205239
"check-cxx check-cxxabi check-unwind",
206240
)
207241

@@ -215,6 +249,7 @@ def test_lldb(self):
215249
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
216250
)
217251
self.assertEqual(env_variables["runtimes_check_targets"], "")
252+
self.assertEqual(env_variables["runtimes_check_targets_multiconfig"], "")
218253

219254

220255
if __name__ == "__main__":

.ci/monolithic-linux.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ projects="${1}"
5757
targets="${2}"
5858
runtimes="${3}"
5959
runtime_targets="${4}"
60+
runtime_targets_multiconfig="${5}"
6061

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

@@ -93,9 +94,15 @@ echo "--- ninja"
9394
# Targets are not escaped as they are passed as separate arguments.
9495
ninja -C "${BUILD_DIR}" -k 0 ${targets}
9596

97+
if [[ "${runtime_targets}" != "" ]]; then
98+
echo "--- ninja runtimes"
99+
100+
ninja -C "${BUILD_DIR}" ${runtime_targets}
101+
fi
102+
96103
# Compiling runtimes with just-built Clang and running their tests
97104
# as an additional testing for Clang.
98-
if [[ "${runtimes_targets}" != "" ]]; then
105+
if [[ "${runtime_targets_multiconfig}" != "" ]]; then
99106
echo "--- cmake runtimes C++26"
100107

101108
cmake \
@@ -105,7 +112,7 @@ if [[ "${runtimes_targets}" != "" ]]; then
105112

106113
echo "--- ninja runtimes C++26"
107114

108-
ninja -C "${BUILD_DIR}" ${runtime_targets}
115+
ninja -C "${BUILD_DIR}" ${runtime_targets_multiconfig}
109116

110117
echo "--- cmake runtimes clang modules"
111118

@@ -116,5 +123,5 @@ if [[ "${runtimes_targets}" != "" ]]; then
116123

117124
echo "--- ninja runtimes clang modules"
118125

119-
ninja -C "${BUILD_DIR}" ${runtime_targets}
126+
ninja -C "${BUILD_DIR}" ${runtime_targets_multiconfig}
120127
fi

0 commit comments

Comments
 (0)