Skip to content

Improve error messages. #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions toolchain/internal/llvm_distributions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -947,19 +947,22 @@ def _find_llvm_basename_list(llvm_version, host_info):
def _find_llvm_basename_or_error(llvm_version, host_info):
basenames = _find_llvm_basename_list(llvm_version, host_info)
if len(basenames) > 1:
return None, "ERROR: Multiple configurations found [{basenames}].".format(
return None, "ERROR: Multiple configurations found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}: [{basenames}].".format(
llvm_version = llvm_version,
os = host_info.os,
dist_name = host_info.dist.name,
dist_version = host_info.dist.version,
arch = host_info.arch,
basenames = ", ".join(basenames),
)
if not basenames:
return None, "ERROR: No version selected"
# TODO(helly25): Enable better error message:
#"ERROR: No matching config could be found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}.".format(
# llvm_version = llvm_version,
# os = host_info.os,
# dist_name = host_info.dist.name,
# dist_version = host_info.dist.version,
# arch = host_info.arch,
#)
return None, "ERROR: No matching config could be found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}.".format(
llvm_version = llvm_version,
os = host_info.os,
dist_name = host_info.dist.name,
dist_version = host_info.dist.version,
arch = host_info.arch,
)

# Use the following for debugging:
# print("Found LLVM: " + basenames[0]) # buildifier: disable=print
Expand All @@ -977,7 +980,7 @@ def _distribution_urls(rctx):
basename = rctx.attr.distribution

if basename not in _llvm_distributions:
fail("Unknown LLVM release: %s\nPlease ensure file name is correct." % basename)
fail("ERROR: Unknown LLVM release: %s\nPlease ensure file name is correct." % basename)

urls = []
url_suffix = "{0}/{1}".format(llvm_version, basename).replace("+", "%2B")
Expand Down Expand Up @@ -1135,17 +1138,21 @@ def _write_distributions_impl(ctx):
_version_string(version),
host_info,
)
if not error:
if error:
if error.startswith("ERROR: No matching config could be found for version"):
# Simplify test output:
error = "ERROR: No version selected"
else:
if predicted.endswith(".exe"):
error = "ERROR: Windows .exe is not supported: " + predicted
elif predicted not in _llvm_distributions:
error = "ERROR: Unavailable prediction: " + predicted
elif len(basenames) == 0:
predicted = "ERROR: No version selected"
error = "ERROR: No version selected"
elif len(basenames) == 1:
predicted = basenames[0]
else:
predicted = "ERROR: Multiple selections"
error = "ERROR: Multiple selections"
if not error:
arch_found = [arch for arch in arch_list if arch in predicted]
if len(arch_found) == 1 and arch_found[0] != arch:
Expand Down