Skip to content

Commit f64f6e0

Browse files
committed
Add aarch64 support
I would appreciate some hints on how to download the correct version of the toolchain depending on the host cpu architecture in `lowrisc_rv32imcb_repos`. I tried using `load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")` there as well but that led to the following problem: ``` ERROR: Failed to load Starlark extension '@local_config_platform//:constraints.bzl'. Cycle in the workspace file detected. This indicates that a repository is used prior to being defined. The following chain of repository dependencies lead to the missing definition. - @local_config_platform This could either mean you have to add the '@local_config_platform' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file. ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping ```
1 parent 7b0acb2 commit f64f6e0

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

bazelisk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ readonly release="v1.11.0"
2323
declare -A hashes=(
2424
# sha256sums for v1.11.0. Update this if you update the release.
2525
[linux-amd64]="231ec5ca8115e94c75a1f4fbada1a062b48822ca04f21f26e4cb1cd8973cd458"
26+
[linux-arm64]="f9119deb1eeb6d730ee8b2e1a14d09cb45638f0447df23144229c5b3b3bc2408"
2627
)
2728

2829
declare -A architectures=(
2930
# Map `uname -m -o` to bazelisk's precompiled binary target names.
3031
[x86_64 GNU/Linux]="linux-amd64"
32+
[aarch64 GNU/Linux]="linux-arm64"
3133
)
3234

3335
function os_arch() {

config/compiler.bzl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ load(
1010
"tool_path",
1111
)
1212
load("@rules_cc//cc:defs.bzl", "cc_toolchain")
13+
load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")
14+
15+
def _get_host_cpu():
16+
cpu_constraint = "@platforms//cpu:"
17+
for constraint in HOST_CONSTRAINTS:
18+
if constraint.startswith(cpu_constraint):
19+
return constraint[len(cpu_constraint):]
1320

1421
PARAM_DEFAULTS = {
15-
"host_system_name": "x86_64-unknown-linux-gnu",
22+
"host_system_name": _get_host_cpu() + "-unknown-linux-gnu",
1623
"target_system_name": "unknown",
1724
"target_libc": "unknown",
1825
"compiler": "unknown",
@@ -141,7 +148,7 @@ def setup(
141148
native.toolchain(
142149
name = "cc_toolchain_" + name,
143150
exec_compatible_with = [
144-
"@platforms//cpu:x86_64",
151+
"@platforms//cpu:" + _get_host_cpu(),
145152
],
146153
target_compatible_with = constraints,
147154
toolchain = ":" + name,

toolchains/lowrisc_rv32imcb/repository.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def lowrisc_rv32imcb_repos(local = None):
88
http_archive_or_local(
99
name = "lowrisc_rv32imcb_files",
1010
local = local,
11-
url = "https://github.com/lowRISC/lowrisc-toolchains/releases/download/20240923-1/lowrisc-toolchain-rv32imcb-20240923-1.tar.xz",
12-
sha256 = "aeea1983553f4c81c6409abcf0d6ca33b5ed4716b2b694e7ff030523cf13486a",
13-
strip_prefix = "lowrisc-toolchain-rv32imcb-20240923-1",
11+
url = "https://github.com/troibe/lowrisc-toolchains/releases/download/20250225-1/lowrisc-toolchain-rv32imcb-aarch64-20250225-1.tar.xz",
12+
sha256 = "1b5df51abe85fb6d3cad24c62082046ab02788ef15e491040b680fcaa35a29ec",
13+
strip_prefix = "lowrisc-toolchain-rv32imcb-aarch64-20250225-1",
1414
build_file = Label("//toolchains:BUILD.export_all.bazel"),
1515
)

0 commit comments

Comments
 (0)