From 4b01c7a390b9a18e14c58bcb64a7881fbb796f32 Mon Sep 17 00:00:00 2001 From: Miguel Young de la Sota Date: Thu, 21 Apr 2022 17:25:52 -0400 Subject: [PATCH] [bazel] Bump the bazel version to fix a UI bug See https://github.com/bazelbuild/bazel/issues/13985 Signed-off-by: Miguel Young de la Sota --- .bazelversion | 2 +- rules/bugfix.bzl | 26 -------------------------- rules/cc_side_outputs.bzl | 8 ++++---- rules/opentitan.bzl | 8 +++----- rules/otbn.bzl | 6 +++--- 5 files changed, 11 insertions(+), 39 deletions(-) delete mode 100644 rules/bugfix.bzl diff --git a/.bazelversion b/.bazelversion index 6aba2b245a847..ac14c3dfaa865 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -4.2.0 +5.1.1 diff --git a/rules/bugfix.bzl b/rules/bugfix.bzl deleted file mode 100644 index 1c2abd7080eb0..0000000000000 --- a/rules/bugfix.bzl +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright lowRISC contributors. -# Licensed under the Apache License, Version 2.0, see LICENSE for details. -# SPDX-License-Identifier: Apache-2.0 - -def find_cc_toolchain(ctx): - """ - Returns the current `CcToolchainInfo`. - - Args: - ctx: The rule context for which to find a toolchain. - - Returns: - A CcToolchainInfo. - """ - - # Check the incompatible flag for toolchain resolution. - if hasattr(cc_common, "is_cc_toolchain_resolution_enabled_do_not_use") and cc_common.is_cc_toolchain_resolution_enabled_do_not_use(ctx = ctx): - if "@rules_cc//cc:toolchain_type" in ctx.toolchains: - return ctx.toolchains["@rules_cc//cc:toolchain_type"] - - # Fall back to the legacy implicit attribute lookup. - elif hasattr(ctx.attr, "_cc_toolchain"): - return ctx.attr._cc_toolchain[cc_common.CcToolchainInfo] - - # We didn't find anything. - fail("In order to use find_cc_toolchain, your rule has to depend on C++ toolchain. See find_cc_toolchain.bzl docs for details.") diff --git a/rules/cc_side_outputs.bzl b/rules/cc_side_outputs.bzl index 4512fb4f8f5c2..62016ec7a3faf 100644 --- a/rules/cc_side_outputs.bzl +++ b/rules/cc_side_outputs.bzl @@ -5,7 +5,7 @@ """Aspects and rules for making cc_* libraries emit more outputs.""" load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES", "C_COMPILE_ACTION_NAME") -load("//rules:bugfix.bzl", "find_cc_toolchain") +load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain") load("//rules:rv.bzl", "rv_rule") CcSideProductInfo = provider(fields = ["files"]) @@ -63,7 +63,7 @@ def _cc_compile_different_output(name, target, ctx, extension, flags, process_al ) cc_compile_ctx = cc_info.compilation_context - cc_toolchain = find_cc_toolchain(ctx) + cc_toolchain = find_cc_toolchain(ctx).cc feature_configuration = cc_common.configure_features( ctx = ctx, cc_toolchain = cc_toolchain, @@ -226,7 +226,7 @@ cc_asm_aspect = aspect( ) def _cc_llvm_aspect_impl(target, ctx): - cc_toolchain = find_cc_toolchain(ctx) + cc_toolchain = find_cc_toolchain(ctx).cc if cc_toolchain.compiler.find("clang") == -1: return CcSideProductInfo(files = depset()) return _cc_compile_different_output("LLVMOutput", target, ctx, "ll", ["-S", "-emit-llvm"]) @@ -273,7 +273,7 @@ def _cc_relink_with_linkmap_aspect_impl(target, ctx): output_file = ctx.actions.declare_file(target.label.name + ".ldmap") - cc_toolchain = find_cc_toolchain(ctx) + cc_toolchain = find_cc_toolchain(ctx).cc feature_configuration = cc_common.configure_features( ctx = ctx, cc_toolchain = cc_toolchain, diff --git a/rules/opentitan.bzl b/rules/opentitan.bzl index 2f7ab8585ff68..a616ce9a6a3e7 100644 --- a/rules/opentitan.bzl +++ b/rules/opentitan.bzl @@ -2,9 +2,7 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 -# TODO(drewmacrae) this should be in rules_cc -# pending resolution of https://github.com/bazelbuild/rules_cc/issues/75 -load("//rules:bugfix.bzl", "find_cc_toolchain") +load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain") load( "//rules:cc_side_outputs.bzl", "rv_asm", @@ -43,7 +41,7 @@ PER_DEVICE_DEPS = { } def _obj_transform_impl(ctx): - cc_toolchain = find_cc_toolchain(ctx) + cc_toolchain = find_cc_toolchain(ctx).cc outputs = [] for src in ctx.files.srcs: binary = ctx.actions.declare_file("{}.{}".format(src.basename, ctx.attr.suffix)) @@ -125,7 +123,7 @@ sign_bin = rv_rule( ) def _elf_to_disassembly_impl(ctx): - cc_toolchain = find_cc_toolchain(ctx) + cc_toolchain = find_cc_toolchain(ctx).cc outputs = [] for src in ctx.files.srcs: disassembly = ctx.actions.declare_file("{}.elf.s".format(src.basename)) diff --git a/rules/otbn.bzl b/rules/otbn.bzl index 3491b2adfa57e..72eea35ba1ed7 100644 --- a/rules/otbn.bzl +++ b/rules/otbn.bzl @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 load("//rules:rv.bzl", "rv_rule") -load("//rules:bugfix.bzl", "find_cc_toolchain") +load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain") def _get_assembler(cc_toolchain): """Find the path to riscv-unknown-elf-as.""" @@ -20,7 +20,7 @@ def _otbn_assemble_sources(ctx): producing a corresponding object file. Returns a list of all object files that will be generated by these actions. """ - cc_toolchain = find_cc_toolchain(ctx) + cc_toolchain = find_cc_toolchain(ctx).cc assembler = _get_assembler(cc_toolchain) objs = [] @@ -77,7 +77,7 @@ def _otbn_binary(ctx): We achieve by having `otbn_build.py` emit a conventional RV32I library that other rules can depend on in their `deps`. """ - cc_toolchain = find_cc_toolchain(ctx) + cc_toolchain = find_cc_toolchain(ctx).cc assembler = _get_assembler(cc_toolchain) # Run the otbn assembler on source files to produce object (.o) files.