Skip to content

Commit 16d23f4

Browse files
committed
Find all distros.
Drop release_name.bzl.
1 parent 74d7730 commit 16d23f4

File tree

3 files changed

+199
-321
lines changed

3 files changed

+199
-321
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.
@@ -737,7 +736,14 @@ def _get_llvm_version(rctx):
737736
)
738737
return llvm_version
739738

740-
_UBUNTU_NAMES = ["arch", "linuxmint", "manjaro", "nixos", "pop", "ubuntu"]
739+
_UBUNTU_NAMES = [
740+
"arch",
741+
"linuxmint",
742+
"manjaro",
743+
"nixos",
744+
"pop",
745+
"ubuntu",
746+
]
741747

742748
_UBUNTU_VERSIONS = [
743749
"linux-ubuntu-20.04",
@@ -769,7 +775,6 @@ def _dist_to_os_names(dist, default_os_names = []):
769775
"linux-sles11.3",
770776
"linux-sles",
771777
"unknown-linux-gnu-rhel86",
772-
"linux-gnu-ubuntu-24.04",
773778
"linux-gnu-ubuntu-22.04",
774779
"linux-gnu-ubuntu-20.04",
775780
"linux-gnu-ubuntu-18.04",
@@ -791,6 +796,10 @@ def _dist_to_os_names(dist, default_os_names = []):
791796
return ["linux-gnueabihf", "linux-gnu"]
792797
if dist.name in ["rhel", "ol", "almalinux"]:
793798
return ["linux-rhel-", "linux-gnu-rhel-"]
799+
if dist.name == "debian":
800+
return [
801+
"linux-gnu-debian8",
802+
] + _UBUNTU_VERSIONS
794803
if dist.name in _UBUNTU_NAMES:
795804
return [
796805
"linux-gnu-ubuntu-" + dist.version,
@@ -951,57 +960,29 @@ def _find_llvm_basename_list(llvm_version, arch, os, dist):
951960
else:
952961
fail("ERROR: Unknown OS: {os}".format(os = os))
953962

954-
def _find_llvm_basename_maybe_fail(llvm_version, arch, os, dist, should_fail):
963+
def _find_llvm_basename_maybe_fail(llvm_version, arch, os, dist):
955964
basenames = _find_llvm_basename_list(llvm_version, arch, os, dist)
956965
if len(basenames) > 1:
957-
if fail:
958-
fail("ERROR: Multiple configurations found [{basenames}].".format(
959-
basenames = ", ".join(basenames),
960-
))
961-
return None
966+
fail("ERROR: Multiple configurations found [{basenames}].".format(
967+
basenames = ", ".join(basenames),
968+
))
962969
if not basenames:
963-
if should_fail:
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-
))
971-
return None
970+
fail("ERROR: No matching config could be found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}.".format(
971+
llvm_version = llvm_version,
972+
os = os,
973+
dist_name = dist.name,
974+
dist_version = dist.version,
975+
arch = arch,
976+
))
972977

973978
# Use the following for debugging:
974979
# print("Found LLVM: " + basenames[0]) # buildifier: disable=print
975980
return basenames[0]
976981

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

1006987
def _distribution_urls(rctx):
1007988
"""Return LLVM `urls`, `shha256` and `strip_prefix` for the given context."""
@@ -1079,8 +1060,6 @@ def _write_distributions_impl(ctx):
10791060
dist_dict_list = {
10801061
"linux": [
10811062
# struct(name = "ibm-aix", version = "7.2"), unreachable
1082-
# struct(name = "linux-gnu-debian", version = "8"), unreachable
1083-
# struct(name = "linux-gnu-rhel", version = "8.4"), unreachable
10841063
# keep sorted
10851064
struct(name = "amzn", version = ANY_VER),
10861065
struct(name = "arch", version = ANY_VER),

0 commit comments

Comments
 (0)