Bazel Build Rules Reference
coralnpu_v2_binary
The primary build rule for compiling C/C++ to a bare-metal Coral NPU binary.
Usage
load("//rules:coralnpu_v2.bzl", "coralnpu_v2_binary")
coralnpu_v2_binary(
name = "my_program",
srcs = ["my_program.cc"],
)
Platform Constraints
Toolchain Configuration
Compiler Flags
| Flag | Purpose |
|---|---|
|
Cross-compile target triple |
|
Target the full Coral NPU ISA |
|
32-bit integers, longs, pointers |
|
Medium-any code model |
|
Aggressive optimization |
|
No standard library startup |
|
No C++ exceptions (saves code size) |
|
No C++ RTTI (saves code size) |
CRT Startup
Startup Sequence
| Step | Action |
|---|---|
1 |
Load stack pointer from |
2 |
Load global pointer from |
3 |
Zero |
4 |
Run C++ static constructors ( |
5 |
Set |
6 |
Enable FP extension in |
7 |
Enable Vector extension in |
8 |
Write sentinel |
9 |
Call |
10 |
Store return value of |
11 |
Run C++ static destructors ( |
12 |
Execute |
13 |
Read cycle counters ( |
14 |
Execute |
Linker Script
Simulator Targets
MPACT Behavioral Simulator
# Build
bazel build //sim:coralnpu_v2_sim
# Run
bazel run //sim:coralnpu_v2_sim -- path/to/program.elf
# Interactive mode
bazel run //sim:coralnpu_v2_sim -- --i path/to/program.elf
Key Build Files
| Path | Purpose |
|---|---|
|
Workspace-level build rules |
|
|
|
|
|
Cross-compiler configuration |
|
Toolchain registration |
|
Platform constraint definitions |
|
Example program build targets |
|
MPACT simulator build target |
|
Verilator simulator build target |