From 250c22dd2f7cf1c6683f7aefe8e271d23d3292e4 Mon Sep 17 00:00:00 2001 From: James Wainwright Date: Wed, 8 Jan 2025 14:51:30 +0000 Subject: [PATCH] [bazel] Switch lowRISC toolchain from CRT to local version This removes the dependency on CRT and registers the new rules-based toolchain instead. Since `guards` is now enabled by default and `pedantic` is now disabled by default, we can remove those configurations from `.bazelrc`. The configuration to disable `guards` is still present. Without CRT, we also don't need to manually load the following repos into the airgapped environment: * `@python3_toolchains` * `@ninja_1.11.0_linux` * `@cmake-3.23.2-linux-x86_64` Signed-off-by: James Wainwright --- .bazelrc | 10 ---------- MODULE.bazel | 2 ++ WORKSPACE.bzlmod | 11 ----------- rules/rv.bzl | 2 +- util/prep-bazel-airgapped-build.sh | 3 --- 5 files changed, 3 insertions(+), 25 deletions(-) diff --git a/.bazelrc b/.bazelrc index 00fbb683bbb20..ec57c239c4ef2 100644 --- a/.bazelrc +++ b/.bazelrc @@ -14,16 +14,6 @@ build --conlyopt='-std=gnu11' # disassemblies when compilation mode is fastbuild. build --strip='never' -# Override default enablement of flags from @crt//common to control C compiler -# warnings. -build --features=-pedantic_warnings -build --host_features=-pedantic_warnings - -# Enable toolchain hardening features. -# `guards` adds `unimp` guard instructions after unconditional jumps. -build --features=guards -build --host_features=guards - # Use --config=disable_hardening to disable hardening to measure the # impact of the hardened sequences on code size. build:disable_hardening --features=-guards --copt=-DOT_DISABLE_HARDENING=1 diff --git a/MODULE.bazel b/MODULE.bazel index f9a222271fd99..761baab29827a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -143,3 +143,5 @@ use_repo( ) register_toolchains("//rules/opentitan:localtools") + +register_toolchains("//toolchain:cc_toolchain_opentitan") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index 0d90a1c97edfe..a670850ba99e8 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -6,14 +6,3 @@ # //third_party/README.md first. workspace(name = "lowrisc_opentitan") - -# CRT is the Compiler Repository Toolkit. It contains the configuration for -# the windows compiler. -load("//third_party/crt:repos.bzl", "crt_repos") -crt_repos() -load("@crt//:repos.bzl", "crt_repos") -crt_repos() -load("@crt//:deps.bzl", "crt_deps") -crt_deps() -load("@crt//config:registration.bzl", "crt_register_toolchains") -crt_register_toolchains(riscv32 = True) diff --git a/rules/rv.bzl b/rules/rv.bzl index 48368231fb30b..9ea767f5321b7 100644 --- a/rules/rv.bzl +++ b/rules/rv.bzl @@ -5,7 +5,7 @@ """Helpers for transitioning to the RISC-V target.""" OPENTITAN_CPU = "@platforms//cpu:riscv32" -OPENTITAN_PLATFORM = "@crt//platforms/riscv32:opentitan" +OPENTITAN_PLATFORM = "//toolchain:opentitan_platform" # This constant holds a dictionary of per-device dependencies which are used to # generate slightly different binaries for each hardware target, including two diff --git a/util/prep-bazel-airgapped-build.sh b/util/prep-bazel-airgapped-build.sh index 45e768322a049..a93905e9a225c 100755 --- a/util/prep-bazel-airgapped-build.sh +++ b/util/prep-bazel-airgapped-build.sh @@ -143,11 +143,8 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \ //... \ @lowrisc_rv32imcb_toolchain//... \ @local_config_platform//... \ - @python3_toolchains//... \ @riscv-compliance//... \ @rules_foreign_cc//toolchains/... \ - @ninja_1.11.0_linux//... \ - @cmake-3.23.2-linux-x86_64//... \ # We don't need all bitstreams in the cache, we just need the latest one so # that the cache is "initialized" and "offline" mode will work correctly. mkdir -p ${BAZEL_AIRGAPPED_DIR}/${BAZEL_BITSTREAMS_CACHEDIR}