Skip to content

Commit ec562a7

Browse files
committed
[doc] Add documentation for Bazel RISC-V toolchain
Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
1 parent c236f1d commit ec562a7

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,9 @@
412412

413413
# Software
414414
- [Introduction](./sw/README.md)
415+
415416
- [Build Software](./sw/doc/build_software.md)
417+
- [RISC-V toolchain](./toolchain/README.md)
416418

417419
- [Device Software](./sw/device/README.md)
418420
- [Build & Test Rules](./rules/opentitan/README.md)

toolchain/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# OpenTitan RISC-V toolchain
2+
3+
This directory contains the Bazel configuration for OpenTitan's RISC-V
4+
toolchain.
5+
6+
This LLVM toolchain comes from the [lowrisc-toolchains] repository. See
7+
`third_party/lowrisc/BUILD.lowrisc_toolchain.bazel` for changing the toolchain
8+
version.
9+
10+
[lowrisc-toolchains]: https://github.com/lowRISC/lowrisc-toolchains
11+
12+
## Configuration
13+
14+
There are four rules used to configure the toolchain:
15+
16+
1. `cc_toolchain`: groups flags, features, and tools into a toolchain.
17+
2. `cc_tool_map`: assigns tools to actions.
18+
3. `cc_args`: defines flags to add to tools based on actions.
19+
3. `cc_feature`: allows `cc_args` flags to be conditionally enabled.
20+
21+
To add new flags to a tool in the toolchain, define a new `cc_args` target
22+
and assign it to some actions (e.g. compiling C code, linking, etc.). Add the
23+
new flags to `cc_toolchain.args`.
24+
25+
To make flags optional, define a new `cc_feature` for those `cc_args`. Features
26+
can be enabled at the command line using `bazel --features=$feature_name`. Add
27+
the flags to `cc_toolchain.known_features` and optionally to
28+
`cc_toolchain.enabled_features`.
29+
30+
Bazel has three built-in features called `dbg`, `fastbuild`, and `opt` that can
31+
be used to enable and disable flags at different optimization levels.

0 commit comments

Comments
 (0)