-
Notifications
You must be signed in to change notification settings - Fork 0
Build System
The project uses CMake 3.16+ with C++20 and LLVM as the primary dependency.
./build.sh --type Releasecmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_DIR=/usr/lib/llvm-20/lib/cmake/llvm \
-DClang_DIR=/usr/lib/llvm-20/lib/cmake/clang \
-DLLVM_LINK_LLVM_DYLIB=ON
cmake --build build -j$(nproc)| Option | Default | Description |
|---|---|---|
BUILD_CLI |
ON |
Build the stack_usage_analyzer CLI binary |
BUILD_SHARED_LIB |
ON |
Reserved compatibility option (current target is still stack_usage_analyzer_lib static library) |
BUILD_ANALYZER_UNIT_TESTS |
OFF |
Build unit tests (standalone builds only) |
ENABLE_STACK_USAGE |
OFF |
Emit per-function .su files |
ENABLE_DEBUG_ASAN |
OFF |
Enable AddressSanitizer + debug symbols |
LLVM_LINK_LLVM_DYLIB |
ON |
Link against libLLVM shared library |
| Target | Type | Description |
|---|---|---|
stack_usage_analyzer_lib |
Static library | Core analysis engine |
coretrace::stack_usage_analyzer_lib |
Alias | For FetchContent consumers |
stack_usage_analyzer |
Executable | CLI tool (requires BUILD_CLI=ON) |
stack_usage_analyzer_unit_tests |
Executable | Unit tests (requires BUILD_ANALYZER_UNIT_TESTS=ON) |
format |
Custom | Run clang-format on all sources |
format-check |
Custom | Verify clang-format compliance |
| Dependency | Minimum Version | How It's Found |
|---|---|---|
| LLVM | 19 | find_package(LLVM REQUIRED CONFIG) |
| Clang | (matches LLVM) | Via LLVM |
| Dependency | Repository | Purpose |
|---|---|---|
coretrace-compiler |
CoreTrace/coretrace-compiler |
C/C++ to LLVM IR compilation |
coretrace-logger |
CoreTrace/coretrace-log |
Structured logging |
Both are fetched from main branch during CMake configure.
The default mode is dynamic linking (LLVM_LINK_LLVM_DYLIB=ON), which links against libLLVM.so/libLLVM.dylib.
If dynamic linking is not available, set LLVM_LINK_LLVM_DYLIB=OFF to link individual LLVM component libraries (core, irreader, support).
The build.sh wrapper auto-detects LLVM/Clang:
macOS: uses brew --prefix llvm to find Homebrew LLVM.
Linux: uses llvm-config to locate LLVM CMake configs.
./build.sh --type Release # Build type
./build.sh --generator Ninja # CMake generator
./build.sh --jobs 8 # Parallel jobs
./build.sh --build-dir out/build # Custom output dir
./build.sh --clean # Clean before build
./build.sh --configure-only # Only run CMake configure
./build.sh --llvm-dir /path/... # Override LLVM path
./build.sh --clang-dir /path/... # Override Clang path| Variable | Description |
|---|---|
LLVM_DIR |
Path to LLVM CMake config directory |
Clang_DIR |
Path to Clang CMake config directory |
DEBUG_ASAN |
Set to ON to enable AddressSanitizer |
Other CMake projects can consume the analyzer via FetchContent:
include(FetchContent)
FetchContent_Declare(
stack-analyzer
GIT_REPOSITORY https://github.com/CoreTrace/coretrace-stack-analyzer.git
GIT_TAG main
)
FetchContent_MakeAvailable(stack-analyzer)
target_link_libraries(my_tool PRIVATE coretrace::stack_usage_analyzer_lib)See extern-project/ for a complete example.
./scripts/format.sh
# or
cmake --build build --target format./scripts/format-check.sh
# or
cmake --build build --target format-checkTarget version: clang-format 20 (used in CI).
Enable ASAN for debugging:
./build.sh --type Debug
# Then rebuild with ASAN:
cmake -S . -B build -DENABLE_DEBUG_ASAN=ON ...
cmake --build buildOr via environment:
DEBUG_ASAN=ON ./build.sh --type DebugASAN flags are applied to both the library and CLI binary.