Skip to content

Commit

Permalink
[bazel] Switch lowRISC toolchain from CRT to local version
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jwnrt committed Jan 9, 2025
1 parent d600816 commit 250c22d
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 25 deletions.
10 changes: 0 additions & 10 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ use_repo(
)

register_toolchains("//rules/opentitan:localtools")

register_toolchains("//toolchain:cc_toolchain_opentitan")
11 changes: 0 additions & 11 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion rules/rv.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions util/prep-bazel-airgapped-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 250c22d

Please sign in to comment.