From 38010077e082ce1824e4aa0e3c91aac74f5d74c1 Mon Sep 17 00:00:00 2001 From: Wyatt Calandro Date: Wed, 1 Jul 2020 22:46:18 +0000 Subject: [PATCH 1/2] Download llvm tools for nightly builds after 2020-05-22 --- rust/repositories.bzl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index 1d8318fa46..68963134cc 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -431,6 +431,25 @@ def _load_rustc_dev_nightly(ctx, target_triple): return +def _load_llvm_tools(ctx, target_triple): + """Loads the llvm tools + + Args: + ctx: A repository_ctx. + target_triple: The rust-style target triple of the tool + """ + + load_arbitrary_tool( + ctx, + iso_date = ctx.attr.iso_date, + target_triple = target_triple, + tool_name = "llvm-tools", + tool_subdirectories = ["llvm-tools-preview"], + version = ctx.attr.version, + ) + + return + def _rust_toolchain_repository_impl(ctx): """The implementation of the rust toolchain repository rule.""" @@ -441,6 +460,10 @@ def _rust_toolchain_repository_impl(ctx): if ctx.attr.rustfmt_version: BUILD_components.append(_load_rustfmt(ctx)) + # Nightly Rust builds after 2020-05-22 need the llvm-tools gzip to get the libLLVM dylib + if ctx.attr.version == "nightly" and int(ctx.attr.iso_date.replace("-", "")) > 20200522: + _load_llvm_tools(ctx, ctx.attr.exec_triple) + for target_triple in [ctx.attr.exec_triple] + ctx.attr.extra_target_triples: BUILD_components.append(_load_rust_stdlib(ctx, target_triple)) From 4323f17cf30e19ee180c185615b9be89e6b29c30 Mon Sep 17 00:00:00 2001 From: Wyatt Calandro Date: Mon, 6 Jul 2020 10:32:52 -0700 Subject: [PATCH 2/2] Use string comparison Co-authored-by: Damien Martin-Guillerez --- rust/repositories.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index 68963134cc..89dc015ce5 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -461,7 +461,7 @@ def _rust_toolchain_repository_impl(ctx): BUILD_components.append(_load_rustfmt(ctx)) # Nightly Rust builds after 2020-05-22 need the llvm-tools gzip to get the libLLVM dylib - if ctx.attr.version == "nightly" and int(ctx.attr.iso_date.replace("-", "")) > 20200522: + if ctx.attr.version == "nightly" and ctx.attr.iso_date > "2020-05-22": _load_llvm_tools(ctx, ctx.attr.exec_triple) for target_triple in [ctx.attr.exec_triple] + ctx.attr.extra_target_triples: