Open Manual

<!-- nytrix-doc: {"audience":"user","featured":true,"group":"learn","order":195,"summary":"Comprehensive build system guide: CMake options, LLVM/GMP/Z3 integration, sanitizer builds, and cross-compilation."} -->

Build System & Toolchain Setup

Nytrix uses CMake for its build configuration, wrapped with an ergonomic Python ./make driver at the repository root.

Build Driver (./make)

The ./make driver provides canonical commands for configuring, building, formatting, testing, and auditing the codebase:

./make --help          # Show all driver commands
./make env             # Display resolved environment and configuration
./make doctor          # Diagnose toolchain, dependencies, and system state
./make targets         # List all available build targets
./make bin             # Build Release binaries
./make tidy            # Format source, run linter, and check header integrity
./make audit           # Run static bug audit analysis
./make check           # Run full validation suite (build + audit + tests)

CMake Options Matrix

FlagValuesDefaultDescription
NYTRIX_USE_LLVMON, OFFON (Unix), ON (Win)LLVM backend support (required on Windows; optional on Unix for pure-native builds).
NYTRIX_USE_GMPON, OFFOFFUse GNU MP for big-integer oracle validation.
NYTRIX_ENABLE_Z3auto, on, offautoFinite constraint solving in the compile-time proof engine.
NYTRIX_FAST_BUILDON, OFFOFFEnables host -march=native optimizations for faster local builds.
NYTRIX_RUNTIME_O3ON, OFFONCompiles runtime hot paths with -O3.
NYTRIX_LTO_MODEnone, thin, fullnoneLink-Time Optimization mode.
NYTRIX_PGO_MODEnone, gen, usenoneProfile-Guided Optimization mode.
NYTRIX_PGO_PROFILE<path>""Path to profile data file for PGO.
NYTRIX_ICF_MODEnone, safe, allnoneIdentical Code Folding linker mode.

LLVM Discovery

CMake searches for llvm-config binaries from version 22 down to 16 automatically. To use a specific version or custom installation:

export LLVM_CONFIG=/usr/bin/llvm-config-21
export NYTRIX_LLVM_INCLUDE=/usr/lib/llvm21/include

On Unix systems, you can build without LLVM for pure-native execution:

cmake -S . -B build/release -DNYTRIX_USE_LLVM=OFF
cmake --build build/release -j"$(nproc)"

Dedicated Sanitizer Build Trees

Always build sanitizers in dedicated debug build directories to keep instrumented objects isolated:

AddressSanitizer + UndefinedBehaviorSanitizer (ASan + UBSan)

cmake -S . -B build/asan -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
cmake --build build/asan -j"$(nproc)"

# Run focused test fixture under ASan
ASAN_OPTIONS=detect_leaks=1:halt_on_error=1 \
  build/asan/ny-test --bin build/asan/ny_debug --failures-only --pattern=<fixture>

# Run reproducer directly
build/asan/ny_debug path/to/reproducer.ny

ThreadSanitizer (TSan)

cmake -S . -B build/tsan -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer -g"
cmake --build build/tsan -j"$(nproc)"

MemorySanitizer (MSan - Clang Only)

CC=clang cmake -S . -B build/msan -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_FLAGS="-fsanitize=memory -fno-omit-frame-pointer -g"
cmake --build build/msan -j"$(nproc)"

Valgrind Memory Validation

./make bin
valgrind --leak-check=full --show-leak-kinds=definite \
  --errors-for-leak-kinds=definite --error-exitcode=97 \
  build/release/ny-full path/to/reproducer.ny

Common Build Issues & Troubleshooting

Issue / SymptomRoot CauseSolution
LLVM headers not foundMissing development headersInstall llvm-dev / libclang-dev, or set NYTRIX_LLVM_INCLUDE.
libclang not foundMissing Clang libraryInstall libclang-dev, or set NYTRIX_CLANG_LIBRARY.
GMP not foundOptional big-integer oracle missingInstall libgmp-dev, or configure with -DNYTRIX_USE_GMP=OFF.
Z3 not foundOptional constraint solver missingInstall libz3-dev, or configure with -DNYTRIX_ENABLE_Z3=off.
Cross-compiling WindowsMissing Windows SDK headers/libsExport NYTRIX_WINSDK_CFLAGS and NYTRIX_WINSDK_LDFLAGS.
Slow build turnaroundDefault linker or baseline flagsEnable -DNYTRIX_FAST_BUILD=ON and use the mold or lld linker.