Skip to content

Commit 9398da3

Browse files
committed
docs: add complete patch for rules_rust wasip2 support
- Include both triple.bzl and triple_mappings.bzl changes - Add system constraint mappings for wasip1/wasip2/wasip3 - Update documentation with complete patch instructions - Fixes 'System wasip2 is not supported' error in CI
1 parent f9d80b6 commit 9398da3

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

PATCH_README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ This repository uses a fork of rules_rust with minimal patches to support WASI t
44

55
## What's Patched
66

7-
**File**: `rust/platform/triple.bzl`
8-
**Changes**: Added support for 2-component WASI target triples
7+
**Files**:
8+
- `rust/platform/triple.bzl` - Added support for 2-component WASI target triples
9+
- `rust/platform/triple_mappings.bzl` - Added system constraints for wasip1/wasip2/wasip3
910

1011
### The Problem
1112
rules_rust expects target triples to have 3+ components (e.g., `x86_64-unknown-linux-gnu`), but WASI targets use 2-component format:
@@ -26,14 +27,14 @@ Convert 2-component WASI targets to standard 3-component format:
2627
cd rules_rust
2728
```
2829

29-
2. Apply the patch:
30+
2. Apply the complete patch:
3031
```bash
31-
git apply wasip2-support.patch
32+
git apply wasip2-complete.patch
3233
```
3334

3435
3. Commit and push:
3536
```bash
36-
git add rust/platform/triple.bzl
37+
git add rust/platform/triple.bzl rust/platform/triple_mappings.bzl
3738
git commit -m "feat: add support for wasm32-wasip2 target triples
3839
3940
- Handle 2-component WASI target triples in triple.bzl

wasip2-complete.patch

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
diff --git a/rust/platform/triple.bzl b/rust/platform/triple.bzl
2+
index 1234567..abcdefg 100644
3+
--- a/rust/platform/triple.bzl
4+
+++ b/rust/platform/triple.bzl
5+
@@ -42,6 +42,17 @@ def triple_from_string(target_triple):
6+
)
7+
8+
component_parts = triple.split("-")
9+
+
10+
+ # Special handling for WASI targets with 2 components
11+
+ if len(component_parts) == 2 and component_parts[0] == "wasm32":
12+
+ if component_parts[1] == "wasip1":
13+
+ # Treat wasm32-wasip1 as wasm32-unknown-wasi
14+
+ component_parts = ["wasm32", "unknown", "wasi"]
15+
+ elif component_parts[1] == "wasip2":
16+
+ # Treat wasm32-wasip2 as wasm32-unknown-wasi
17+
+ component_parts = ["wasm32", "unknown", "wasi"]
18+
+ elif component_parts[1] == "wasip3":
19+
+ # Future support for wasm32-wasip3
20+
+ component_parts = ["wasm32", "unknown", "wasi"]
21+
+
22+
if len(component_parts) < 3:
23+
fail("Expected target triple to contain at least three sections separated by '-'")
24+
diff --git a/rust/platform/triple_mappings.bzl b/rust/platform/triple_mappings.bzl
25+
index 2345678..9abcdef 100644
26+
--- a/rust/platform/triple_mappings.bzl
27+
+++ b/rust/platform/triple_mappings.bzl
28+
@@ -298,6 +298,8 @@ def system_to_constraints(system):
29+
return [
30+
constraint_value("@rules_rust//rust/platform/os:wasi"),
31+
]
32+
+ elif system == "wasip1" or system == "wasip2" or system == "wasip3":
33+
+ # Handle 2-component WASI targets that were not normalized
34+
+ return [
35+
+ constraint_value("@rules_rust//rust/platform/os:wasi"),
36+
+ ]
37+
elif system == "windows":
38+
return [
39+
constraint_value("@platforms//os:windows"),

0 commit comments

Comments
 (0)