Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
eedf272
fix(test-runner): harden strict expectation matching and location tol…
SizzleUnrlsd Mar 1, 2026
b6506c6
test(fixtures): update expectations in recursive-controlled-alloca.c
SizzleUnrlsd Mar 1, 2026
250efb3
test(fixtures): update expectations in recursive-infinite-alloca.c
SizzleUnrlsd Mar 1, 2026
ce76163
test(fixtures): update expectations in bound-storage-if-statement.c
SizzleUnrlsd Mar 1, 2026
102f717
test(fixtures): update expectations in bound-storage.c
SizzleUnrlsd Mar 1, 2026
675b4d4
test(fixtures): update expectations in indirection-profonde-aliasing.c
SizzleUnrlsd Mar 1, 2026
7804860
test(fixtures): update expectations in bound_index.cc
SizzleUnrlsd Mar 1, 2026
0ed2266
test(fixtures): update expectations in dead_code.cc
SizzleUnrlsd Mar 1, 2026
180baa3
test(fixtures): update expectations in format_problem.c
SizzleUnrlsd Mar 1, 2026
7a0e586
test(fixtures): update expectations in null_pointer.c
SizzleUnrlsd Mar 1, 2026
842324b
test(fixtures): update expectations in bad-usage-memcpy.c
SizzleUnrlsd Mar 1, 2026
6d1d1a4
test(fixtures): update expectations in bad-usage-memset.c
SizzleUnrlsd Mar 1, 2026
e7a770e
test(fixtures): update expectations in unbounded-strcpy-model.c
SizzleUnrlsd Mar 1, 2026
0b0cad1
test(fixtures): update expectations in indirect-callback-unknown-targ…
SizzleUnrlsd Mar 1, 2026
2c7c88a
test(fixtures): update expectations in return-stack-address-through-p…
SizzleUnrlsd Mar 1, 2026
334cf7c
test(fixtures): update expectations in stack_escape.c
SizzleUnrlsd Mar 1, 2026
97d4ecc
test(fixtures): update expectations in virtual-strategy-local-no-esca…
SizzleUnrlsd Mar 1, 2026
07685d6
test(fixtures): update expectations in unique_ptr_state.cpp
SizzleUnrlsd Mar 1, 2026
f48cf07
test(fixtures): update expectations in stb-like-next-code-uninitializ…
SizzleUnrlsd Mar 1, 2026
a1cec04
test(fixtures): update expectations in external-wrapper-known-no-acqu…
SizzleUnrlsd Mar 1, 2026
e83e7da
test(fixtures): update expectations in external-wrapper-unknown-out-n…
SizzleUnrlsd Mar 1, 2026
0913d9f
test(fixtures): update expectations in external-wrapper-unknown-ref-o…
SizzleUnrlsd Mar 1, 2026
701e857
test(fixtures): update expectations in new-double-delete.cpp
SizzleUnrlsd Mar 1, 2026
8250b8b
test(fixtures): update expectations in uninitialized-local-pointer-re…
SizzleUnrlsd Mar 1, 2026
384da9c
chore(test-compat): keep legacy test/files shim in sync (README.md)
SizzleUnrlsd Mar 1, 2026
f8c736f
chore(test-compat): keep legacy test/files shim in sync (Makefile)
SizzleUnrlsd Mar 1, 2026
da170c8
test(inter-tu): add cross-tu regression fixture cross-tu-tricky-def.c
SizzleUnrlsd Mar 1, 2026
d6e52a8
test(inter-tu): add cross-tu regression fixture cross-tu-tricky-use.c
SizzleUnrlsd Mar 1, 2026
1b4f90e
test(inter-tu): add cross-tu regression fixture cross-tu-uaf-def.c
SizzleUnrlsd Mar 1, 2026
e084f05
test(inter-tu): add cross-tu regression fixture cross-tu-uaf-use.c
SizzleUnrlsd Mar 1, 2026
9962c6e
docs(test-security): add grouped corpus documentation and tooling (Ma…
SizzleUnrlsd Mar 1, 2026
6e29f05
docs(test-security): add grouped corpus documentation and tooling (RE…
SizzleUnrlsd Mar 1, 2026
4fce94b
test(security): add or update categorized fixture 01_buffer_overflow.c
SizzleUnrlsd Mar 1, 2026
7c11ffc
test(security): add or update categorized fixture 08_command_injection.c
SizzleUnrlsd Mar 1, 2026
c32e546
test(security): add or update categorized fixture 02_format_string.c
SizzleUnrlsd Mar 1, 2026
b981218
test(security): add or update categorized fixture 04_integer_overflow.c
SizzleUnrlsd Mar 1, 2026
3247c71
test(security): add or update categorized fixture 17_integer_overflow…
SizzleUnrlsd Mar 1, 2026
020d0b6
test(security): add or update categorized fixture 09_memory_leak.c
SizzleUnrlsd Mar 1, 2026
4802c60
test(security): add or update categorized fixture 05_null_deref.c
SizzleUnrlsd Mar 1, 2026
cd0e04b
test(security): add or update categorized fixture 16_null_deref_nested.c
SizzleUnrlsd Mar 1, 2026
c35546d
test(security): add or update categorized fixture 12_oob_read.c
SizzleUnrlsd Mar 1, 2026
52b2ad5
test(security): add or update categorized fixture 15_sizeof_pitfall.c
SizzleUnrlsd Mar 1, 2026
1b81048
test(security): add or update categorized fixture 11_return_local.c
SizzleUnrlsd Mar 1, 2026
1d85464
test(security): add or update categorized fixture 07_toctou.c
SizzleUnrlsd Mar 1, 2026
ea100c6
test(security): add or update categorized fixture 10_type_confusion.c
SizzleUnrlsd Mar 1, 2026
d64919e
test(security): add or update categorized fixture 06_uninitialized.c
SizzleUnrlsd Mar 1, 2026
a318ce6
test(security): add or update categorized fixture 13_unsafe_functions.c
SizzleUnrlsd Mar 1, 2026
372df3f
test(security): add or update categorized fixture 03_use_after_free.c
SizzleUnrlsd Mar 1, 2026
c3c7d22
test(security): add or update categorized fixture 18_use_after_free_a…
SizzleUnrlsd Mar 1, 2026
e84769a
test(security): add or update categorized fixture 14_variadic_mismatch.c
SizzleUnrlsd Mar 1, 2026
5ae7d4a
test(fixtures): update expectations in bound-storage-for-statement.c
SizzleUnrlsd Mar 1, 2026
df07eed
test(fixtures): update expectations in ranges_test.c
SizzleUnrlsd Mar 1, 2026
ecb5291
test(fixtures): update expectations in name-contains-memintrinsics.c
SizzleUnrlsd Mar 1, 2026
7ff8a10
test(fixtures): update expectations in stack-exhaustion-large-frame.c
SizzleUnrlsd Mar 1, 2026
3f7b4a0
test(fixtures): update expectations in const-mixed.c
SizzleUnrlsd Mar 1, 2026
ffe2e9c
test(fixtures): update expectations in release-without-acquire-still-…
SizzleUnrlsd Mar 1, 2026
f9776ae
test(fixtures): update expectations in cross-tu-uninitialized-wrapper…
SizzleUnrlsd Mar 1, 2026
046dd58
test(fixtures): update expectations in uninitialized-local-cpp-lambda…
SizzleUnrlsd Mar 1, 2026
223cc91
test(fixtures): update expectations in uninitialized-local-stdint-typ…
SizzleUnrlsd Mar 1, 2026
a2d01ac
test(fixtures): update expectations in uninitialized-local-warnings-o…
SizzleUnrlsd Mar 1, 2026
144dc39
build(cmake): update CMakeLists.txt
SizzleUnrlsd Mar 1, 2026
e28419b
docs(readme): update project README
SizzleUnrlsd Mar 1, 2026
378e9ca
feat(analyzer): update StackUsageAnalyzer.hpp
SizzleUnrlsd Mar 1, 2026
7b25da9
feat(analyzer): update BufferWriteModel.hpp
SizzleUnrlsd Mar 1, 2026
cb744c6
feat(analyzer): update CommandInjectionAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
a8917ee
feat(analyzer): update FrontendDiagnostics.hpp
SizzleUnrlsd Mar 1, 2026
8aeed2b
feat(analyzer): update InputPipeline.hpp
SizzleUnrlsd Mar 1, 2026
ef6e381
feat(analyzer): update IntegerOverflowAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
55e68bb
feat(analyzer): update MemIntrinsicOverflow.hpp
SizzleUnrlsd Mar 1, 2026
16201ec
feat(analyzer): update NullDerefAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
bbfda68
feat(analyzer): update OOBReadAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
a3fe57f
feat(analyzer): update ResourceLifetimeAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
887e8c6
feat(analyzer): update StackBufferAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
962fb81
feat(analyzer): update TOCTOUAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
fff5d9f
feat(analyzer): update TypeConfusionAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
58cfefc
feat(analyzer): update UninitializedVarAnalysis.hpp
SizzleUnrlsd Mar 1, 2026
55bf5b3
feat(analyzer): update DiagnosticEmitter.hpp
SizzleUnrlsd Mar 1, 2026
961cfb0
feat(analyzer): update main.cpp
SizzleUnrlsd Mar 1, 2026
4115471
chore(models): update generic.txt
SizzleUnrlsd Mar 1, 2026
7ea0589
chore(models): update generic.txt
SizzleUnrlsd Mar 1, 2026
8f404e7
feat(analyzer): update StackUsageAnalyzer.cpp
SizzleUnrlsd Mar 1, 2026
42afc0e
feat(analyzer): update BufferWriteModel.cpp
SizzleUnrlsd Mar 1, 2026
912849a
feat(analyzer): update CommandInjectionAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
a852963
feat(analyzer): update FrontendDiagnostics.cpp
SizzleUnrlsd Mar 1, 2026
9335f7b
feat(analyzer): update InputPipeline.cpp
SizzleUnrlsd Mar 1, 2026
8f64246
feat(analyzer): update IntRanges.cpp
SizzleUnrlsd Mar 1, 2026
6e7b756
feat(analyzer): update IntegerOverflowAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
11d7555
feat(analyzer): update MemIntrinsicOverflow.cpp
SizzleUnrlsd Mar 1, 2026
6090f4c
feat(analyzer): update NullDerefAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
6a3d597
feat(analyzer): update OOBReadAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
e66558f
feat(analyzer): update ResourceLifetimeAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
730898e
feat(analyzer): update StackBufferAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
ca9e577
feat(analyzer): update TOCTOUAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
e9eb9bb
feat(analyzer): update TypeConfusionAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
bfb6ce4
feat(analyzer): update UninitializedVarAnalysis.cpp
SizzleUnrlsd Mar 1, 2026
f84c201
feat(analyzer): update AnalysisPipeline.cpp
SizzleUnrlsd Mar 1, 2026
679cbc5
feat(analyzer): update DiagnosticEmitter.cpp
SizzleUnrlsd Mar 1, 2026
eb85c88
feat(analyzer): update AnalyzerApp.cpp
SizzleUnrlsd Mar 1, 2026
2020b80
feat(analyzer): update ArgParser.cpp
SizzleUnrlsd Mar 1, 2026
053c577
test(fixtures): add or update global-array-overflow.c
SizzleUnrlsd Mar 1, 2026
49d030d
test(fixtures): add or update ne-narrowing-unsound.c
SizzleUnrlsd Mar 1, 2026
9875523
test(fixtures): add or update AvoidDefaultArgumentsOnVirtualMethods.hh
SizzleUnrlsd Mar 1, 2026
ec447ff
test(fixtures): add or update DestructorOfVirtualClass.hh
SizzleUnrlsd Mar 1, 2026
68b60f4
test(fixtures): add or update EmptyForStatement.cc
SizzleUnrlsd Mar 1, 2026
6496cca
test(fixtures): add or update RedundantIfStatement.c
SizzleUnrlsd Mar 1, 2026
6d44541
test(fixtures): add or update RedundantIfStatement.cc
SizzleUnrlsd Mar 1, 2026
4e71ead
test(fixtures): add or update bad_function_pointer.cc
SizzleUnrlsd Mar 1, 2026
6710048
test(fixtures): add or update buffer_overflow.cc
SizzleUnrlsd Mar 1, 2026
71d6227
test(fixtures): add or update double_free.c
SizzleUnrlsd Mar 1, 2026
cc6df55
test(fixtures): add or update if_collapse.c
SizzleUnrlsd Mar 1, 2026
ac19682
test(fixtures): add or update if_constant_expr.c
SizzleUnrlsd Mar 1, 2026
2d4e521
test(fixtures): add or update partitioning.cc
SizzleUnrlsd Mar 1, 2026
83a8248
test(fixtures): add or update pointer_comparison_analysis.cc
SizzleUnrlsd Mar 1, 2026
c9a6a7e
test(fixtures): add or update pointer_overflow.cc
SizzleUnrlsd Mar 1, 2026
8b2ab17
test(fixtures): add or update too_many_methods.cc
SizzleUnrlsd Mar 1, 2026
97153fd
test(fixtures): add or update unaligned_dereferencing.cc
SizzleUnrlsd Mar 1, 2026
160ff37
test(fixtures): add or update memcpy-name-false-positive.c
SizzleUnrlsd Mar 1, 2026
d3dc8bc
test(fixtures): add or update custom-wrapper-buffer-model.txt
SizzleUnrlsd Mar 1, 2026
74188bc
test(fixtures): add or update cxa-demangle-balanced-no-incomplete.cpp
SizzleUnrlsd Mar 1, 2026
3cb39b7
test(fixtures): add or update local-non-escaping-no-incomplete.cpp
SizzleUnrlsd Mar 1, 2026
37a0cc1
test(fixtures): add or update nocapture-local-handle-no-incomplete.cpp
SizzleUnrlsd Mar 1, 2026
e2e9eb2
test(fixtures): add or update summary-release-aggregate-field-no-inco…
SizzleUnrlsd Mar 1, 2026
f049b0b
test(fixtures): add or update summary-release-aggregate-local-no-inco…
SizzleUnrlsd Mar 1, 2026
3281c8a
test(fixtures): add or update uninitialized-local-cpp-aggregate-ctor-…
SizzleUnrlsd Mar 1, 2026
9c932c6
test(fixtures): add or update uninitialized-local-cpp-ctor-forgets-fi…
SizzleUnrlsd Mar 1, 2026
d1ce7ca
test(fixtures): add or update uninitialized-local-cpp-nested-aggregat…
SizzleUnrlsd Mar 1, 2026
3fd7efa
test(fixtures): add or update uninitialized-local-cpp-parameterized-c…
SizzleUnrlsd Mar 1, 2026
3d9f5dd
test(fixtures): add or update uninitialized-local-cpp-sret-complex-re…
SizzleUnrlsd Mar 1, 2026
244b4ff
chore(docs): remove obsolete PATCH.md
SizzleUnrlsd Mar 1, 2026
3cbb31d
ci(github-actions): optimize Linux/macOS pipeline with Ninja, ccache,…
SizzleUnrlsd Mar 1, 2026
9601b43
test(runner): optimize analyzer test runner with precompiled regex an…
SizzleUnrlsd Mar 1, 2026
07db5da
fix(ci): stabilize Linux analyzer test diagnostics across toolchains
SizzleUnrlsd Mar 1, 2026
fb5d874
chore(style): format code with clang-format
SizzleUnrlsd Mar 1, 2026
608bb51
fix(test-runner): enforce trailing --compile-arg overrides for determ…
SizzleUnrlsd Mar 1, 2026
09356a5
ci(tests): remove Linux-specific extra analyzer args from test run
SizzleUnrlsd Mar 3, 2026
0d39e45
build(docker): split image into base, dev, builder, and runtime stage…
SizzleUnrlsd Mar 3, 2026
1945fce
docs(readme): align Docker usage guide with multi-target Dockerfile a…
SizzleUnrlsd Mar 3, 2026
bd09a58
fix(diagnostics): classify implicit gets declaration as deprecated un…
SizzleUnrlsd Mar 3, 2026
18982a5
fix(integer-overflow): recognize LLVM mem intrinsics as size sinks
SizzleUnrlsd Mar 3, 2026
7e82209
fix(uninitialized): improve memtransfer initialization modeling and C…
SizzleUnrlsd Mar 3, 2026
6d2bb03
test(const-correctness): include stdint header for fixed-width intege…
SizzleUnrlsd Mar 3, 2026
29ec7ce
test(unsafe-functions): use clang pragma to downgrade implicit gets d…
SizzleUnrlsd Mar 3, 2026
d891388
chore(style): format code with clang-format
SizzleUnrlsd Mar 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 62 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- "**"
workflow_dispatch:

env:
CCACHE_DIR: ${{ github.workspace }}/.ccache

jobs:
build:
name: Build on ${{ matrix.os }}
Expand All @@ -22,15 +25,19 @@ jobs:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Shallow clone is enough for building. Steps that need history
# (changelog, merge-base) should override with their own fetch.
fetch-depth: 1

# Linux: install toolchain + accelerators
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake python3
sudo apt-get install -y build-essential cmake python3 \
ninja-build ccache lld
# Install LLVM and Clang 20
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main"
Expand All @@ -39,38 +46,75 @@ jobs:
echo "LLVM_DIR=/usr/lib/llvm-20/lib/cmake/llvm" >> $GITHUB_ENV
echo "Clang_DIR=/usr/lib/llvm-20/lib/cmake/clang" >> $GITHUB_ENV

# macOS: install toolchain
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake python llvm@20
brew install cmake python llvm@20 ninja ccache
echo "LLVM_DIR=$(brew --prefix llvm@20)/lib/cmake/llvm" >> $GITHUB_ENV
echo "Clang_DIR=$(brew --prefix llvm@20)/lib/cmake/clang" >> $GITHUB_ENV
echo "$(brew --prefix llvm@20)/bin" >> $GITHUB_PATH

- name: Configure via build.sh (quick)
# ccache: restore + configure
- name: Restore ccache
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ runner.os }}-${{ github.ref_name }}-${{ hashFiles('CMakeLists.txt', 'src/**', 'include/**') }}
restore-keys: |
ccache-${{ runner.os }}-${{ github.ref_name }}-
ccache-${{ runner.os }}-

- name: Configure ccache
run: |
./build.sh --build-dir build-script --type Release --configure-only
ccache --set-config=cache_dir=${{ env.CCACHE_DIR }}
ccache --set-config=max_size=500M
ccache --set-config=compression=true
ccache -z

- name: Configure and Build (Linux/macOS)
if: runner.os == 'Linux' || runner.os == 'macOS'
# FetchContent cache (sources only)
- name: Restore FetchContent sources
uses: actions/cache@v4
with:
path: |
build/_deps/cc-src
build/_deps/coretrace-logger-src
key: fetchcontent-${{ runner.os }}-llvm20-${{ hashFiles('CMakeLists.txt', 'cmake/**') }}
restore-keys: |
fetchcontent-${{ runner.os }}-llvm20-

# Configure
- name: Configure
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DLLVM_DIR=${{ env.LLVM_DIR }} \
-DClang_DIR=${{ env.Clang_DIR }} \
-DUSE_SHARED_LIB=OFF \
-DBUILD_TESTS=OFF
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_DIR=${{ env.LLVM_DIR }} \
-DClang_DIR=${{ env.Clang_DIR }} \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DUSE_SHARED_LIB=OFF \
-DBUILD_TESTS=OFF \
${{ runner.os == 'Linux' && '-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld' || '' }}

# Build
- name: Build
run: cmake --build build --config Release

cmake --build . --config Release
- name: Show ccache stats
if: always()
run: ccache -s

- name: Test Stack Usage Analyzer (Linux/macOS)
if: runner.os == 'Linux' || runner.os == 'macOS'
# Tests
- name: Test Stack Usage Analyzer
timeout-minutes: 45
run: |
TEST_JOBS="$(python3 -c 'import os; print(max(1, min(8, os.cpu_count() or 1)))')"
echo "Running run_test.py with ${TEST_JOBS} job(s)"
python3 -u run_test.py --jobs="${TEST_JOBS}"
EXTRA_ANALYZER_ARGS=""
CORETRACE_RUN_TEST_EXTRA_ANALYZER_ARGS="${EXTRA_ANALYZER_ARGS}" \
python3 -u run_test.py --jobs="${TEST_JOBS}"

# Self-analysis (Linux only)
- name: Self-analysis (analyze own source code)
if: runner.os == 'Linux'
run: |
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,20 @@ set(STACK_ANALYZER_SOURCES
src/analysis/AnalyzerUtils.cpp
src/analysis/CompileCommands.cpp
src/analysis/ConstParamAnalysis.cpp
src/analysis/CommandInjectionAnalysis.cpp
src/analysis/DuplicateIfCondition.cpp
src/analysis/DynamicAlloca.cpp
src/analysis/BufferWriteModel.cpp
src/analysis/FrontendDiagnostics.cpp
src/analysis/FunctionFilter.cpp
src/analysis/IRValueUtils.cpp
src/analysis/IntRanges.cpp
src/analysis/IntegerOverflowAnalysis.cpp
src/analysis/InputPipeline.cpp
src/analysis/InvalidBaseReconstruction.cpp
src/analysis/MemIntrinsicOverflow.cpp
src/analysis/NullDerefAnalysis.cpp
src/analysis/OOBReadAnalysis.cpp
src/analysis/ResourceLifetimeAnalysis.cpp
src/analysis/Reachability.cpp
src/analysis/SizeMinusKWrites.cpp
Expand All @@ -84,6 +90,8 @@ set(STACK_ANALYZER_SOURCES
src/analysis/StackPointerEscape.cpp
src/analysis/StackPointerEscapeModel.cpp
src/analysis/StackPointerEscapeResolver.cpp
src/analysis/TOCTOUAnalysis.cpp
src/analysis/TypeConfusionAnalysis.cpp
src/analysis/UninitializedVarAnalysis.cpp
src/report/ReportSerialization.cpp
src/mangle.cpp
Expand Down
72 changes: 49 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
# =============================================================================
# CoreTrace Stack Analyzer — Production Docker Image
# CoreTrace Stack Analyzer — Docker Image
# =============================================================================
# Multi-stage build: builds the analyzer, then creates a slim runtime image.
# This Dockerfile supports 3 user-facing targets:
# - dev:
# toolchain + repo checkout, no build; default command is an interactive shell.
# Use it to run cmake/build/tests manually.
# - builder:
# compiles the analyzer into /repo/build/stack_usage_analyzer.
# Use it in CI or to extract binaries/artifacts.
# - runtime:
# production image with analyzer + models + Docker entrypoint wrapper.
# Default workdir is /workspace and entrypoint auto-resolves compile_commands.json.
#
# Default runtime behavior (via entrypoint wrapper):
# - auto-detect /workspace/build/compile_commands.json (fallback: /workspace/compile_commands.json)
# - --analysis-profile=fast
# - --compdb-fast
# - --resource-summary-cache-memory-only
# - --resource-model=/models/resource-lifetime/generic.txt
# Typical commands:
# # 1) Dev mode (interactive)
# docker build --target dev -t coretrace-stack-analyzer:dev .
# docker run --rm -it -v "$PWD:/repo" -w /repo coretrace-stack-analyzer:dev
#
# Usage:
# docker build -t coretrace-stack-analyzer .
# docker run --rm -v $(pwd):/workspace coretrace-stack-analyzer
# # 2) Builder mode (compile artifacts)
# docker build --target builder -t coretrace-stack-analyzer:builder .
# docker create --name coretrace-builder coretrace-stack-analyzer:builder
# docker cp coretrace-builder:/repo/build/stack_usage_analyzer ./build/stack_usage_analyzer
# docker rm coretrace-builder
#
# Override defaults with explicit args:
# docker run --rm -v $(pwd):/workspace coretrace-stack-analyzer \
# --analysis-profile=full --resource-model=/models/resource-lifetime/generic.txt
#
# Bypass defaults completely:
# docker run --rm -v $(pwd):/workspace coretrace-stack-analyzer --raw --help
# # 3) Runtime mode (analyze project from compile_commands.json)
# docker build --target runtime -t coretrace-stack-analyzer:runtime .
# docker run --rm -v "$PWD:/workspace" coretrace-stack-analyzer:runtime
# # pass --raw to bypass wrapper defaults:
# docker run --rm -v "$PWD:/workspace" coretrace-stack-analyzer:runtime --raw --help
# =============================================================================

# ---------------------------------------------------------------------------
# Stage 1: Build
# Stage 0: Base (toolchain + build deps)
# ---------------------------------------------------------------------------
FROM ubuntu:24.04 AS builder
FROM ubuntu:24.04 AS base

ARG DEBIAN_FRONTEND=noninteractive
ARG LLVM_VERSION=20
Expand All @@ -52,6 +60,25 @@ RUN curl -fsSL https://apt.llvm.org/llvm.sh -o /tmp/llvm.sh \
&& apt-get install -y --no-install-recommends libclang-${LLVM_VERSION}-dev \
&& rm -rf /var/lib/apt/lists/*

# Make sure LLVM shared libs are found at runtime (useful for dev builds too)
ENV LD_LIBRARY_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib

# ---------------------------------------------------------------------------
# Stage 1: Dev (deps + repo, no build)
# ---------------------------------------------------------------------------
FROM base AS dev

WORKDIR /repo
COPY . /repo

# Default: interactive shell so you can build/test manually
CMD ["bash"]

# ---------------------------------------------------------------------------
# Stage 2: Build (produces binaries)
# ---------------------------------------------------------------------------
FROM base AS builder

WORKDIR /repo
COPY . /repo

Expand All @@ -65,14 +92,14 @@ RUN cmake -S . -B build -G Ninja \
&& cmake --build build -j"$(nproc)"

# ---------------------------------------------------------------------------
# Stage 2: Runtime (slim)
# Stage 3: Runtime (prod)
# ---------------------------------------------------------------------------
FROM ubuntu:24.04
FROM ubuntu:24.04 AS runtime

ARG DEBIAN_FRONTEND=noninteractive
ARG LLVM_VERSION=20

# Install only the runtime libraries needed by the analyzer binary
# Install only what is needed to run (and to support the entrypoint script)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
Expand All @@ -97,7 +124,6 @@ COPY --from=builder /repo/models /models

RUN chmod +x /usr/local/bin/coretrace-entrypoint.py

# Make sure the binary can find LLVM shared libs
ENV LD_LIBRARY_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib

WORKDIR /workspace
Expand Down
54 changes: 0 additions & 54 deletions PATCH.md

This file was deleted.

Loading
Loading