Skip to content

Commit 8c115ad

Browse files
committed
Merge branch 'main' of github.com:llvm/llvm-project into TypedefsOnly
2 parents 10a3a2e + d46715a commit 8c115ad

File tree

15,249 files changed

+1179360
-364686
lines changed

Some content is hidden

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

15,249 files changed

+1179360
-364686
lines changed

.ci/all_requirements.txt

Lines changed: 213 additions & 11 deletions
Large diffs are not rendered by default.

.ci/cache_lit_timing_files.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Caches .lit_test_times.txt files between premerge invocations.
5+
6+
.lit_test_times.txt files are used by lit to order tests to best take advantage
7+
of parallelism. Having them around and up to date can result in a ~15%
8+
improvement in test times. This script downloading cached test time files and
9+
uploading new versions to the GCS buckets used for caching.
10+
"""
11+
12+
import sys
13+
import os
14+
import logging
15+
import multiprocessing.pool
16+
import pathlib
17+
import glob
18+
19+
from google.cloud import storage
20+
21+
GCS_PARALLELISM = 100
22+
23+
24+
def _maybe_upload_timing_file(bucket, timing_file_path):
25+
if os.path.exists(timing_file_path):
26+
timing_file_blob = bucket.blob("lit_timing/" + timing_file_path)
27+
timing_file_blob.upload_from_filename(timing_file_path)
28+
29+
30+
def upload_timing_files(storage_client, bucket_name: str):
31+
bucket = storage_client.bucket(bucket_name)
32+
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
33+
futures = []
34+
for timing_file_path in glob.glob("**/.lit_test_times.txt", recursive=True):
35+
futures.append(
36+
thread_pool.apply_async(
37+
_maybe_upload_timing_file, (bucket, timing_file_path)
38+
)
39+
)
40+
for future in futures:
41+
future.get()
42+
print("Done uploading")
43+
44+
45+
def _maybe_download_timing_file(blob):
46+
file_name = blob.name.removeprefix("lit_timing/")
47+
pathlib.Path(os.path.dirname(file_name)).mkdir(parents=True, exist_ok=True)
48+
blob.download_to_filename(file_name)
49+
50+
51+
def download_timing_files(storage_client, bucket_name: str):
52+
bucket = storage_client.bucket(bucket_name)
53+
blobs = bucket.list_blobs(prefix="lit_timing")
54+
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
55+
futures = []
56+
for timing_file_blob in blobs:
57+
futures.append(
58+
thread_pool.apply_async(
59+
_maybe_download_timing_file, (timing_file_blob,)
60+
)
61+
)
62+
for future in futures:
63+
future.get()
64+
print("Done downloading")
65+
66+
67+
if __name__ == "__main__":
68+
if len(sys.argv) != 2:
69+
logging.fatal("Expected usage is cache_lit_timing_files.py <upload/download>")
70+
sys.exit(1)
71+
action = sys.argv[1]
72+
storage_client = storage.Client()
73+
bucket_name = os.environ["CACHE_GCS_BUCKET"]
74+
if action == "download":
75+
download_timing_files(storage_client, bucket_name)
76+
elif action == "upload":
77+
upload_timing_files(storage_client, bucket_name)
78+
else:
79+
logging.fatal("Expected usage is cache_lit_timing_files.py <upload/download>")
80+
sys.exit(1)

.ci/compute_projects.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"libc": {"clang", "lld"},
2727
"openmp": {"clang", "lld"},
2828
"flang": {"llvm", "clang"},
29+
"flang-rt": {"flang"},
2930
"lldb": {"llvm", "clang"},
3031
"libclc": {"llvm", "clang"},
3132
"lld": {"llvm"},
@@ -49,8 +50,7 @@
4950
"flang",
5051
},
5152
"lld": {"bolt", "cross-project-tests"},
52-
# TODO(issues/132795): LLDB should be enabled on clang changes.
53-
"clang": {"clang-tools-extra", "cross-project-tests"},
53+
"clang": {"clang-tools-extra", "cross-project-tests", "lldb"},
5454
"mlir": {"flang"},
5555
# Test everything if ci scripts are changed.
5656
".ci": {
@@ -81,7 +81,9 @@
8181
"clang-tools-extra": {"libc"},
8282
"libc": {"libc"},
8383
"compiler-rt": {"compiler-rt"},
84-
".ci": {"compiler-rt", "libc"},
84+
"flang": {"flang-rt"},
85+
"flang-rt": {"flang-rt"},
86+
".ci": {"compiler-rt", "libc", "flang-rt"},
8587
}
8688
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
8789
"llvm": {"libcxx", "libcxxabi", "libunwind"},
@@ -96,14 +98,14 @@
9698

9799
EXCLUDE_WINDOWS = {
98100
"cross-project-tests", # TODO(issues/132797): Tests are failing.
99-
"compiler-rt", # TODO(issues/132798): Tests take excessive time.
100101
"openmp", # TODO(issues/132799): Does not detect perl installation.
101102
"libc", # No Windows Support.
102103
"lldb", # TODO(issues/132800): Needs environment setup.
103104
"bolt", # No Windows Support.
104105
"libcxx",
105106
"libcxxabi",
106107
"libunwind",
108+
"flang-rt",
107109
}
108110

109111
# These are projects that we should test if the project itself is changed but
@@ -141,15 +143,17 @@
141143
"bolt": "check-bolt",
142144
"lld": "check-lld",
143145
"flang": "check-flang",
146+
"flang-rt": "check-flang-rt",
144147
"libc": "check-libc",
145148
"lld": "check-lld",
146149
"lldb": "check-lldb",
147150
"mlir": "check-mlir",
148151
"openmp": "check-openmp",
149152
"polly": "check-polly",
153+
"lit": "check-lit",
150154
}
151155

152-
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
156+
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc", "flang-rt"}
153157

154158
# Meta projects are projects that need explicit handling but do not reside
155159
# in their own top level folder. To add a meta project, the start of the path
@@ -163,8 +167,12 @@
163167
("llvm", "utils", "gn"): "gn",
164168
(".github", "workflows", "premerge.yaml"): ".ci",
165169
("third-party",): ".ci",
170+
("llvm", "utils", "lit"): "lit",
166171
}
167172

173+
# Projects that should run tests but cannot be explicitly built.
174+
SKIP_BUILD_PROJECTS = ["CIR", "lit"]
175+
168176
# Projects that should not run any tests. These need to be metaprojects.
169177
SKIP_PROJECTS = ["docs", "gn"]
170178

@@ -312,7 +320,9 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
312320
# clang build, but it requires an explicit option to enable. We set that
313321
# option here, and remove it from the projects_to_build list.
314322
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
315-
projects_to_build.discard("CIR")
323+
# Remove any metaprojects from the list of projects to build.
324+
for project in SKIP_BUILD_PROJECTS:
325+
projects_to_build.discard(project)
316326

317327
# We use a semicolon to separate the projects/runtimes as they get passed
318328
# to the CMake invocation and thus we need to use the CMake list separator
@@ -334,6 +344,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
334344
current_platform = platform.system()
335345
if len(sys.argv) == 2:
336346
current_platform = sys.argv[1]
337-
env_variables = get_env_variables(sys.stdin.readlines(), current_platform)
347+
changed_files = [line.strip() for line in sys.stdin.readlines()]
348+
env_variables = get_env_variables(changed_files, current_platform)
338349
for env_variable in env_variables:
339350
print(f"{env_variable}='{env_variables[env_variable]}'")

.ci/compute_projects_test.py

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def test_clang(self):
8383
)
8484
self.assertEqual(
8585
env_variables["projects_to_build"],
86-
"clang;clang-tools-extra;lld;llvm",
86+
"clang;clang-tools-extra;lld;lldb;llvm",
8787
)
8888
self.assertEqual(
8989
env_variables["project_check_targets"],
90-
"check-clang check-clang-tools",
90+
"check-clang check-clang-tools check-lldb",
9191
)
9292
self.assertEqual(
9393
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
@@ -110,15 +110,15 @@ def test_clang_windows(self):
110110
["clang/CMakeLists.txt"], "Windows"
111111
)
112112
self.assertEqual(
113-
env_variables["projects_to_build"], "clang;clang-tools-extra;llvm"
113+
env_variables["projects_to_build"], "clang;clang-tools-extra;lld;llvm"
114114
)
115115
self.assertEqual(
116116
env_variables["project_check_targets"], "check-clang check-clang-tools"
117117
)
118-
self.assertEqual(env_variables["runtimes_to_build"], "")
118+
self.assertEqual(env_variables["runtimes_to_build"], "compiler-rt")
119119
self.assertEqual(
120120
env_variables["runtimes_check_targets"],
121-
"",
121+
"check-compiler-rt",
122122
)
123123
self.assertEqual(
124124
env_variables["runtimes_check_targets_needs_reconfig"],
@@ -158,11 +158,11 @@ def test_cir(self):
158158
)
159159
self.assertEqual(
160160
env_variables["projects_to_build"],
161-
"clang;clang-tools-extra;lld;llvm;mlir",
161+
"clang;clang-tools-extra;lld;lldb;llvm;mlir",
162162
)
163163
self.assertEqual(
164164
env_variables["project_check_targets"],
165-
"check-clang check-clang-cir check-clang-tools",
165+
"check-clang check-clang-cir check-clang-tools check-lldb",
166166
)
167167
self.assertEqual(
168168
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
@@ -216,8 +216,8 @@ def test_flang(self):
216216
)
217217
self.assertEqual(env_variables["projects_to_build"], "clang;flang;llvm")
218218
self.assertEqual(env_variables["project_check_targets"], "check-flang")
219-
self.assertEqual(env_variables["runtimes_to_build"], "")
220-
self.assertEqual(env_variables["runtimes_check_targets"], "")
219+
self.assertEqual(env_variables["runtimes_to_build"], "flang-rt")
220+
self.assertEqual(env_variables["runtimes_check_targets"], "check-flang-rt")
221221
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
222222
self.assertEqual(env_variables["enable_cir"], "OFF")
223223

@@ -293,11 +293,11 @@ def test_ci(self):
293293
)
294294
self.assertEqual(
295295
env_variables["runtimes_to_build"],
296-
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
296+
"compiler-rt;flang-rt;libc;libcxx;libcxxabi;libunwind",
297297
)
298298
self.assertEqual(
299299
env_variables["runtimes_check_targets"],
300-
"check-compiler-rt check-libc",
300+
"check-compiler-rt check-flang-rt check-libc",
301301
)
302302
self.assertEqual(
303303
env_variables["runtimes_check_targets_needs_reconfig"],
@@ -318,11 +318,11 @@ def test_windows_ci(self):
318318
)
319319
self.assertEqual(
320320
env_variables["runtimes_to_build"],
321-
"",
321+
"compiler-rt",
322322
)
323323
self.assertEqual(
324324
env_variables["runtimes_check_targets"],
325-
"",
325+
"check-compiler-rt",
326326
)
327327
self.assertEqual(
328328
env_variables["runtimes_check_targets_needs_reconfig"],
@@ -367,11 +367,11 @@ def test_premerge_workflow(self):
367367
)
368368
self.assertEqual(
369369
env_variables["runtimes_to_build"],
370-
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
370+
"compiler-rt;flang-rt;libc;libcxx;libcxxabi;libunwind",
371371
)
372372
self.assertEqual(
373373
env_variables["runtimes_check_targets"],
374-
"check-compiler-rt check-libc",
374+
"check-compiler-rt check-flang-rt check-libc",
375375
)
376376
self.assertEqual(
377377
env_variables["runtimes_check_targets_needs_reconfig"],
@@ -402,11 +402,35 @@ def test_third_party_benchmark(self):
402402
)
403403
self.assertEqual(
404404
env_variables["runtimes_to_build"],
405-
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
405+
"compiler-rt;flang-rt;libc;libcxx;libcxxabi;libunwind",
406+
)
407+
self.assertEqual(
408+
env_variables["runtimes_check_targets"],
409+
"check-compiler-rt check-flang-rt check-libc",
410+
)
411+
self.assertEqual(
412+
env_variables["runtimes_check_targets_needs_reconfig"],
413+
"check-cxx check-cxxabi check-unwind",
414+
)
415+
416+
def test_lit(self):
417+
env_variables = compute_projects.get_env_variables(
418+
["llvm/utils/lit/CMakeLists.txt"], "Linux"
419+
)
420+
self.assertEqual(
421+
env_variables["projects_to_build"],
422+
"bolt;clang;clang-tools-extra;flang;lld;lldb;llvm;mlir;polly",
423+
)
424+
self.assertEqual(
425+
env_variables["project_check_targets"],
426+
"check-bolt check-clang check-clang-tools check-flang check-lit check-lld check-lldb check-llvm check-mlir check-polly",
427+
)
428+
self.assertEqual(
429+
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
406430
)
407431
self.assertEqual(
408432
env_variables["runtimes_check_targets"],
409-
"check-compiler-rt check-libc",
433+
"",
410434
)
411435
self.assertEqual(
412436
env_variables["runtimes_check_targets_needs_reconfig"],

.ci/generate_test_report_lib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ def _parse_ninja_log(ninja_log: list[str]) -> list[tuple[str, str]]:
2727
# We hit the end of the log without finding a build failure, go to
2828
# the next log.
2929
return failures
30+
# If we are doing a build with LLVM_ENABLE_RUNTIMES, we can have nested
31+
# ninja invocations. The sub-ninja will print that a subcommand failed,
32+
# and then the outer ninja will list the command that failed. We should
33+
# ignore the outer failure.
34+
if ninja_log[index - 1].startswith("ninja: build stopped:"):
35+
index += 1
36+
continue
3037
# We are trying to parse cases like the following:
3138
#
3239
# [4/5] test/4.stamp

.ci/generate_test_report_lib_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,39 @@ def test_ninja_log_multiple_failures(self):
126126
),
127127
)
128128

129+
# Test that we can correctly handle the runtimes build. the LLVM runtimes
130+
# build will involve ninja invoking more ninja processes within the
131+
# runtimes directory. This means that we see two failures for a failure in
132+
# the runtimes build: one from the inner ninja containing the actual action
133+
# that failed, and one for the sub ninja invocation that failed.
134+
def test_ninja_log_runtimes_failure(self):
135+
failures = generate_test_report_lib.find_failure_in_ninja_logs(
136+
[
137+
[
138+
"[1/5] test/1.stamp",
139+
"[2/5] test/2.stamp",
140+
"FAILED: touch test/2.stamp",
141+
"Wow! This system is really broken!",
142+
"ninja: build stopped: subcommand failed.",
143+
"FAILED: running check-runtime failed.",
144+
"<some random command>",
145+
"ninja: build stopped: subcommand failed.",
146+
]
147+
]
148+
)
149+
self.assertEqual(len(failures), 1)
150+
self.assertEqual(
151+
failures[0],
152+
(
153+
"test/2.stamp",
154+
dedent(
155+
"""\
156+
FAILED: touch test/2.stamp
157+
Wow! This system is really broken!"""
158+
),
159+
),
160+
)
161+
129162
def test_title_only(self):
130163
self.assertEqual(
131164
generate_test_report_lib.generate_report("Foo", 0, [], []),

0 commit comments

Comments
 (0)