Skip to content

Commit 5bad824

Browse files
authored
Add avr-none triple support (bazelbuild#3950)
**Problem**: The `triple()` parser in `rust/platform/triple.bzl` fails on `avr-none` because it only has two components separated by `-`, which does not match the expected `arch-vendor-system[-abi]` format. The function hits the `fail()` guard at the bottom that requires at least 3 components. **Solution**: Add a special case for `avr-none` alongside the existing ones for `wasm32v1-none` and the ARM Thumb targets. **Additional context**: `avr-none` is the standard Rust target triple for AVR bare-metal targets (ATtiny, ATmega, AVR-DA series, etc.). Without this fix, any project using rules_rust with an AVR toolchain (even a custom one) that sets the target triple to `avr-none` will fail during toolchain resolution.
1 parent 2bad175 commit 5bad824

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

rust/platform/triple.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def triple(triple):
4040
abi = None,
4141
str = triple,
4242
)
43+
elif triple == "avr-none":
44+
return struct(
45+
arch = "avr",
46+
vendor = None,
47+
system = "none",
48+
abi = None,
49+
str = triple,
50+
)
4351
elif triple in ("aarch64-fuchsia", "x86_64-fuchsia"):
4452
return struct(
4553
arch = triple.split("-")[0],

test/unit/platform_triple/platform_triple_test.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ def _construct_known_triples_test_impl(ctx):
144144
# WebAssembly MVP target
145145
_assert_parts(env, triple("wasm32v1-none"), "wasm32", "v1", "none", None)
146146

147+
# AVR bare-metal target
148+
_assert_parts(env, triple("avr-none"), "avr", None, "none", None)
149+
147150
_assert_parts(env, triple("x86_64-fuchsia"), "x86_64", "unknown", "fuchsia", None)
148151
_assert_parts(env, triple("x86_64-apple-ios-macabi"), "x86_64", "apple", "ios", "macabi")
149152

0 commit comments

Comments
 (0)