Skip to content

Commit c145262

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

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@
415415

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

419420
- [Device Software](./sw/device/README.md)
420421
- [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)