Skip to content

Commit ecb287e

Browse files
tgymnichclaude
andcommitted
Update AGENTS.md files with build instructions and formatting guidance
- water/AGENTS.md: restructure Building section to clarify that Water must be built with CMake first, then pip install with WAVE_WATER_DIR; add full cmake configure/build commands and useful flags; note that ninja alone is sufficient for iterating after initial pip install; add git clang-format guidance; add lit location note; add Pipelines.cpp reference in Pass Pipeline section - waveasm/AGENTS.md: add git clang-format guidance - AGENTS.md: update pre-commit invocation; add AGENTS.local.md to .gitignore Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Tim Gymnich <tim@gymni.ch>
1 parent f039831 commit ecb287e

4 files changed

Lines changed: 50 additions & 18 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ water/build_tools/wheel/water_mlir/water_mlir
6060
# rocm version detection
6161
requirements-pytorch-rocm-generated.txt
6262

63-
# Claude
63+
# AI Agents
6464
CLAUDE.local.md
65+
AGENTS.local.md

AGENTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ pytest -s tests/ --run-e2e # GPU tests (requires har
2121

2222
### Linting
2323
```bash
24-
mypy # type check wave_lang
25-
pre-commit run --all-files # Black, Ruff, clang-format
24+
mypy # type check wave_lang
25+
pre-commit run # run Black, Ruff, clang-format against currently staged files
2626
```
2727

2828
### Gotchas
2929
- **Always set `WAVE_CACHE_ON=0`** when testing code changes — stale cache entries hide the effect of edits: `WAVE_CACHE_ON=0 pytest ...`
30-
- DCO sign-off required on commits: `git commit -s`
3130
- Dump MLIR for debugging: `pytest --dump-mlir-files-path=/tmp/mlir tests/`
3231

3332
## Architecture

water/AGENTS.md

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,57 @@ Water is an optional MLIR layer in the Wave compiler stack that replaces IREE's
22

33
## Building
44

5+
Water must be built with CMake first. `pip install` alone does not build Water — `WAVE_WATER_DIR` is required to point Wave at an existing Water build.
6+
7+
LLVM is pinned at `water/llvm-sha.txt`. CLI tool: `water-opt` (analogous to `mlir-opt`).
8+
9+
### Step 1: Build Water with CMake
10+
11+
Requires a pre-built LLVM/MLIR. Set `$BUILD_DIR` to your LLVM build or install tree.
12+
513
```bash
6-
# First build — builds LLVM from source, takes a while
7-
WAVE_WATER_DIR=water/build pip install -e ".[dev]"
14+
# Configure
15+
cmake -G Ninja \
16+
-B water/build \
17+
water/ \
18+
-DMLIR_DIR=$BUILD_DIR/lib/cmake/mlir \
19+
-DBUILD_SHARED_LIBS=ON \
20+
-DPython3_EXECUTABLE="$(which python)" \
21+
-DWATER_ENABLE_PYTHON=ON
22+
23+
# Optional: faster builds with clang + ccache + lld
24+
cmake -B water/build \
25+
-DCMAKE_C_COMPILER=clang \
26+
-DCMAKE_CXX_COMPILER=clang++ \
27+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
28+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
29+
-DLLVM_USE_LINKER=lld
30+
31+
# Build
32+
cmake --build water/build
33+
```
34+
35+
### Step 2: Install Wave with Water bindings
836

9-
# Iterating on C++ changes
10-
ninja -C water/build # rebuild changed targets only
11-
pip install -e ".[dev]" # re-links Python extension (fast, skips CMake)
37+
```bash
38+
WAVE_WATER_DIR=water/build pip install -e ".[dev]"
1239
```
1340

14-
`WAVE_WATER_DIR` tells the Wave build system to use an existing build directory instead of rebuilding from scratch. Without it, the full LLVM + Water CMake build runs on every `pip install`.
41+
`WAVE_WATER_DIR` tells Wave where to find the Water build. Without it, Water is not included.
1542

16-
LLVM is pinned at `water/llvm-sha.txt`. CLI tool: `water-opt` (analogous to `mlir-opt`).
43+
### Iterating on C++ changes
1744

18-
## Formatting
45+
```bash
46+
ninja -C water/build # rebuild changed C++ targets and Python bindings
47+
```
1948

20-
C++ code is formatted with `clang-format`. Run via pre-commit or directly:
49+
## Formatting
2150

51+
C++ code is formatted with `git clang-format` which formats only the lines changed relative to a commit (default: `HEAD`)
2252
```bash
23-
clang-format -i <file> # format a single file in-place
24-
pre-commit run clang-format # format all staged files
53+
git clang-format # format staged changes
54+
git clang-format HEAD~1 # also include most recent commit
55+
git clang-format main # format everything touched on your branch
2556
```
2657

2758
## Testing

waveasm/AGENTS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ Set `WAVE_WAVEASM_DIR=waveasm/build` after first build to avoid full rebuilds on
1515

1616
## Formatting
1717

18-
C++ code is formatted with `clang-format`. Run via pre-commit or directly:
18+
C++ code is formatted with `git clang-format` which formats only the lines changed relative to a commit (default: `HEAD`)
1919

2020
```bash
21-
clang-format -i <file> # format a single file in-place
22-
pre-commit run clang-format # format all staged files
21+
git clang-format # format staged changes
22+
git clang-format HEAD~1 # also include most recent commit
23+
git clang-format main # format everything touched on your branch
2324
```
2425

2526
## Testing

0 commit comments

Comments
 (0)