Skip to content

Commit 5010220

Browse files
authored
Merge branch 'main' into hgh/libcxx/P3044R2-sub-string_view-from-string
2 parents bfa7571 + 49ffe31 commit 5010220

File tree

4,430 files changed

+347913
-64811
lines changed

Some content is hidden

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

4,430 files changed

+347913
-64811
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: 9 additions & 4 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"},
@@ -80,7 +81,9 @@
8081
"clang-tools-extra": {"libc"},
8182
"libc": {"libc"},
8283
"compiler-rt": {"compiler-rt"},
83-
".ci": {"compiler-rt", "libc"},
84+
"flang": {"flang-rt"},
85+
"flang-rt": {"flang-rt"},
86+
".ci": {"compiler-rt", "libc", "flang-rt"},
8487
}
8588
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
8689
"llvm": {"libcxx", "libcxxabi", "libunwind"},
@@ -95,14 +98,14 @@
9598

9699
EXCLUDE_WINDOWS = {
97100
"cross-project-tests", # TODO(issues/132797): Tests are failing.
98-
"compiler-rt", # TODO(issues/132798): Tests take excessive time.
99101
"openmp", # TODO(issues/132799): Does not detect perl installation.
100102
"libc", # No Windows Support.
101103
"lldb", # TODO(issues/132800): Needs environment setup.
102104
"bolt", # No Windows Support.
103105
"libcxx",
104106
"libcxxabi",
105107
"libunwind",
108+
"flang-rt",
106109
}
107110

108111
# These are projects that we should test if the project itself is changed but
@@ -140,6 +143,7 @@
140143
"bolt": "check-bolt",
141144
"lld": "check-lld",
142145
"flang": "check-flang",
146+
"flang-rt": "check-flang-rt",
143147
"libc": "check-libc",
144148
"lld": "check-lld",
145149
"lldb": "check-lldb",
@@ -148,7 +152,7 @@
148152
"polly": "check-polly",
149153
}
150154

151-
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
155+
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc", "flang-rt"}
152156

153157
# Meta projects are projects that need explicit handling but do not reside
154158
# in their own top level folder. To add a meta project, the start of the path
@@ -333,6 +337,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
333337
current_platform = platform.system()
334338
if len(sys.argv) == 2:
335339
current_platform = sys.argv[1]
336-
env_variables = get_env_variables(sys.stdin.readlines(), current_platform)
340+
changed_files = [line.strip() for line in sys.stdin.readlines()]
341+
env_variables = get_env_variables(changed_files, current_platform)
337342
for env_variable in env_variables:
338343
print(f"{env_variable}='{env_variables[env_variable]}'")

.ci/compute_projects_test.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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"],
@@ -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,11 @@ 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",
406406
)
407407
self.assertEqual(
408408
env_variables["runtimes_check_targets"],
409-
"check-compiler-rt check-libc",
409+
"check-compiler-rt check-flang-rt check-libc",
410410
)
411411
self.assertEqual(
412412
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, [], []),

.ci/metrics/metrics.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
# by trial and error).
7171
GRAFANA_METRIC_MAX_AGE_MN = 120
7272

73+
7374
@dataclass
7475
class JobMetrics:
7576
job_name: str
@@ -243,6 +244,7 @@ def clean_up_libcxx_job_name(old_name: str) -> str:
243244
new_name = stage + "_" + remainder
244245
return new_name
245246

247+
246248
def github_get_metrics(
247249
github_repo: github.Repository, last_workflows_seen_as_completed: set[int]
248250
) -> tuple[list[JobMetrics], int]:
@@ -336,11 +338,29 @@ def github_get_metrics(
336338
name_suffix = GITHUB_JOB_TO_TRACK[name_prefix][job.name]
337339
metric_name = name_prefix + "_" + name_suffix
338340

341+
ag_metric_name = None
342+
if libcxx_testing:
343+
job_key = None
344+
if job.name.find("stage1") != -1:
345+
job_key = "stage1"
346+
elif job.name.find("stage2") != -1:
347+
job_key = "stage2"
348+
elif job.name.find("stage3") != -1:
349+
job_key = "stage3"
350+
if job_key:
351+
ag_name = (
352+
name_prefix + "_" + GITHUB_JOB_TO_TRACK[name_prefix][job_key]
353+
)
354+
339355
if task.status != "completed":
340356
if job.status == "queued":
341357
queued_count[metric_name] += 1
358+
if libcxx_testing:
359+
queued_count[ag_name] += 1
342360
elif job.status == "in_progress":
343361
running_count[metric_name] += 1
362+
if libcxx_testing:
363+
running_count[ag_name] += 1
344364
continue
345365

346366
job_result = int(job.conclusion == "success" or job.conclusion == "skipped")

.ci/metrics/metrics_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,5 +409,6 @@ def test_clean_up_libcxx_job_name(self):
409409
out_name4 = metrics.clean_up_libcxx_job_name(bad_name)
410410
self.assertEqual(out_name4, bad_name)
411411

412+
412413
if __name__ == "__main__":
413414
unittest.main()

.ci/monolithic-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6161
-D LLDB_ENABLE_PYTHON=ON \
6262
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
6363
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
64-
-D CMAKE_EXE_LINKER_FLAGS="-no-pie"
64+
-D CMAKE_EXE_LINKER_FLAGS="-no-pie" \
65+
-D LLVM_ENABLE_WERROR=ON
6566

6667
start-group "ninja"
6768

.ci/monolithic-windows.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ source .ci/utils.sh
1717

1818
projects="${1}"
1919
targets="${2}"
20+
runtimes="${3}"
21+
runtimes_targets="${4}"
2022

2123
start-group "CMake"
2224
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
@@ -46,9 +48,14 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4648
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
4749
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
4850
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
49-
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO"
51+
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \
52+
-D LLVM_ENABLE_RUNTIMES="${runtimes}"
5053

5154
start-group "ninja"
5255

5356
# Targets are not escaped as they are passed as separate arguments.
5457
ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log
58+
59+
start-group "ninja runtimes"
60+
61+
ninja -C "${BUILD_DIR}" -k 0 ${runtimes_targets} |& tee ninja_runtimes.log

0 commit comments

Comments
 (0)