Skip to content

Commit

Permalink
[doc] Add documentation for Bazel RISC-V toolchain
Browse files Browse the repository at this point in the history
Signed-off-by: James Wainwright <[email protected]>
  • Loading branch information
jwnrt committed Jan 10, 2025
1 parent 00d1e21 commit 4ee5ecb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@

- [Build Software](./sw/doc/build_software.md)
- [External dependencies](./third_party/README.md)
- [RISC-V toolchain](./toolchain/README.md)

- [Device Software](./sw/device/README.md)
- [Build & Test Rules](./rules/opentitan/README.md)
Expand Down
31 changes: 31 additions & 0 deletions toolchain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# OpenTitan RISC-V toolchain

This directory contains the Bazel configuration for OpenTitan's RISC-V
toolchain.

This LLVM toolchain comes from the [lowrisc-toolchains] repository. See
`third_party/lowrisc/BUILD.lowrisc_toolchain.bazel` for changing the toolchain
version.

[lowrisc-toolchains]: https://github.com/lowRISC/lowrisc-toolchains

## Configuration

There are four rules used to configure the toolchain:

1. `cc_toolchain`: groups flags, features, and tools into a toolchain.
2. `cc_tool_map`: assigns tools to actions.
3. `cc_args`: defines flags to add to tools based on actions.
3. `cc_feature`: allows `cc_args` flags to be conditionally enabled.

To add new flags to a tool in the toolchain, define a new `cc_args` target
and assign it to some actions (e.g. compiling C code, linking, etc.). Add the
new flags to `cc_toolchain.args`.

To make flags optional, define a new `cc_feature` for those `cc_args`. Features
can be enabled at the command line using `bazel --features=$feature_name`. Add
the flags to `cc_toolchain.known_features` and optionally to
`cc_toolchain.enabled_features`.

Bazel has three built-in features called `dbg`, `fastbuild`, and `opt` that can
be used to enable and disable flags at different optimization levels.

0 comments on commit 4ee5ecb

Please sign in to comment.