Why Use Cargo?
Cargo is ideal when you need:- Fast Iteration - Quick compile-test cycles
- IDE Support - Native rust-analyzer integration
- Standard Workflow - Familiar Rust development patterns
- Direct Dependencies - Transparent dependency management
- Debugging - Better debugger integration
For production builds and CI, use Bazel to ensure reproducibility.
Setup
Prerequisites
Install Rust
Building
Basic Build Commands
Build Profiles
NativeLink defines custom build profiles inCargo.toml:
Testing
Running Tests
Test Configuration
Code Quality
Formatting
Linting with Clippy
Lint Configuration
NativeLink enforces strict lints defined inCargo.toml:96-213:
Cargo.toml for the complete list.
Documentation
Building Documentation
Documentation Tests
Running NativeLink
Run with Cargo
Binary Locations
Workspace Structure
NativeLink uses a Cargo workspace defined inCargo.toml:2-7:
Workspace Crates
nativelink-config
Configuration parsing and validation
nativelink-error
Error types and handling
nativelink-scheduler
Task scheduling and execution
nativelink-service
gRPC service implementations
nativelink-store
Storage backends and caching
nativelink-util
Shared utilities and helpers
nativelink-worker
Remote execution worker
nativelink-macro
Procedural macros
nativelink-proto
Protocol buffer definitions
nativelink-metric
Metrics and telemetry
IDE Integration
rust-analyzer
rust-analyzer works out of the box with Cargo workspaces:VS Code Setup
Debugging
- VS Code
- Command Line
Advanced Usage
Dependency Management
Build Performance
- Parallel Builds
- Incremental Compilation
- Build Cache
Cross-Compilation
Troubleshooting
Cargo fails with OpenSSL errors
Cargo fails with OpenSSL errors
Install OpenSSL development headers:Or use vendored OpenSSL (if available):
Linker errors on macOS
Linker errors on macOS
Ensure Xcode Command Line Tools are installed:
Out of disk space
Out of disk space
Clean build artifacts:
Slow incremental builds
Slow incremental builds
Clear incremental compilation cache:
Clippy or rustfmt version mismatch
Clippy or rustfmt version mismatch
Update Rust toolchain:
Cargo Tools
cargo-watch
Auto-rebuild on file changes
cargo-bloat
Find what takes space in binaries
cargo-tree
Show dependency tree (built-in)
cargo-expand
Expand macros
Next Steps
Development with Bazel
Production builds and remote execution
Development with Nix
Reproducible development environment