Skip to content

Commit 9d4e81e

Browse files
committed
rebase, fix new -Wswitch and add release note
Created using spr 1.3.6-beta.1
2 parents e2471cd + 7e6adba commit 9d4e81e

File tree

14,801 files changed

+1009305
-472278
lines changed

Some content is hidden

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

14,801 files changed

+1009305
-472278
lines changed

.ci/compute_projects.py

Lines changed: 110 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
PROJECT_DEPENDENCIES = {
2020
"llvm": set(),
2121
"clang": {"llvm"},
22+
"CIR": {"clang", "mlir"},
2223
"bolt": {"clang", "lld", "llvm"},
2324
"clang-tools-extra": {"clang", "llvm"},
2425
"compiler-rt": {"clang", "lld"},
@@ -49,12 +50,23 @@
4950
},
5051
"lld": {"bolt", "cross-project-tests"},
5152
# 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"},
53+
"clang": {"clang-tools-extra", "cross-project-tests"},
5454
"mlir": {"flang"},
5555
# Test everything if ci scripts are changed.
56-
# FIXME: Figure out what is missing and add here.
57-
".ci": {"llvm", "clang", "lld", "lldb"},
56+
".ci": {
57+
"llvm",
58+
"clang",
59+
"CIR",
60+
"lld",
61+
"lldb",
62+
"bolt",
63+
"clang-tools-extra",
64+
"mlir",
65+
"polly",
66+
"flang",
67+
"libclc",
68+
"openmp",
69+
},
5870
}
5971

6072
# This mapping describes runtimes that should be enabled for a specific project,
@@ -64,7 +76,17 @@
6476

6577
# This mapping describes runtimes that should be tested when the key project is
6678
# touched.
67-
DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}}
79+
DEPENDENT_RUNTIMES_TO_TEST = {
80+
"clang": {"compiler-rt"},
81+
"clang-tools-extra": {"libc"},
82+
"libc": {"libc"},
83+
".ci": {"compiler-rt", "libc"},
84+
}
85+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
86+
"llvm": {"libcxx", "libcxxabi", "libunwind"},
87+
"clang": {"libcxx", "libcxxabi", "libunwind"},
88+
".ci": {"libcxx", "libcxxabi", "libunwind"},
89+
}
6890

6991
EXCLUDE_LINUX = {
7092
"cross-project-tests", # TODO(issues/132796): Tests are failing.
@@ -93,9 +115,6 @@
93115
"cross-project-tests",
94116
"flang",
95117
"libc",
96-
"libcxx",
97-
"libcxxabi",
98-
"libunwind",
99118
"lldb",
100119
"openmp",
101120
"polly",
@@ -111,6 +130,7 @@
111130
"lldb": "check-lldb",
112131
"llvm": "check-llvm",
113132
"clang": "check-clang",
133+
"CIR": "check-clang-cir",
114134
"bolt": "check-bolt",
115135
"lld": "check-lld",
116136
"flang": "check-flang",
@@ -122,21 +142,35 @@
122142
"polly": "check-polly",
123143
}
124144

125-
RUNTIMES = {"libcxx", "libcxxabi", "libunwind"}
145+
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
126146

127147

128-
def _add_dependencies(projects: Set[str]) -> Set[str]:
148+
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
129149
projects_with_dependents = set(projects)
130150
current_projects_count = 0
131151
while current_projects_count != len(projects_with_dependents):
132152
current_projects_count = len(projects_with_dependents)
133153
for project in list(projects_with_dependents):
134-
if project not in PROJECT_DEPENDENCIES:
135-
continue
136-
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
154+
if project in PROJECT_DEPENDENCIES:
155+
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
156+
for runtime in runtimes:
157+
if runtime in PROJECT_DEPENDENCIES:
158+
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
137159
return projects_with_dependents
138160

139161

162+
def _exclude_projects(current_projects: Set[str], platform: str) -> Set[str]:
163+
if platform == "Linux":
164+
to_exclude = EXCLUDE_LINUX
165+
elif platform == "Windows":
166+
to_exclude = EXCLUDE_WINDOWS
167+
elif platform == "Darwin":
168+
to_exclude = EXCLUDE_MAC
169+
else:
170+
raise ValueError(f"Unexpected platform: {platform}")
171+
return current_projects.difference(to_exclude)
172+
173+
140174
def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
141175
projects_to_test = set()
142176
for modified_project in modified_projects:
@@ -154,54 +188,52 @@ def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set
154188
):
155189
continue
156190
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.")
191+
projects_to_test = _exclude_projects(projects_to_test, platform)
171192
return projects_to_test
172193

173194

174-
def _compute_projects_to_build(projects_to_test: Set[str]) -> Set[str]:
175-
return _add_dependencies(projects_to_test)
195+
def _compute_projects_to_build(
196+
projects_to_test: Set[str], runtimes: Set[str]
197+
) -> Set[str]:
198+
return _add_dependencies(projects_to_test, runtimes)
176199

177200

178201
def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
179202
check_targets = set()
180203
for project_to_test in projects_to_test:
181-
if project_to_test not in PROJECT_CHECK_TARGETS:
182-
continue
183-
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
204+
if project_to_test in PROJECT_CHECK_TARGETS:
205+
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
184206
return check_targets
185207

186208

187-
def _compute_runtimes_to_test(projects_to_test: Set[str]) -> Set[str]:
209+
def _compute_runtimes_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
188210
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
211+
for modified_project in modified_projects:
212+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST:
213+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
214+
return _exclude_projects(runtimes_to_test, platform)
195215

196216

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

206238

207239
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
@@ -218,17 +250,41 @@ def _get_modified_projects(modified_files: list[str]) -> Set[str]:
218250
# capacity.
219251
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
220252
continue
253+
# If the file is in the clang/lib/CIR directory, add the CIR project.
254+
if len(path_parts) > 3 and (
255+
path_parts[:3] == ("clang", "lib", "CIR")
256+
or path_parts[:3] == ("clang", "test", "CIR")
257+
or path_parts[:4] == ("clang", "include", "clang", "CIR")
258+
):
259+
modified_projects.add("CIR")
260+
# Fall through to add clang.
221261
modified_projects.add(pathlib.Path(modified_file).parts[0])
222262
return modified_projects
223263

224264

225265
def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
226266
modified_projects = _get_modified_projects(modified_files)
227267
projects_to_test = _compute_projects_to_test(modified_projects, platform)
228-
projects_to_build = _compute_projects_to_build(projects_to_test)
268+
runtimes_to_test = _compute_runtimes_to_test(modified_projects, platform)
269+
runtimes_to_test_needs_reconfig = _compute_runtimes_to_test_needs_reconfig(
270+
modified_projects, platform
271+
)
272+
runtimes_to_build = _compute_runtimes_to_build(
273+
runtimes_to_test | runtimes_to_test_needs_reconfig, modified_projects, platform
274+
)
275+
projects_to_build = _compute_projects_to_build(projects_to_test, runtimes_to_build)
229276
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)
277+
runtimes_check_targets = _compute_project_check_targets(runtimes_to_test)
278+
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
279+
runtimes_to_test_needs_reconfig
280+
)
281+
282+
# CIR is used as a pseudo-project in this script. It is built as part of the
283+
# clang build, but it requires an explicit option to enable. We set that
284+
# option here, and remove it from the projects_to_build list.
285+
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
286+
projects_to_build.discard("CIR")
287+
232288
# We use a semicolon to separate the projects/runtimes as they get passed
233289
# to the CMake invocation and thus we need to use the CMake list separator
234290
# (;). We use spaces to separate the check targets as they end up getting
@@ -238,6 +294,10 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
238294
"project_check_targets": " ".join(sorted(projects_check_targets)),
239295
"runtimes_to_build": ";".join(sorted(runtimes_to_build)),
240296
"runtimes_check_targets": " ".join(sorted(runtimes_check_targets)),
297+
"runtimes_check_targets_needs_reconfig": " ".join(
298+
sorted(runtimes_check_targets_needs_reconfig)
299+
),
300+
"enable_cir": enable_cir,
241301
}
242302

243303

0 commit comments

Comments
 (0)