Skip to content

Commit af8209d

Browse files
committed
[bazel] Add cc_rules-based lowRISC toolchain
This uses the new rules-based toolchain feature of `rules_cc` to define the lowRISC toolchain with the same flags that the CRT toolchain had. There are two differences: 1. The CRT toolchain does not have the `guards` feature enabled by default, we enable it in `.bazelrc`. This new one is enabled automatically. 2. The CRT toolchain has `-Wpedantic` enabled by default, but we disable it in `.bazelrc`. This new one has it disabled by default. Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
1 parent 9466eb5 commit af8209d

File tree

3 files changed

+443
-0
lines changed

3 files changed

+443
-0
lines changed

rules/actions.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright lowRISC contributors (OpenTitan project).
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
OT_ACTION_OBJDUMP = "objdump"

third_party/lowrisc/BUILD.lowrisc_rv32imcb_toolchain.bazel

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,66 @@
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
44

5+
load("@bazel_skylib//rules/directory:directory.bzl", "directory")
6+
load("@bazel_skylib//rules/directory:subdirectory.bzl", "subdirectory")
7+
load("@rules_cc//cc/toolchains:tool.bzl", "cc_tool")
8+
9+
package(default_visibility = ["//visibility:public"])
10+
511
exports_files(glob(["**"]))
12+
13+
# Define certain binaries as `cc_tool`s so they can be used in a toolchain.
14+
# Each tool has access to all the other libraries and binaries in this repository
15+
# because some tools execute one another and access various libraries.
16+
[
17+
cc_tool(
18+
name = tool,
19+
src = ":bin/riscv32-unknown-elf-{}".format(tool),
20+
data = [":root"],
21+
)
22+
for tool in [
23+
"clang",
24+
"clang++",
25+
"ar",
26+
"objcopy",
27+
"objdump",
28+
"strip",
29+
]
30+
]
31+
32+
directory(
33+
name = "root",
34+
srcs = glob(["**/*"]),
35+
)
36+
37+
# System library include directories (for `-isystem`):
38+
39+
subdirectory(
40+
name = "lib-clang-include",
41+
parent = ":root",
42+
path = "lib/clang/16/include",
43+
)
44+
45+
subdirectory(
46+
name = "riscv32-unknown-elf-include",
47+
parent = ":root",
48+
path = "riscv32-unknown-elf/include",
49+
)
50+
51+
subdirectory(
52+
name = "cxx-include",
53+
parent = ":root",
54+
path = "riscv32-unknown-elf/include/c++/10.2.0",
55+
)
56+
57+
subdirectory(
58+
name = "cxx-backward",
59+
parent = ":root",
60+
path = "riscv32-unknown-elf/include/c++/10.2.0/backward",
61+
)
62+
63+
subdirectory(
64+
name = "cxx-riscv32-unknown-elf",
65+
parent = ":root",
66+
path = "riscv32-unknown-elf/include/c++/10.2.0/riscv32-unknown-elf",
67+
)

0 commit comments

Comments
 (0)