Skip to content

Commit b165f53

Browse files
committed
[bazel] Import lowRISC toolchain repo directly
Previously we were accessing the lowRISC toolchain indirectly via CRT, but this isn't possible with Bzlmod. We need to pull the repo in directly. Signed-off-by: James Wainwright <[email protected]> (cherry picked from commit bdc9c37)
1 parent 1f3c981 commit b165f53

File tree

9 files changed

+68
-10
lines changed

9 files changed

+68
-10
lines changed

MODULE.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ use_repo(hwtrust, "hwtrust")
121121
qemu = use_extension("//third_party/qemu:extensions.bzl", "qemu")
122122
use_repo(qemu, "qemu_opentitan")
123123

124+
lowrisc_rv32imcb_toolchain = use_extension("//third_party/lowrisc:extensions.bzl", "lowrisc_rv32imcb_toolchain")
125+
use_repo(lowrisc_rv32imcb_toolchain, "lowrisc_rv32imcb_toolchain")
126+
124127
# Extension for linking in externally managed test and provisioning customizations
125128
# for both secure/non-secure manufacturer domains.
126129
hooks = use_extension("//rules:extensions.bzl", "hooks")

MODULE.bazel.lock

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hw/ip/otbn/dv/uvm/get-toolchain-paths.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ if [[ -n ${BAZEL_CACHE} ]]; then
1313
${BAZEL_CMD} fetch \
1414
--distdir="${BAZEL_DISTDIR}" \
1515
--repository_cache="${BAZEL_CACHE}" \
16-
@lowrisc_rv32imcb_files//...
16+
@lowrisc_rv32imcb_toolchain//...
1717
else
1818
BAZEL_CMD="./bazelisk.sh"
19-
${BAZEL_CMD} fetch @lowrisc_rv32imcb_files//...
19+
${BAZEL_CMD} fetch @lowrisc_rv32imcb_toolchain//...
2020
fi
2121

2222
# Set environment variables for the RV32 linker and assembler.
2323
RV32_TOOL_LD=$(${BAZEL_CMD} query \
24-
'deps(@lowrisc_rv32imcb_files//:bin/riscv32-unknown-elf-ld)' \
24+
'deps(@lowrisc_rv32imcb_toolchain//:bin/riscv32-unknown-elf-ld)' \
2525
--output location | cut -f1 -d:)
2626
RV32_TOOL_AS=$(${BAZEL_CMD} query \
27-
'deps(@lowrisc_rv32imcb_files//:bin/riscv32-unknown-elf-as)' \
27+
'deps(@lowrisc_rv32imcb_toolchain//:bin/riscv32-unknown-elf-as)' \
2828
--output location | cut -f1 -d:)
2929
export RV32_TOOL_LD
3030
export RV32_TOOL_AS

rules/certificates.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ certificate_codegen = rule(
7171
attrs = {
7272
"template": attr.label(allow_single_file = True, doc = "path to the hjson template file"),
7373
"clang_format": attr.label(
74-
default = "@lowrisc_rv32imcb_files//:bin/clang-format",
74+
default = "@lowrisc_rv32imcb_toolchain//:bin/clang-format",
7575
allow_single_file = True,
7676
cfg = "host",
7777
executable = True,

rules/quality.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ clang_format_attrs = {
6363
doc = "Command to execute to display diffs",
6464
),
6565
"clang_format": attr.label(
66-
default = "@lowrisc_rv32imcb_files//:bin/clang-format",
66+
default = "@lowrisc_rv32imcb_toolchain//:bin/clang-format",
6767
allow_single_file = True,
6868
cfg = "host",
6969
executable = True,
@@ -191,7 +191,7 @@ def _cc_aspect_impl(target, ctx, action_callback):
191191

192192
# To see which checks clang-tidy knows about, run this command:
193193
#
194-
# ./bazelisk.sh run @lowrisc_rv32imcb_files//:bin/clang-tidy -- --checks='*' --list-checks
194+
# ./bazelisk.sh run @lowrisc_rv32imcb_toolchain//:bin/clang-tidy -- --checks='*' --list-checks
195195
_CLANG_TIDY_CHECKS = [
196196
"clang-analyzer-core.*",
197197
# Disable advice to replace `memcpy` with `mempcy_s`.
@@ -264,7 +264,7 @@ def _make_clang_tidy_aspect(enable_fix):
264264
executable = True,
265265
),
266266
"_clang_tidy": attr.label(
267-
default = "@lowrisc_rv32imcb_files//:bin/clang-tidy",
267+
default = "@lowrisc_rv32imcb_toolchain//:bin/clang-tidy",
268268
allow_single_file = True,
269269
cfg = "host",
270270
executable = True,

third_party/lowrisc/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
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
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+
exports_files(glob(["**"]))

third_party/lowrisc/extensions.bzl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
6+
7+
def _lowrisc_repos():
8+
VERSION = "20240923-1"
9+
http_archive(
10+
name = "lowrisc_rv32imcb_toolchain",
11+
url = "https://github.com/lowRISC/lowrisc-toolchains/releases/download/{v}/lowrisc-toolchain-rv32imcb-{v}.tar.xz".format(v = VERSION),
12+
sha256 = "aeea1983553f4c81c6409abcf0d6ca33b5ed4716b2b694e7ff030523cf13486a",
13+
strip_prefix = "lowrisc-toolchain-rv32imcb-{}".format(VERSION),
14+
build_file = ":BUILD.lowrisc_rv32imcb_toolchain.bazel",
15+
)
16+
17+
lowrisc_rv32imcb_toolchain = module_extension(
18+
implementation = lambda _: _lowrisc_repos(),
19+
)

util/prep-bazel-airgapped-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \
142142
${BAZELISK} fetch \
143143
--repository_cache=${BAZEL_AIRGAPPED_DIR}/${BAZEL_CACHEDIR} \
144144
//... \
145-
@lowrisc_rv32imcb_files//... \
145+
@lowrisc_rv32imcb_toolchain//... \
146146
@local_config_platform//... \
147147
@python3_toolchains//... \
148148
@riscv-compliance//...

0 commit comments

Comments
 (0)