Skip to content

Commit b215ced

Browse files
committed
Merge branch 'main' into reland-m-prefetch
2 parents 70bb924 + dbb3e7d commit b215ced

File tree

17,273 files changed

+1672180
-650606
lines changed

Some content is hidden

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

17,273 files changed

+1672180
-650606
lines changed

.ci/compute_projects.py

Lines changed: 98 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,41 @@
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+
".ci": {"compiler-rt", "libc"},
81+
}
82+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
83+
"llvm": {"libcxx", "libcxxabi", "libunwind"},
84+
"clang": {"libcxx", "libcxxabi", "libunwind"},
85+
".ci": {"libcxx", "libcxxabi", "libunwind"},
86+
}
6187

6288
EXCLUDE_LINUX = {
6389
"cross-project-tests", # TODO(issues/132796): Tests are failing.
@@ -86,9 +112,6 @@
86112
"cross-project-tests",
87113
"flang",
88114
"libc",
89-
"libcxx",
90-
"libcxxabi",
91-
"libunwind",
92115
"lldb",
93116
"openmp",
94117
"polly",
@@ -115,21 +138,35 @@
115138
"polly": "check-polly",
116139
}
117140

118-
RUNTIMES = {"libcxx", "libcxxabi", "libunwind"}
141+
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
119142

120143

121-
def _add_dependencies(projects: Set[str]) -> Set[str]:
144+
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
122145
projects_with_dependents = set(projects)
123146
current_projects_count = 0
124147
while current_projects_count != len(projects_with_dependents):
125148
current_projects_count = len(projects_with_dependents)
126149
for project in list(projects_with_dependents):
127-
if project not in PROJECT_DEPENDENCIES:
128-
continue
129-
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
150+
if project in PROJECT_DEPENDENCIES:
151+
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
152+
for runtime in runtimes:
153+
if runtime in PROJECT_DEPENDENCIES:
154+
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
130155
return projects_with_dependents
131156

132157

158+
def _exclude_projects(current_projects: Set[str], platform: str) -> Set[str]:
159+
if platform == "Linux":
160+
to_exclude = EXCLUDE_LINUX
161+
elif platform == "Windows":
162+
to_exclude = EXCLUDE_WINDOWS
163+
elif platform == "Darwin":
164+
to_exclude = EXCLUDE_MAC
165+
else:
166+
raise ValueError(f"Unexpected platform: {platform}")
167+
return current_projects.difference(to_exclude)
168+
169+
133170
def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
134171
projects_to_test = set()
135172
for modified_project in modified_projects:
@@ -147,50 +184,52 @@ def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set
147184
):
148185
continue
149186
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.")
187+
projects_to_test = _exclude_projects(projects_to_test, platform)
164188
return projects_to_test
165189

166190

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

170196

171197
def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
172198
check_targets = set()
173199
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])
200+
if project_to_test in PROJECT_CHECK_TARGETS:
201+
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
177202
return check_targets
178203

179204

180-
def _compute_runtimes_to_test(projects_to_test: Set[str]) -> Set[str]:
205+
def _compute_runtimes_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
181206
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
207+
for modified_project in modified_projects:
208+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST:
209+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
210+
return _exclude_projects(runtimes_to_test, platform)
187211

188212

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
213+
def _compute_runtimes_to_test_needs_reconfig(
214+
modified_projects: Set[str], platform: str
215+
) -> Set[str]:
216+
runtimes_to_test = set()
217+
for modified_project in modified_projects:
218+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
219+
runtimes_to_test.update(
220+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
221+
)
222+
return _exclude_projects(runtimes_to_test, platform)
223+
224+
225+
def _compute_runtimes_to_build(
226+
runtimes_to_test: Set[str], modified_projects: Set[str], platform: str
227+
) -> Set[str]:
228+
runtimes_to_build = set(runtimes_to_test)
229+
for modified_project in modified_projects:
230+
if modified_project in DEPENDENT_RUNTIMES_TO_BUILD:
231+
runtimes_to_build.update(DEPENDENT_RUNTIMES_TO_BUILD[modified_project])
232+
return _exclude_projects(runtimes_to_build, platform)
194233

195234

196235
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
@@ -214,19 +253,31 @@ def _get_modified_projects(modified_files: list[str]) -> Set[str]:
214253
def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
215254
modified_projects = _get_modified_projects(modified_files)
216255
projects_to_test = _compute_projects_to_test(modified_projects, platform)
217-
projects_to_build = _compute_projects_to_build(projects_to_test)
256+
runtimes_to_test = _compute_runtimes_to_test(modified_projects, platform)
257+
runtimes_to_test_needs_reconfig = _compute_runtimes_to_test_needs_reconfig(
258+
modified_projects, platform
259+
)
260+
runtimes_to_build = _compute_runtimes_to_build(
261+
runtimes_to_test | runtimes_to_test_needs_reconfig, modified_projects, platform
262+
)
263+
projects_to_build = _compute_projects_to_build(projects_to_test, runtimes_to_build)
218264
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)
265+
runtimes_check_targets = _compute_project_check_targets(runtimes_to_test)
266+
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
267+
runtimes_to_test_needs_reconfig
268+
)
221269
# We use a semicolon to separate the projects/runtimes as they get passed
222270
# to the CMake invocation and thus we need to use the CMake list separator
223271
# (;). We use spaces to separate the check targets as they end up getting
224272
# passed to ninja.
225273
return {
226274
"projects_to_build": ";".join(sorted(projects_to_build)),
227275
"project_check_targets": " ".join(sorted(projects_check_targets)),
228-
"runtimes_to_build": ";".join(sorted(runtimes_to_test)),
276+
"runtimes_to_build": ";".join(sorted(runtimes_to_build)),
229277
"runtimes_check_targets": " ".join(sorted(runtimes_check_targets)),
278+
"runtimes_check_targets_needs_reconfig": " ".join(
279+
sorted(runtimes_check_targets_needs_reconfig)
280+
),
230281
}
231282

232283

0 commit comments

Comments
 (0)