Skip to content

Commit ea52d71

Browse files
authored
Update distros without download (#614)
Instead of computing the SHA256s ourselves we get them from github directly. Also add additional 21.1.5 distros.
1 parent ed7cff6 commit ea52d71

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

toolchain/internal/llvm_distributions.bzl

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,14 @@ _llvm_distributions = {
706706
"clang+llvm-21.1.4-x86_64-pc-windows-msvc.tar.xz": "511e4e7e0a43156cb1410578285f1db246ebb400db0018cd304c84a369562b6d",
707707

708708
# 21.1.5
709-
"LLVM-21.1.5-Linux-ARM64.tar.xz": "c9a1ee5d1a1698a8eb0abda1c1e44c812378aec32f89cc4fbbb41865237359a9",
710-
"LLVM-21.1.5-Linux-X64.tar.xz": "6279d78feeeb8e839a397f0bca7b1c0594972224d59525496416653d9b9c077f",
711-
"clang+llvm-21.1.5-x86_64-pc-windows-msvc.tar.xz": "eba824f1379fdb1a385f6dff8d19275a57348f621c752ce93b6d11256741e349",
709+
"clang+llvm-21.1.5-aarch64-pc-windows-msvc.tar.xz": "sha256:dcc7a6f9e3ff02f5b49b23e6f91abe2f9431972d72ab59f7b7d9f8b436ea1ca3",
710+
"clang+llvm-21.1.5-armv7a-linux-gnueabihf.tar.gz": "sha256:42a964c0ea68764ef8e222f5f979a400a803a912e5df273358652d4017ca3411",
711+
"clang+llvm-21.1.5-x86_64-pc-windows-msvc.tar.xz": "sha256:eba824f1379fdb1a385f6dff8d19275a57348f621c752ce93b6d11256741e349",
712+
"LLVM-21.1.5-Linux-ARM64.tar.xz": "sha256:c9a1ee5d1a1698a8eb0abda1c1e44c812378aec32f89cc4fbbb41865237359a9",
713+
"LLVM-21.1.5-Linux-X64.tar.xz": "sha256:6279d78feeeb8e839a397f0bca7b1c0594972224d59525496416653d9b9c077f",
712714

713715
# Refer to variable declaration on how to update!
714-
# Example update (without deleting): utils/llvm_checksums.sh -g -t /tmp/llvm -v 21.1.5
716+
# Example update (without download): utils/llvm_checksums.sh -D -g -t /tmp/llvm -v 21.1.5
715717
}
716718

717719
# Note: Unlike the user-specified llvm_mirror attribute, the URL prefixes in
@@ -779,6 +781,13 @@ def _full_url(url):
779781
return "file://" + url
780782
return url
781783

784+
def _normalize_and_check_sha256(sha256):
785+
if sha256:
786+
sha256 = sha256.removeprefix("sha256:")
787+
if len(sha256) != 64:
788+
return None, "Attribute sha256 needs exactly 64 hex characters."
789+
return sha256, None
790+
782791
def download_llvm(rctx):
783792
"""Download the LLVM distribution for the given context."""
784793
urls = []
@@ -793,6 +802,10 @@ def download_llvm(rctx):
793802
if not urls:
794803
urls, sha256, strip_prefix = _distribution_urls(rctx)
795804

805+
sha256, shaerr = _normalize_and_check_sha256(sha256)
806+
if shaerr:
807+
fail("ERROR: " + shaerr)
808+
796809
res = rctx.download_and_extract(
797810
[_full_url(url) for url in urls],
798811
sha256 = sha256,
@@ -1443,6 +1456,13 @@ def _distributions_test_writer_impl(ctx):
14431456
extra_llvm_distributions = extra_llvm_distributions,
14441457
parsed_llvm_version = version,
14451458
)
1459+
for basename, distribution in all_llvm_distributions.items():
1460+
_, shaerr = _normalize_and_check_sha256(distribution.sha256)
1461+
if shaerr:
1462+
output.append("err: {basename}: bad sha256: {shaerr}".format(
1463+
basename = basename,
1464+
shaerr = shaerr,
1465+
))
14461466
for arch in arch_list:
14471467
for os in os_list:
14481468
if version < MIN_VERSION:

utils/llvm_checksums.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ set -euo pipefail
1717

1818
use_github_host=0
1919
tmp_dir=
20+
download=1
2021

21-
while getopts "t:v:gh" opt; do
22+
while getopts "t:v:ghD" opt; do
2223
case "${opt}" in
2324
"t") tmp_dir="${OPTARG}" ;;
2425
"v") llvm_version="${OPTARG}" ;;
@@ -30,6 +31,7 @@ while getopts "t:v:gh" opt; do
3031
echo "-g - Use github to download releases."
3132
exit 2
3233
;;
34+
"D") download=0 ;;
3335
*)
3436
echo "invalid option: -${OPTARG}"
3537
exit 1
@@ -67,11 +69,21 @@ llvm_host() {
6769
github_host() {
6870
output_dir="${tmp_dir}/${llvm_version}"
6971
mkdir -p "${output_dir}"
72+
if ((download)); then
73+
echo ""
74+
echo "===="
75+
echo "Checksums for clang+llvm distributions are (${output_dir}):"
76+
echo " # ${llvm_version}"
77+
curl -s "https://api.github.com/repos/llvm/llvm-project/releases/tags/llvmorg-${llvm_version}" |
78+
tee ./releases.json |
79+
jq -r '.assets[]|select(any(.name; test("^(clang[+]llvm|LLVM)-.*tar.(xz|gz)$")))|" \""+(.browser_download_url|split("/")|.[-1]|sub("%2B";"+"))+"\": \""+.digest+"\","'
80+
exit 0
81+
fi
7082
(
7183
cd "${output_dir}"
7284
curl -s "https://api.github.com/repos/llvm/llvm-project/releases/tags/llvmorg-${llvm_version}" |
7385
tee ./releases.json |
74-
jq '.assets[]|select(any(.name; test("^(clang[+]llvm|LLVM)-.*tar.(xz|gz)$")))|.browser_download_url' |
86+
jq '.assets[]|select(any(.name .digest; test("^(clang[+]llvm|LLVM)-.*tar.(xz|gz)$")))|.browser_download_url' |
7587
tee ./filtered_urls.txt |
7688
xargs -n1 curl -L -O -C -
7789
)

0 commit comments

Comments
 (0)