Skip to content

Commit 655e310

Browse files
committed
Find all distros.
Drop release_name.bzl.
1 parent 27493bc commit 655e310

File tree

4 files changed

+208
-322
lines changed

4 files changed

+208
-322
lines changed

toolchain/internal/llvm_distributions.bzl

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ load(
1919
_exec_os_arch_dict_value = "exec_os_arch_dict_value",
2020
_host_info = "host_info",
2121
)
22-
load("//toolchain/internal:release_name.bzl", _llvm_release_name_context = "llvm_release_name_context")
2322

2423
# If a new LLVM version is missing from this list, please add the shasums here
2524
# and the new version in toolchain/internal/llvm_distributions.golden.txt.
@@ -731,7 +730,14 @@ def _get_llvm_version(rctx):
731730
)
732731
return llvm_version
733732

734-
_UBUNTU_NAMES = ["arch", "linuxmint", "manjaro", "nixos", "pop", "ubuntu"]
733+
_UBUNTU_NAMES = [
734+
"arch",
735+
"linuxmint",
736+
"manjaro",
737+
"nixos",
738+
"pop",
739+
"ubuntu",
740+
]
735741

736742
_UBUNTU_VERSIONS = [
737743
"linux-ubuntu-20.04",
@@ -763,7 +769,6 @@ def _dist_to_os_names(dist, default_os_names = []):
763769
"linux-sles11.3",
764770
"linux-sles",
765771
"unknown-linux-gnu-rhel86",
766-
"linux-gnu-ubuntu-24.04",
767772
"linux-gnu-ubuntu-22.04",
768773
"linux-gnu-ubuntu-20.04",
769774
"linux-gnu-ubuntu-18.04",
@@ -785,6 +790,10 @@ def _dist_to_os_names(dist, default_os_names = []):
785790
return ["linux-gnueabihf", "linux-gnu"]
786791
if dist.name in ["rhel", "ol", "almalinux"]:
787792
return ["linux-rhel-", "linux-gnu-rhel-"]
793+
if dist.name == "debian":
794+
return [
795+
"linux-gnu-debian8",
796+
] + _UBUNTU_VERSIONS
788797
if dist.name in _UBUNTU_NAMES:
789798
return [
790799
"linux-gnu-ubuntu-" + dist.version,
@@ -945,57 +954,29 @@ def _find_llvm_basename_list(llvm_version, arch, os, dist):
945954
else:
946955
fail("ERROR: Unknown OS: {os}".format(os = os))
947956

948-
def _find_llvm_basename_maybe_fail(llvm_version, arch, os, dist, should_fail):
957+
def _find_llvm_basename_maybe_fail(llvm_version, arch, os, dist):
949958
basenames = _find_llvm_basename_list(llvm_version, arch, os, dist)
950959
if len(basenames) > 1:
951-
if fail:
952-
fail("ERROR: Multiple configurations found [{basenames}].".format(
953-
basenames = ", ".join(basenames),
954-
))
955-
return None
960+
fail("ERROR: Multiple configurations found [{basenames}].".format(
961+
basenames = ", ".join(basenames),
962+
))
956963
if not basenames:
957-
if should_fail:
958-
fail("ERROR: No matching config could be found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}.".format(
959-
llvm_version = llvm_version,
960-
os = os,
961-
dist_name = dist.name,
962-
dist_version = dist.version,
963-
arch = arch,
964-
))
965-
return None
964+
fail("ERROR: No matching config could be found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}.".format(
965+
llvm_version = llvm_version,
966+
os = os,
967+
dist_name = dist.name,
968+
dist_version = dist.version,
969+
arch = arch,
970+
))
966971

967972
# Use the following for debugging:
968973
# print("Found LLVM: " + basenames[0]) # buildifier: disable=print
969974
return basenames[0]
970975

971-
def _major_llvm_version(llvm_version):
972-
"""Return the major version given `<major>['.' <minor> [ '.' <mini> [.*]]]."""
973-
return int(llvm_version.split(".")[0])
974-
975-
def _host_can_be_found(major_llvm_version, host_info):
976-
"""Return whether the basename can be found or needs to be predicted."""
977-
if major_llvm_version >= 19:
978-
return True
979-
if host_info.os in ["darwin", "windows"]:
980-
return True
981-
if _dist_to_os_names(host_info.dist, []):
982-
return True
983-
if host_info.arch in ["aarch64", "armv7a", "mips", "mipsel"]:
984-
return True
985-
986-
return False
987-
988976
def _llvm_release_name(rctx, llvm_version):
989-
"""Try to find the distribution in the configured list. Otherwise predict version name by input.
990-
991-
For versions 19+ or we os==darwin fail if the distribution cannot be found automatically."""
992-
major_llvm_version = _major_llvm_version(llvm_version)
977+
"""Try to find the distribution in the configured list. Otherwise predict version name by input."""
993978
host_info = _host_info(rctx)
994-
should_fail = _host_can_be_found(major_llvm_version, host_info)
995-
basename = _find_llvm_basename_maybe_fail(llvm_version, host_info.arch, host_info.os, host_info.dist, should_fail)
996-
if basename:
997-
return basename
998-
return _llvm_release_name_context(rctx, llvm_version)
979+
return _find_llvm_basename_maybe_fail(llvm_version, host_info.arch, host_info.os, host_info.dist)
999980

1000981
def _distribution_urls(rctx):
1001982
"""Return LLVM `urls`, `shha256` and `strip_prefix` for the given context."""
@@ -1073,8 +1054,6 @@ def _write_distributions_impl(ctx):
10731054
dist_dict_list = {
10741055
"linux": [
10751056
# struct(name = "ibm-aix", version = "7.2"), unreachable
1076-
# struct(name = "linux-gnu-debian", version = "8"), unreachable
1077-
# struct(name = "linux-gnu-rhel", version = "8.4"), unreachable
10781057
# keep sorted
10791058
struct(name = "amzn", version = ANY_VER),
10801059
struct(name = "arch", version = ANY_VER),

toolchain/internal/llvm_distributions.golden.out.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ version: 20.1.1
6363
version: 20.1.2
6464
version: 20.1.3
6565
del: clang+llvm-6.0.0-i686-linux-gnu-Fedora27.tar.xz
66-
del: clang+llvm-6.0.0-x86_64-linux-gnu-debian8.tar.xz
6766
del: clang+llvm-9.0.0-sparcv9-sun-solaris2.11.tar.xz
6867
del: clang+llvm-9.0.0-x86_64-pc-linux-gnu.tar.xz
6968
del: clang+llvm-10.0.0-sparcv9-sun-solaris2.11.tar.xz
@@ -118,3 +117,12 @@ del: clang+llvm-19.1.0-x86_64-pc-windows-msvc.tar.xz
118117
del: clang+llvm-19.1.1-x86_64-pc-windows-msvc.tar.xz
119118
del: clang+llvm-19.1.2-x86_64-pc-windows-msvc.tar.xz
120119
del: clang+llvm-19.1.3-x86_64-pc-windows-msvc.tar.xz
120+
dup: 15.0.2-x86_64-linux-debian-0 -> 2
121+
: clang+llvm-15.0.2-x86_64-unknown-linux-gnu-rhel86.tar.xz
122+
: clang+llvm-15.0.2-x86_64-unknown-linux-gnu-sles15.tar.xz
123+
dup: 15.0.2-x86_64-linux-debian-8 -> 2
124+
: clang+llvm-15.0.2-x86_64-unknown-linux-gnu-rhel86.tar.xz
125+
: clang+llvm-15.0.2-x86_64-unknown-linux-gnu-sles15.tar.xz
126+
dup: 15.0.2-x86_64-linux-debian-9 -> 2
127+
: clang+llvm-15.0.2-x86_64-unknown-linux-gnu-rhel86.tar.xz
128+
: clang+llvm-15.0.2-x86_64-unknown-linux-gnu-sles15.tar.xz

0 commit comments

Comments
 (0)