From bcee12c384292865f64b9e2582f64616a99db660 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Mon, 16 Dec 2024 11:40:08 +0100 Subject: [PATCH] [quality] Make modid_check using the golden toolchain This aspect was still pointing to opentitantool directly instead of using the golden toolchain. This is not ideal because it causes bazel to build a second copy of opentitantool and it might cause issues. Signed-off-by: Amaury Pouly --- rules/quality.bzl | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/rules/quality.bzl b/rules/quality.bzl index 8f74314d3d961..3da4903b9f7f6 100644 --- a/rules/quality.bzl +++ b/rules/quality.bzl @@ -9,6 +9,7 @@ load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES", "C_COMPILE_ACTION_NAME") load("@bazel_skylib//lib:shell.bzl", "shell") load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain") load("//rules:rv.bzl", "rv_rule") +load("//rules/opentitan:toolchain.bzl", "LOCALTOOLS_TOOLCHAIN") def _ensure_tag(tags, *tag): for t in tag: @@ -397,6 +398,7 @@ def _modid_check_aspect_impl(target, ctx): Verify that a binary (ELF file) does not contain conflicting module IDs using opentitantool. """ + tc = ctx.toolchains[LOCALTOOLS_TOOLCHAIN] # If the target is //sw/device/lib/base:status, then it has module ID information, # this is the root of all the information. @@ -427,13 +429,15 @@ def _modid_check_aspect_impl(target, ctx): # printing anything if the test is successful but by default opentitantool prints # unnecessary information that pollutes the output. args = ctx.actions.args() - args.add_all([ctx.file._validator, generated_file]) + + # The opentitantool binary returns a FilesToRun provider. + args.add_all([tc.tools.opentitantool.executable.path, generated_file]) args.add_all(target.files) ctx.actions.run( executable = ctx.executable._modid_check, arguments = [args], - inputs = depset([ctx.file._validator] + target.files.to_list()), - tools = [], + inputs = target.files, + tools = [tc.tools.opentitantool], outputs = [generated_file], progress_message = "Checking module IDs for %{label}", ) @@ -450,26 +454,13 @@ modid_check_aspect = aspect( # types of dependencies to reach the binaries. attr_aspects = ["*"], attrs = { - # The rules to which we apply the aspect may not depend on opentitantool - # so make sure that we depend on it. Make sure that it is built for the - # execution platform since this aspect will be applied to targets built - # for the OT platform. - # NOTE: Make sure this is NOT named _opentitantool. Due to how bazel works - # https://github.com/bazelbuild/bazel/issues/18286, private aspect attributes - # are merged with the attributes of rule they run on, which can cause inexplicable - # errors message. - "_validator": attr.label( - default = "//sw/host/opentitantool", - allow_single_file = True, - executable = True, - cfg = "exec", - ), "_modid_check": attr.label( default = "//rules/scripts:modid_check", executable = True, cfg = "exec", ), }, + toolchains = [LOCALTOOLS_TOOLCHAIN], ) def _rustfmt_impl(ctx, check = False):