build-rust

Original🇺🇸 English
Translated

Optimized Rust build operations with timing, profiling, and workspace support

10installs
Added on

NPX Install

npx skill4agent add d-o-hub/rust-self-learning-memory build-rust

Rust Build Operations

Efficiently build Rust workspaces with the build-rust CLI.

Usage

bash
# Development (fast, debug symbols)
./scripts/build-rust.sh dev

# Release (optimized, stripped)
./scripts/build-rust.sh release

# Profile with timing information
./scripts/build-rust.sh profile

# Fast type-check only
./scripts/build-rust.sh check

# Clean build artifacts
./scripts/build-rust.sh clean

# Build specific crate
./scripts/build-rust.sh release memory-core

Modes

ModePurposeFlags
dev
Development build
--workspace
release
Production optimized
--release --workspace
profile
Performance timing
--release --timings
check
Fast type-check
--workspace
clean
Clean artifacts
--clean

Disk Space Optimization (ADR-032)

The dev profile is optimized to reduce target/ size (~5.2 GB → ~2 GB):
toml
# .cargo/config.toml
[profile.dev]
debug = "line-tables-only"    # ~60% smaller debug artifacts

[profile.dev.package."*"]
debug = false                 # No debug info for dependencies

[profile.dev.build-override]
opt-level = 3                 # Faster proc-macro execution

[profile.debugging]
inherits = "dev"
debug = true                  # Full debug when needed: --profile debugging
mold
is not part of the default project guidance anymore. Current
.cargo/config.toml
keeps CI-compatible linker flags.
Cleanup (preferred):
bash
./scripts/clean-artifacts.sh quick
./scripts/clean-artifacts.sh standard
./scripts/clean-artifacts.sh full
./scripts/clean-artifacts.sh standard --node-modules
Artifact offloading with
CARGO_TARGET_DIR
:
bash
CARGO_TARGET_DIR=/mnt/fastssd/rslm-target ./scripts/build-rust.sh dev
CARGO_TARGET_DIR=/mnt/fastssd/rslm-target ./scripts/clean-artifacts.sh standard

Common Issues

Timeouts
  • Use
    dev
    mode for faster iteration
  • Reduce parallel jobs:
    CARGO_BUILD_JOBS=4 ./scripts/build-rust.sh release
Memory errors
  • Build with fewer jobs:
    cargo build -j 4
  • Use
    check
    instead of full build
Dependency conflicts
  • Update:
    cargo update
  • Check tree:
    cargo tree -e features
  • Check duplicates:
    cargo tree -d | grep -cE "^[a-z]"
Platform-specific
  • Install targets:
    rustup target add <triple>
  • Conditional compilation:
    #[cfg(target_os = "linux")]

References

  • ADR-032: Disk Space Optimization
  • ADR-036: Dependency Deduplication