Skip to content

Commit 6a2ba86

Browse files
authored
Add support for riscv32-unknown-none-elf targets (#530)
This adds support for bare metal riscv32 targets that don't need a sysroot. I have an esp32 riscv board that I'm building for, and to set up an appropriate toolchain, `toolchains_llvm` needs to know about it.
1 parent 5d58ae5 commit 6a2ba86

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

toolchain/cc_toolchain_config.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ def cc_toolchain_config(
9797
"clang",
9898
"glibc_unknown",
9999
),
100+
"none-riscv32": (
101+
"clang-riscv32-none",
102+
"riscv32",
103+
"unknown",
104+
"clang",
105+
"unknown",
106+
"unknown",
107+
),
100108
"none-x86_64": (
101109
"clang-x86_64-none",
102110
"k8",

toolchain/internal/common.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ SUPPORTED_TARGETS = [
1818
("linux", "armv7"),
1919
("darwin", "x86_64"),
2020
("darwin", "aarch64"),
21+
("none", "riscv32"),
2122
("none", "wasm32"),
2223
("none", "wasm64"),
2324
("none", "x86_64"),
@@ -27,6 +28,7 @@ SUPPORTED_TARGETS = [
2728

2829
# These are targets that can build without a sysroot.
2930
SUPPORTED_NO_SYSROOT_TARGETS = [
31+
("none", "riscv32"),
3032
("none", "x86_64"),
3133
]
3234

toolchain/internal/configure.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def _cc_toolchain_str(
306306
if exec_os == target_os and exec_arch == target_arch:
307307
# For darwin -> darwin, we can use the macOS SDK path.
308308
sysroot_path = _default_sysroot_path(rctx, exec_os)
309-
elif target_pair in _supported_no_sysroot_targets:
309+
elif (target_os, target_arch) in _supported_no_sysroot_targets:
310310
sysroot_path = ""
311311
else:
312312
# We are trying to cross-compile without a sysroot, let's bail.
@@ -331,6 +331,7 @@ def _cc_toolchain_str(
331331
"linux-aarch64": "aarch64-unknown-linux-gnu",
332332
"linux-armv7": "armv7-unknown-linux-gnueabihf",
333333
"linux-x86_64": "x86_64-unknown-linux-gnu",
334+
"none-riscv32": "riscv32-unknown-none-elf",
334335
"none-x86_64": "x86_64-unknown-none",
335336
"wasm32": "wasm32-unknown-unknown",
336337
"wasm64": "wasm64-unknown-unknown",

0 commit comments

Comments
 (0)