Skip to content

Commit 9a919d8

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 <james.wainwright@lowrisc.org>
1 parent 7780c6b commit 9a919d8

9 files changed

+75
-17
lines changed

MODULE.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ use_repo(open_dice, "open-dice")
114114
hyperdebug = use_extension("//third_party/hyperdebug:extensions.bzl", "hyperdebug")
115115
use_repo(hyperdebug, "hyperdebug_firmware")
116116

117+
lowrisc_toolchain = use_extension("//third_party/lowrisc:extensions.bzl", "lowrisc_toolchain")
118+
use_repo(lowrisc_toolchain, "lowrisc_toolchain")
119+
117120
# Extension for linking in externally managed test and provisioning customizations
118121
# for both secure/non-secure manufacturer domains.
119122
hooks = use_extension("//rules:extensions.bzl", "hooks")

MODULE.bazel.lock

Lines changed: 36 additions & 8 deletions
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_toolchain//...
1717
else
1818
BAZEL_CMD="./bazelisk.sh"
19-
${BAZEL_CMD} fetch @lowrisc_rv32imcb_files//...
19+
${BAZEL_CMD} fetch @lowrisc_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_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_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_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
@@ -64,7 +64,7 @@ clang_format_attrs = {
6464
doc = "Command to execute to display diffs",
6565
),
6666
"clang_format": attr.label(
67-
default = "@lowrisc_rv32imcb_files//:bin/clang-format",
67+
default = "@lowrisc_toolchain//:bin/clang-format",
6868
allow_single_file = True,
6969
cfg = "host",
7070
executable = True,
@@ -192,7 +192,7 @@ def _cc_aspect_impl(target, ctx, action_callback):
192192

193193
# To see which checks clang-tidy knows about, run this command:
194194
#
195-
# ./bazelisk.sh run @lowrisc_rv32imcb_files//:bin/clang-tidy -- --checks='*' --list-checks
195+
# ./bazelisk.sh run @lowrisc_toolchain//:bin/clang-tidy -- --checks='*' --list-checks
196196
_CLANG_TIDY_CHECKS = [
197197
"clang-analyzer-core.*",
198198
# Disable advice to replace `memcpy` with `mempcy_s`.
@@ -265,7 +265,7 @@ def _make_clang_tidy_aspect(enable_fix):
265265
executable = True,
266266
),
267267
"_clang_tidy": attr.label(
268-
default = "@lowrisc_rv32imcb_files//:bin/clang-tidy",
268+
default = "@lowrisc_toolchain//:bin/clang-tidy",
269269
allow_single_file = True,
270270
cfg = "host",
271271
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_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_toolchain.bazel",
15+
)
16+
17+
lowrisc_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
@@ -141,7 +141,7 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \
141141
${BAZELISK} fetch \
142142
--repository_cache=${BAZEL_AIRGAPPED_DIR}/${BAZEL_CACHEDIR} \
143143
//... \
144-
@lowrisc_rv32imcb_files//... \
144+
@lowrisc_toolchain//... \
145145
@local_config_platform//... \
146146
@python3_toolchains//... \
147147
@riscv-compliance//... \

0 commit comments

Comments
 (0)