Skip to content

Commit 9f49d18

Browse files
committed
refactor: use git_override for rules_rust wasip2 support
- Replace local_path_override with git_override pointing to avrabe/rules_rust - Use feature/wasi-p2-support branch with minimal wasip2 patches - Remove large third_party/rules_rust_patched directory (3,423 files) - Add patch file and documentation for maintainability - Much cleaner approach than carrying full patched codebase
1 parent cedd1f7 commit 9f49d18

File tree

3,424 files changed

+57
-758303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,424 files changed

+57
-758303
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bazel_dep(name = "rules_rust", version = "0.62.0")
1313
git_override(
1414
module_name = "rules_rust",
1515
remote = "https://github.com/avrabe/rules_rust.git",
16-
commit = "HEAD", # Update this to specific commit hash once patch is applied
16+
commit = "feature/wasi-p2-support",
1717
)
1818
bazel_dep(name = "bazel_skylib", version = "1.7.1")
1919
bazel_dep(name = "platforms", version = "0.0.11")

PATCH_README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# rules_rust WASI Support Patch
2+
3+
This repository uses a fork of rules_rust with minimal patches to support WASI target triples.
4+
5+
## What's Patched
6+
7+
**File**: `rust/platform/triple.bzl`
8+
**Changes**: Added support for 2-component WASI target triples
9+
10+
### The Problem
11+
rules_rust expects target triples to have 3+ components (e.g., `x86_64-unknown-linux-gnu`), but WASI targets use 2-component format:
12+
- `wasm32-wasip1` (WASI Preview 1)
13+
- `wasm32-wasip2` (WASI Preview 2)
14+
15+
### The Solution
16+
Convert 2-component WASI targets to standard 3-component format:
17+
- `wasm32-wasip1``wasm32-unknown-wasi`
18+
- `wasm32-wasip2``wasm32-unknown-wasi`
19+
- `wasm32-wasip3``wasm32-unknown-wasi` (future support)
20+
21+
## Applying the Patch
22+
23+
1. Clone the rules_rust fork:
24+
```bash
25+
git clone https://github.com/avrabe/rules_rust.git
26+
cd rules_rust
27+
```
28+
29+
2. Apply the patch:
30+
```bash
31+
git apply wasip2-support.patch
32+
```
33+
34+
3. Commit and push:
35+
```bash
36+
git add rust/platform/triple.bzl
37+
git commit -m "feat: add support for wasm32-wasip2 target triples
38+
39+
- Handle 2-component WASI target triples in triple.bzl
40+
- Convert wasm32-wasip1, wasm32-wasip2, wasm32-wasip3 to standard format
41+
- Enable WASI Preview 2 builds with rules_rust compatibility"
42+
git push origin main
43+
```
44+
45+
4. Update the commit hash in `MODULE.bazel`:
46+
```python
47+
git_override(
48+
module_name = "rules_rust",
49+
remote = "https://github.com/avrabe/rules_rust.git",
50+
commit = "abc123...", # Use the actual commit hash
51+
)
52+
```
53+
54+
## Status
55+
56+
This is a minimal, safe patch that only affects target triple parsing. The changes are expected to be upstreamed to the main rules_rust repository eventually.

0 commit comments

Comments
 (0)