Skip to content

Commit c0d0ee9

Browse files
authored
Merge branch 'main' into dangling-references-latest
2 parents 44fcea1 + 494253f commit c0d0ee9

File tree

19,173 files changed

+1760752
-725213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

19,173 files changed

+1760752
-725213
lines changed

.ci/compute_projects.py

Lines changed: 99 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,42 @@
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.
56-
# FIXME: Figure out what is missing and add here.
57-
".ci": {"llvm", "clang", "lld", "lldb"},
55+
".ci": {
56+
"llvm",
57+
"clang",
58+
"lld",
59+
"lldb",
60+
"bolt",
61+
"clang-tools-extra",
62+
"mlir",
63+
"polly",
64+
"flang",
65+
"libclc",
66+
"openmp",
67+
},
5868
}
5969

60-
DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}}
70+
# This mapping describes runtimes that should be enabled for a specific project,
71+
# but not necessarily run for testing. The only case of this currently is lldb
72+
# which needs some runtimes enabled for tests.
73+
DEPENDENT_RUNTIMES_TO_BUILD = {"lldb": {"libcxx", "libcxxabi", "libunwind"}}
74+
75+
# This mapping describes runtimes that should be tested when the key project is
76+
# touched.
77+
DEPENDENT_RUNTIMES_TO_TEST = {
78+
"clang": {"compiler-rt"},
79+
"clang-tools-extra": {"libc"},
80+
"libc": {"libc"},
81+
".ci": {"compiler-rt", "libc"},
82+
}
83+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
84+
"llvm": {"libcxx", "libcxxabi", "libunwind"},
85+
"clang": {"libcxx", "libcxxabi", "libunwind"},
86+
".ci": {"libcxx", "libcxxabi", "libunwind"},
87+
}
6188

6289
EXCLUDE_LINUX = {
6390
"cross-project-tests", # TODO(issues/132796): Tests are failing.
@@ -86,9 +113,6 @@
86113
"cross-project-tests",
87114
"flang",
88115
"libc",
89-
"libcxx",
90-
"libcxxabi",
91-
"libunwind",
92116
"lldb",
93117
"openmp",
94118
"polly",
@@ -115,21 +139,35 @@
115139
"polly": "check-polly",
116140
}
117141

118-
RUNTIMES = {"libcxx", "libcxxabi", "libunwind"}
142+
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
119143

120144

121-
def _add_dependencies(projects: Set[str]) -> Set[str]:
145+
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
122146
projects_with_dependents = set(projects)
123147
current_projects_count = 0
124148
while current_projects_count != len(projects_with_dependents):
125149
current_projects_count = len(projects_with_dependents)
126150
for project in list(projects_with_dependents):
127-
if project not in PROJECT_DEPENDENCIES:
128-
continue
129-
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
151+
if project in PROJECT_DEPENDENCIES:
152+
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
153+
for runtime in runtimes:
154+
if runtime in PROJECT_DEPENDENCIES:
155+
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
130156
return projects_with_dependents
131157

132158

159+
def _exclude_projects(current_projects: Set[str], platform: str) -> Set[str]:
160+
if platform == "Linux":
161+
to_exclude = EXCLUDE_LINUX
162+
elif platform == "Windows":
163+
to_exclude = EXCLUDE_WINDOWS
164+
elif platform == "Darwin":
165+
to_exclude = EXCLUDE_MAC
166+
else:
167+
raise ValueError(f"Unexpected platform: {platform}")
168+
return current_projects.difference(to_exclude)
169+
170+
133171
def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
134172
projects_to_test = set()
135173
for modified_project in modified_projects:
@@ -147,50 +185,52 @@ def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set
147185
):
148186
continue
149187
projects_to_test.add(dependent_project)
150-
if platform == "Linux":
151-
for to_exclude in EXCLUDE_LINUX:
152-
if to_exclude in projects_to_test:
153-
projects_to_test.remove(to_exclude)
154-
elif platform == "Windows":
155-
for to_exclude in EXCLUDE_WINDOWS:
156-
if to_exclude in projects_to_test:
157-
projects_to_test.remove(to_exclude)
158-
elif platform == "Darwin":
159-
for to_exclude in EXCLUDE_MAC:
160-
if to_exclude in projects_to_test:
161-
projects_to_test.remove(to_exclude)
162-
else:
163-
raise ValueError("Unexpected platform.")
188+
projects_to_test = _exclude_projects(projects_to_test, platform)
164189
return projects_to_test
165190

166191

167-
def _compute_projects_to_build(projects_to_test: Set[str]) -> Set[str]:
168-
return _add_dependencies(projects_to_test)
192+
def _compute_projects_to_build(
193+
projects_to_test: Set[str], runtimes: Set[str]
194+
) -> Set[str]:
195+
return _add_dependencies(projects_to_test, runtimes)
169196

170197

171198
def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
172199
check_targets = set()
173200
for project_to_test in projects_to_test:
174-
if project_to_test not in PROJECT_CHECK_TARGETS:
175-
continue
176-
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
201+
if project_to_test in PROJECT_CHECK_TARGETS:
202+
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
177203
return check_targets
178204

179205

180-
def _compute_runtimes_to_test(projects_to_test: Set[str]) -> Set[str]:
206+
def _compute_runtimes_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
181207
runtimes_to_test = set()
182-
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])
186-
return runtimes_to_test
208+
for modified_project in modified_projects:
209+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST:
210+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
211+
return _exclude_projects(runtimes_to_test, platform)
187212

188213

189-
def _compute_runtime_check_targets(runtimes_to_test: Set[str]) -> Set[str]:
190-
check_targets = set()
191-
for runtime_to_test in runtimes_to_test:
192-
check_targets.add(PROJECT_CHECK_TARGETS[runtime_to_test])
193-
return check_targets
214+
def _compute_runtimes_to_test_needs_reconfig(
215+
modified_projects: Set[str], platform: str
216+
) -> Set[str]:
217+
runtimes_to_test = set()
218+
for modified_project in modified_projects:
219+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
220+
runtimes_to_test.update(
221+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
222+
)
223+
return _exclude_projects(runtimes_to_test, platform)
224+
225+
226+
def _compute_runtimes_to_build(
227+
runtimes_to_test: Set[str], modified_projects: Set[str], platform: str
228+
) -> Set[str]:
229+
runtimes_to_build = set(runtimes_to_test)
230+
for modified_project in modified_projects:
231+
if modified_project in DEPENDENT_RUNTIMES_TO_BUILD:
232+
runtimes_to_build.update(DEPENDENT_RUNTIMES_TO_BUILD[modified_project])
233+
return _exclude_projects(runtimes_to_build, platform)
194234

195235

196236
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
@@ -214,19 +254,31 @@ def _get_modified_projects(modified_files: list[str]) -> Set[str]:
214254
def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
215255
modified_projects = _get_modified_projects(modified_files)
216256
projects_to_test = _compute_projects_to_test(modified_projects, platform)
217-
projects_to_build = _compute_projects_to_build(projects_to_test)
257+
runtimes_to_test = _compute_runtimes_to_test(modified_projects, platform)
258+
runtimes_to_test_needs_reconfig = _compute_runtimes_to_test_needs_reconfig(
259+
modified_projects, platform
260+
)
261+
runtimes_to_build = _compute_runtimes_to_build(
262+
runtimes_to_test | runtimes_to_test_needs_reconfig, modified_projects, platform
263+
)
264+
projects_to_build = _compute_projects_to_build(projects_to_test, runtimes_to_build)
218265
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)
266+
runtimes_check_targets = _compute_project_check_targets(runtimes_to_test)
267+
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
268+
runtimes_to_test_needs_reconfig
269+
)
221270
# We use a semicolon to separate the projects/runtimes as they get passed
222271
# to the CMake invocation and thus we need to use the CMake list separator
223272
# (;). We use spaces to separate the check targets as they end up getting
224273
# passed to ninja.
225274
return {
226275
"projects_to_build": ";".join(sorted(projects_to_build)),
227276
"project_check_targets": " ".join(sorted(projects_check_targets)),
228-
"runtimes_to_build": ";".join(sorted(runtimes_to_test)),
277+
"runtimes_to_build": ";".join(sorted(runtimes_to_build)),
229278
"runtimes_check_targets": " ".join(sorted(runtimes_check_targets)),
279+
"runtimes_check_targets_needs_reconfig": " ".join(
280+
sorted(runtimes_check_targets_needs_reconfig)
281+
),
230282
}
231283

232284

0 commit comments

Comments
 (0)