A local, offline Compiler Explorer β right in your terminal.
Write C++ in your editor. Watch the assembly update live. Understand every instruction.
Visit the Project Website
localbolt hello.cpp
LocalBolt is an offline, privacy-first Compiler Explorer that runs entirely in your terminal. It watches your C++ source files, recompiles on every save, and displays syntax-highlighted assembly output with per-instruction performance metrics β all without ever leaving your local machine. Inspired by Godbolt (https://godbolt.org/).
Built with Textual and Rich, this project was initially built for the TartanHacks (Carnegie Mellon) Hackathon. Where the project won the "Best Innovation without AI" award. It features a clean Mosaic light theme with a cyan-to-teal gradient palette designed for extended readability.
| Feature | Description |
|---|---|
| π Live Reload | Watches your .cpp file with Watchdog β assembly refreshes instantly on save |
| π¨ Syntax Highlighting | Color-coded assembly: instructions, registers, labels, size keywords, and numbers |
| π Performance Heatmap | Per-instruction cycle counts from llvm-mca with a green β amber β red severity gradient |
| π Source β Assembly Mapping | Floating peek popup shows exactly which C++ line generated the current assembly |
| π Sibling Highlighting | Assembly lines from the same C++ source line get a β gutter indicator when selected |
| π Instruction Help | Floating popup with description, example, and meaning for the instruction under the cursor |
| β¨οΈ Vim-Style Navigation | j/k and arrow keys for scrolling through assembly |
| π§Ή Clean Output | Strips compiler directives, debug noise, and system symbols β shows only your code |
| π§ Auto-Discovery | Finds compile_commands.json in your project and inherits build flags automatically |
| π Assembly Reference | Built-in --assemblyhelp reference for 30+ common x86 and ARM64 (Apple Silicon) instructions |
| Tool | Purpose | Install |
|---|---|---|
| Python 3.10+ | Runtime | python.org |
| g++ or clang++ | C++ compilation | brew install gcc / apt install g++ |
| llvm-mca | Performance analysis | brew install llvm / apt install llvm |
| c++filt | C++ symbol demangling | Included with gcc / binutils |
| rustc (optional) | Rust compilation | rustup.rs |
| rustfilt (optional) | Rust symbol demangling | cargo install rustfilt |
# Clone the repository
git clone https://github.com/RonaldMishiev/tartanhacks.git
cd tartanhacks
# Create a virtual environment and install
python3 -m venv .venv
source .venv/bin/activate
pip install -e .# Launch the TUI with a source file
localbolt hello.cpp
# Or view the assembly instruction reference
localbolt --assemblyhelpTip: Edit
hello.cppin your favorite editor (VS Code, Vim, etc.) and save β the assembly view updates automatically.
βΆmarks the cursor line.βmarks sibling assembly lines that originate from the same C++ source line.
| Key | Action |
|---|---|
j / β |
Move cursor down |
k / β |
Move cursor up |
r |
Force recompile |
o |
Compiler options |
q |
Quit |
| Background | Meaning |
|---|---|
π’ Green (#d1e7dd) |
Low latency β 1 cycle |
π‘ Amber (#fff3cd) |
Medium latency β 2β4 cycles |
π΄ Red (#f8d7da) |
High latency β 5+ cycles |
LocalBolt follows a clean pipeline architecture where data flows through four independent layers:
βββββββββββββββ βββββββββββββββ ββββββββββββββ βββββββββββββββ
β Compiler ββββββΆβ Parser ββββββΆβ Engine ββββββΆβ UI β
β Driver β β (Lexer) β β (State) β β (Textual) β
βββββββββββββββ βββββββββββββββ ββββββββββββββ βββββββββββββββ
g++ / clang++ clean & map coordinate render &
llvm-mca demangle watch navigate
diagnostics
src/localbolt/
βββ main.py # CLI entry point & argument parsing
βββ engine.py # BoltEngine β coordinates the full pipeline
βββ __init__.py # Package root, exports process_assembly
β
βββ compiler/ # π§ Compilation & Analysis
β βββ driver.py # CompilerDriver β runs g++/clang++ and llvm-mca
β βββ analyzer.py # Auto-discovers compile_commands.json flags
β βββ types.py # CompilationResult dataclass
β
βββ parsing/ # π§Ή Assembly Processing
β βββ lexer.py # 5-stage assembly cleaner with source line mapping
β βββ mapper.py # C++ symbol demangling via c++filt
β βββ perf_parser.py # Parses llvm-mca output into InstructionStats
β βββ diagnostics.py # Parses GCC/Clang stderr into Diagnostic objects
β
βββ ui/ # π¨ Terminal User Interface
β βββ app.py # LocalBoltApp β main Textual application
β βββ source_peek.py # SourcePeekPanel β floating C++ context popup
β βββ instruction_help.py # InstructionHelpPanel β floating asm instruction reference
β βββ widgets.py # AssemblyView & StatusBar reusable widgets
β
βββ asm_ui/ # π§ͺ Standalone assembly viewer (development tool)
β βββ asm_app.py # AsmApp β file-based assembly viewer prototype
β
βββ utils/ # βοΈ Shared Utilities
βββ state.py # LocalBoltState β single source of truth dataclass
βββ config.py # ConfigManager β ~/.localbolt/config.json
βββ watcher.py # FileWatcher β Watchdog-based file monitoring
βββ highlighter.py # Assembly syntax highlighting & heatmap gutter
βββ asm_help.py # Built-in assembly instruction reference table
The CompilerDriver invokes g++ or clang++ with carefully layered flags:
System flags (-S -g -fverbose-asm)
ββΆ Architecture flags (-masm=intel on x86)
ββΆ Config flags (-O3, user preferences from ~/.localbolt/config.json)
ββΆ Auto-discovered flags (from compile_commands.json)
ββΆ Runtime overrides (user-provided at launch)
It then pipes the generated assembly through llvm-mca for per-instruction performance metrics (latency, ΞΌops, throughput).
The lexer applies a 5-stage pipeline to clean raw compiler output:
| Stage | Purpose |
|---|---|
| Section Filter | Skip debug sections (.debug_*, __DWARF) β keep .text |
| Mapping | Track .loc directives to map asm lines β C++ source lines |
| Block Filter | Remove system symbols (__cxa_*, __gxx_*, STL internals) |
| Instruction Filter | Strip assembler directives (.align, .cfi_*) |
| Portability | Normalize macOS (_main) vs Linux (.LBB0_1) label formats |
The result: clean, readable assembly with an accurate {asm_line β source_line} mapping dictionary.
BoltEngine is the orchestrator. It:
- Reads the source file
- Calls
CompilerDriver.compile()β raw assembly - Passes through
process_assembly()β cleaned asm + mapping - Runs
CompilerDriver.analyze_perf()βllvm-mcaoutput - Parses into
InstructionStats(latency, ΞΌops, throughput) - Updates
LocalBoltState(the single source of truth) - Fires the
on_update_callbackto notify the UI - Starts
FileWatcherto auto-refresh on save (debounced at 500ms)
LocalBoltApp renders the state into an interactive TUI:
- Per-line
AsmLinewidgets for individual cursor highlighting & CSS severity classes AsmScrollβ aVerticalScrollwith disabled bindings so the app handles cursor movement with priority- Sibling line indicators β when cursor is on an asm line, all other asm lines from the same C++ source get a
βgutter mark SourcePeekPanelβ floating popup that walks the asmβsource mapping (with backward lookup) to show 3 lines of C++ contextInstructionHelpPanelβ floating popup that shows the description, example, and meaning for the instruction under the cursor- Generation-based widget IDs (
asm-line-{gen}-{idx}) to preventDuplicateIdserrors on refresh
LocalBolt stores preferences in ~/.localbolt/config.json:
{
"compiler": "g++",
"opt_level": "-O3",
"flags": ["-Wall", "-std=c++20"]
}| Key | Default | Description |
|---|---|---|
compiler |
"g++" |
Compiler to use (g++, clang++, gcc, clang) |
opt_level |
"-O0" |
Optimization level (-O0 through -O3, -Os, -Oz) |
flags |
[] |
Additional compiler flags passed to every compilation |
If a compile_commands.json is found in the project directory (or build/, out/, debug/ subdirectories), its include paths and flags are automatically merged.
LocalBolt features a comprehensive suite of unit and integration tests.
The easiest way to verify the entire project is to use the provided test runner:
./run_all_tests.shYou can also run specific tests using the virtual environment's Python:
Unit Tests (Logic & Utilities)
pytest tests/unit/Integration Tests (End-to-End & Systems)
pytest tests/integration/UI Tests (App, Widgets, Source Peek)
pytest tests/test_c_app.py tests/test_c_main.py tests/test_c_widgets.pyLocalBolt uses a custom light-mode color palette called Mosaic:
| Swatch | Hex | Role |
|---|---|---|
| β¬ | #EBEEEE |
Background |
| β¬ | #191A1A |
Text / Header background |
| π΅ | #45d3ee |
Cyan accent β instructions, footer |
| π· | #9FBFC5 |
Muted blue β borders, cursor highlight |
| π’ | #94bfc1 |
Teal β labels, panel titles |
| π | #fecd91 |
Orange β registers, examples |
textual>=0.47.1 # TUI framework
watchdog>=3.0.0 # File system monitoring
pygments>=2.17.2 # Syntax highlighting support
rich>=13.7.0 # Terminal rendering
System tools: g++ or clang++, llvm-mca, c++filt
This project was built for TartanHacks 2026.
Built with β‘ by the LocalBolt team