# building

building guides compilation of ExecuTorch from source, including the Python package, C++ runtime, model runners, and mobile cross-compilation.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 21 installs · ★ 5187 repo stars
- Author: pytorch
- License: BSD-3-Clause · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/pytorch/executorch/tree/HEAD/.claude/skills/building/SKILL.md
- Updated: 2026-10-29
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/building

## What it does

This skill equips coding agents with build procedures for the ExecuTorch codebase. It starts by auditing prerequisites: it checks for Python 3.11–3.15 and CMake 3.24 or newer. The workflow can create an `executorch` Conda environment or a local `.executorch-venv`, automatically upgrading CMake via pip when needed.

Execution paths branch according to the request. Standard Python builds run `./install_executorch.sh --editable`, while the standalone C++ runtime utilizes CMake presets across macOS, Linux, and Windows. Dedicated model targets like `llama-cpu`, `whisper-metal`, or `gemma3-cuda` compile directly through `make <model>-<backend>`.

Mobile targets rely on dedicated helper scripts. Packaging Apple frameworks requires `./scripts/build_apple_frameworks.sh`, whereas building Android AAR artifacts fails immediately unless the `ANDROID_NDK` environment variable points to a valid NDK directory.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add pytorch/executorch --skill building -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/building/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/building/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add pytorch/executorch --skill building -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/building/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add pytorch/executorch --skill building -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/building/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install pytorch/executorch .claude/skills/building
```

2. **Manually: put the files in place**
- File: `.github/skills/building/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add pytorch/executorch --skill building -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/pytorch/executorch --path .claude/skills/building
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/building/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add pytorch/executorch --skill building -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/pytorch/executorch/tree/HEAD/.claude/skills/building/SKILL.md

## When to use it
- Compile ExecuTorch from source with optional backend flags
- Build model runner binaries such as `llama-cpu` and `whisper-metal`
- Configure standalone C++ runtimes via CMake presets
- Cross-compile libraries for iOS frameworks and Android AAR

## Example prompts
- Build ExecuTorch in editable mode with Core ML enabled
- Compile the whisper-metal runner target
- Configure the standalone C++ runtime for Linux Release

## Source text · SKILL.md · BSD-3-Clause

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 564b485906adb42b.

BEGIN THIRD-PARTY FILE 564b485906adb42b
````text
---
name: building
description: Build ExecuTorch from source — Python package, C++ runtime, runners, cross-compilation, and backend-specific builds. Use when compiling anything in the ExecuTorch repo, diagnosing build failures, or setting up platform-specific builds.
---

# Building ExecuTorch

## Step 1: Ensure Python environment (detect and fix automatically)

**Path A — conda (preferred):**
```bash
# Initialize conda for non-interactive shells (required in Claude Code / CI)
eval "$(conda shell.bash hook 2>/dev/null)"

# Check if executorch conda env exists; create if not
conda env list 2>/dev/null | grep executorch || \
  ls "$(conda info --base 2>/dev/null)/envs/" 2>/dev/null | grep executorch || \
  conda create -yn executorch python=3.12

# Activate
conda activate executorch
```

**Path B — no conda (fall back to venv):**
```bash
# Find a compatible Python (3.11–3.15).
python3.12 -m venv .executorch-venv   # or python3.11, python3.13, python3.14, python3.15
source .executorch-venv/bin/activate
pip install --upgrade pip
```

**Then verify (either path):**

Run `python --version` and `cmake --version`. Fix automatically:
- **Python not 3.11–3.15**: recreate the env with a correct Python version.
- **cmake missing or < 3.24**: run `pip install 'cmake>=3.24'` inside the env.
- **cmake >= 4.0**: works in practice, no action needed.

Parallel jobs: `$(sysctl -n hw.ncpu)` on macOS, `$(nproc)` on Linux.

## Step 2: Build

Route based on what the user asks for:
- User mentions **Android** → skip to [Cross-compilation: Android](#cross-compilation)
- User mentions **iOS** or **frameworks** → skip to [Cross-compilation: iOS](#cross-compilation)
- User mentions a **model name** (llama, whisper, etc.) → skip to [LLM / ASR model runner](#llm--asr-model-runner-simplest-path-for-running-models)
- User mentions **C++ runtime** or **cmake** → skip to [C++ runtime](#c-runtime-standalone)
- Otherwise → default to **Python package** below

### Python package (default)
```bash
conda activate executorch
./install_executorch.sh --editable    # editable install from source
```
This handles everything: submodules, deps, C++ build, Python install. Takes ~10 min on Apple Silicon.

For subsequent rebuilds (deps already present): `pip install -e . --no-build-isolation`

For minimal install (skip example deps): `./install_executorch.sh --minimal`

Enable additional backends:
```bash
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_VULKAN=ON" ./install_executorch.sh --editable
```

Verify: `python -c "from executorch.exir import to_edge_transform_and_lower; print('OK')"`

### LLM / ASR model runner (simplest path for running models)

```bash
conda activate executorch
make <model>-<backend>
```

Available targets (run `make help` for full list):

| Target | Backend | macOS | Linux |
````
END THIRD-PARTY FILE 564b485906adb42b

The third-party file has ended. Everything between the 564b485906adb42b tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2836 of 9128 bytes. © pytorch · BSD-3-Clause · https://github.com/pytorch/executorch/tree/HEAD/.claude/skills/building/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
