Skip to content

Commit 1737696

Browse files
committed
Merge branch 'main' of github.com:arjunUpatel/llvm-project
2 parents 47d964e + 52ebb65 commit 1737696

File tree

692 files changed

+18243
-10545
lines changed

Some content is hidden

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

692 files changed

+18243
-10545
lines changed

.ci/compute_projects.py

Lines changed: 82 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,29 @@
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.
5756
".ci": {"llvm", "clang", "lld", "lldb"},
5857
}
5958

60-
DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}}
59+
# This mapping describes runtimes that should be enabled for a specific project,
60+
# but not necessarily run for testing. The only case of this currently is lldb
61+
# which needs some runtimes enabled for tests.
62+
DEPENDENT_RUNTIMES_TO_BUILD = {"lldb": {"libcxx", "libcxxabi", "libunwind"}}
63+
64+
# This mapping describes runtimes that should be tested when the key project is
65+
# touched.
66+
DEPENDENT_RUNTIMES_TO_TEST = {
67+
"clang": {"compiler-rt"},
68+
"clang-tools-extra": {"libc"},
69+
}
70+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
71+
"llvm": {"libcxx", "libcxxabi", "libunwind"},
72+
"clang": {"libcxx", "libcxxabi", "libunwind"},
73+
".ci": {"libcxx", "libcxxabi", "libunwind"},
74+
}
6175

6276
EXCLUDE_LINUX = {
6377
"cross-project-tests", # TODO(issues/132796): Tests are failing.
@@ -86,9 +100,6 @@
86100
"cross-project-tests",
87101
"flang",
88102
"libc",
89-
"libcxx",
90-
"libcxxabi",
91-
"libunwind",
92103
"lldb",
93104
"openmp",
94105
"polly",
@@ -115,10 +126,10 @@
115126
"polly": "check-polly",
116127
}
117128

118-
RUNTIMES = {"libcxx", "libcxxabi", "libunwind"}
129+
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
119130

120131

121-
def _add_dependencies(projects: Set[str]) -> Set[str]:
132+
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
122133
projects_with_dependents = set(projects)
123134
current_projects_count = 0
124135
while current_projects_count != len(projects_with_dependents):
@@ -127,9 +138,25 @@ def _add_dependencies(projects: Set[str]) -> Set[str]:
127138
if project not in PROJECT_DEPENDENCIES:
128139
continue
129140
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
141+
for runtime in runtimes:
142+
if runtime not in PROJECT_DEPENDENCIES:
143+
continue
144+
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
130145
return projects_with_dependents
131146

132147

148+
def _exclude_projects(current_projects: Set[str], platform: str) -> Set[str]:
149+
if platform == "Linux":
150+
to_exclude = EXCLUDE_LINUX
151+
elif platform == "Windows":
152+
to_exclude = EXCLUDE_WINDOWS
153+
elif platform == "Darwin":
154+
to_exclude = EXCLUDE_MAC
155+
else:
156+
raise ValueError(f"Unexpected platform: {platform}")
157+
return current_projects.difference(to_exclude)
158+
159+
133160
def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
134161
projects_to_test = set()
135162
for modified_project in modified_projects:
@@ -147,25 +174,14 @@ def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set
147174
):
148175
continue
149176
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.")
177+
projects_to_test = _exclude_projects(projects_to_test, platform)
164178
return projects_to_test
165179

166180

167-
def _compute_projects_to_build(projects_to_test: Set[str]) -> Set[str]:
168-
return _add_dependencies(projects_to_test)
181+
def _compute_projects_to_build(
182+
projects_to_test: Set[str], runtimes: Set[str]
183+
) -> Set[str]:
184+
return _add_dependencies(projects_to_test, runtimes)
169185

170186

171187
def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
@@ -177,20 +193,36 @@ def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
177193
return check_targets
178194

179195

180-
def _compute_runtimes_to_test(projects_to_test: Set[str]) -> Set[str]:
196+
def _compute_runtimes_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
181197
runtimes_to_test = set()
182-
for project_to_test in projects_to_test:
183-
if project_to_test not in DEPENDENT_RUNTIMES_TO_TEST:
198+
for modified_project in modified_projects:
199+
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST:
184200
continue
185-
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[project_to_test])
186-
return runtimes_to_test
201+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
202+
return _exclude_projects(runtimes_to_test, platform)
187203

188204

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
205+
def _compute_runtimes_to_test_needs_reconfig(
206+
modified_projects: Set[str], platform: str
207+
) -> Set[str]:
208+
runtimes_to_test = set()
209+
for modified_project in modified_projects:
210+
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
211+
continue
212+
runtimes_to_test.update(
213+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
214+
)
215+
return _exclude_projects(runtimes_to_test, platform)
216+
217+
218+
def _compute_runtimes_to_build(
219+
runtimes_to_test: Set[str], modified_projects: Set[str], platform: str
220+
) -> Set[str]:
221+
runtimes_to_build = set(runtimes_to_test)
222+
for modified_project in modified_projects:
223+
if modified_project in DEPENDENT_RUNTIMES_TO_BUILD:
224+
runtimes_to_build.update(DEPENDENT_RUNTIMES_TO_BUILD[modified_project])
225+
return _exclude_projects(runtimes_to_build, platform)
194226

195227

196228
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
@@ -214,19 +246,31 @@ def _get_modified_projects(modified_files: list[str]) -> Set[str]:
214246
def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
215247
modified_projects = _get_modified_projects(modified_files)
216248
projects_to_test = _compute_projects_to_test(modified_projects, platform)
217-
projects_to_build = _compute_projects_to_build(projects_to_test)
249+
runtimes_to_test = _compute_runtimes_to_test(modified_projects, platform)
250+
runtimes_to_test_needs_reconfig = _compute_runtimes_to_test_needs_reconfig(
251+
modified_projects, platform
252+
)
253+
runtimes_to_build = _compute_runtimes_to_build(
254+
runtimes_to_test | runtimes_to_test_needs_reconfig, modified_projects, platform
255+
)
256+
projects_to_build = _compute_projects_to_build(projects_to_test, runtimes_to_build)
218257
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)
258+
runtimes_check_targets = _compute_project_check_targets(runtimes_to_test)
259+
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
260+
runtimes_to_test_needs_reconfig
261+
)
221262
# We use a semicolon to separate the projects/runtimes as they get passed
222263
# to the CMake invocation and thus we need to use the CMake list separator
223264
# (;). We use spaces to separate the check targets as they end up getting
224265
# passed to ninja.
225266
return {
226267
"projects_to_build": ";".join(sorted(projects_to_build)),
227268
"project_check_targets": " ".join(sorted(projects_check_targets)),
228-
"runtimes_to_build": ";".join(sorted(runtimes_to_test)),
269+
"runtimes_to_build": ";".join(sorted(runtimes_to_build)),
229270
"runtimes_check_targets": " ".join(sorted(runtimes_check_targets)),
271+
"runtimes_check_targets_needs_reconfig": " ".join(
272+
sorted(runtimes_check_targets_needs_reconfig)
273+
),
230274
}
231275

232276

.ci/compute_projects_test.py

Lines changed: 62 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_needs_reconfig"],
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_needs_reconfig"],
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_needs_reconfig"],
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_needs_reconfig"],
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_needs_reconfig"],
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_needs_reconfig"], "")
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_needs_reconfig"], "")
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_needs_reconfig"], "")
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_needs_reconfig"], "")
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_needs_reconfig"], "")
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_needs_reconfig"], "")
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_needs_reconfig"], "")
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_needs_reconfig"], "")
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_needs_reconfig"], "")
190219

191220
def test_ci(self):
192221
env_variables = compute_projects.get_env_variables(
@@ -198,13 +227,42 @@ 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_needs_reconfig"],
205239
"check-cxx check-cxxabi check-unwind",
206240
)
207241

242+
def test_lldb(self):
243+
env_variables = compute_projects.get_env_variables(
244+
["lldb/CMakeLists.txt"], "Linux"
245+
)
246+
self.assertEqual(env_variables["projects_to_build"], "clang;lldb;llvm")
247+
self.assertEqual(env_variables["project_check_targets"], "check-lldb")
248+
self.assertEqual(
249+
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
250+
)
251+
self.assertEqual(env_variables["runtimes_check_targets"], "")
252+
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
253+
254+
def test_clang_tools_extra(self):
255+
env_variables = compute_projects.get_env_variables(
256+
["clang-tools-extra/CMakeLists.txt"], "Linux"
257+
)
258+
self.assertEqual(
259+
env_variables["projects_to_build"], "clang;clang-tools-extra;lld;llvm"
260+
)
261+
self.assertEqual(env_variables["project_check_targets"], "check-clang-tools")
262+
self.assertEqual(env_variables["runtimes_to_build"], "libc")
263+
self.assertEqual(env_variables["runtimes_check_targets"], "check-libc")
264+
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
265+
208266

209267
if __name__ == "__main__":
210268
unittest.main()

0 commit comments

Comments
 (0)