Bootstrap CoreTrace tool aligned with coretrace-stack-analyzer conventions:
- CMake stack-style setup (
cmake_minimum_required(VERSION 3.21), LLVM version check). coretrace-compilerintegration viacmake/compiler/coretrace-compiler.cmake.- Public C++ API + CLI wrapper to compile source files to in-memory LLVM IR (
llorbc). - Consumer example in
extern-project/.
This repository currently provides a compilation bootstrap (source -> LLVM IR in memory).
It does not yet emit concurrency diagnostics. The analyzer logic will be layered on top of the
llvm::Module produced by the API.
The project intentionally depends on compilerlib (coretrace-compiler) as the compilation
backend, but this dependency is now isolated behind an internal backend interface:
- CLI/consumer layer: parse options, render diagnostics/errors.
InMemoryIRCompiler(orchestrator): validate request, choose format (ll|bc), map failures.CompileCommandBuilder: normalize/construct compile arguments.ICompilationBackend/CompilerLibBackend: invokecompilerlib(memory LL or file BC).IIRLoader/LLVMIRLoader: parse LLVM payloads (parseIR,parseBitcodeFile) intollvm::Module.- Future analyzer layer: consume
llvm::Moduleindependently from CLI/backend choices.
InMemoryIRCompiler keeps the same public compile(...) API and now also supports dependency
injection (backend/loader constructor) for architecture-level tests.
cmake -S . -B build-llvm20 \
-DLLVM_DIR=/opt/homebrew/opt/llvm@20/lib/cmake/llvm \
-DClang_DIR=/opt/homebrew/opt/llvm@20/lib/cmake/clang \
-DCLANG_EXECUTABLE=/opt/homebrew/opt/llvm@20/bin/clang \
-DCLANG_RESOURCE_DIR=/opt/homebrew/opt/llvm@20/lib/clang/20
cmake --build build-llvm20 -j4./build-llvm20/coretrace_concurrency_analyzer /tmp/sample.c --ir-format=ll
./build-llvm20/coretrace_concurrency_analyzer /tmp/sample.c --ir-format=bcOptions:
--ir-format=ll|bc--compile-arg=<arg>(repeatable)--instrument--verbose--to forward all trailing compiler args
extraCompileArgs are forwarded as raw compiler arguments to compilerlib::compile(...)
without sanitization. They are not shell-expanded by this tool, but they still influence
compilation behavior and file access done by the compiler toolchain.
Use this API/CLI only with trusted inputs, or implement an explicit allowlist in front of it for untrusted callers.
cmake -S extern-project -B extern-project/build-llvm20 \
-DLLVM_DIR=/opt/homebrew/opt/llvm@20/lib/cmake/llvm \
-DClang_DIR=/opt/homebrew/opt/llvm@20/lib/cmake/clang \
-DCLANG_EXECUTABLE=/opt/homebrew/opt/llvm@20/bin/clang \
-DCLANG_RESOURCE_DIR=/opt/homebrew/opt/llvm@20/lib/clang/20
cmake --build extern-project/build-llvm20 -j4
./extern-project/build-llvm20/concurrency_consumer /tmp/sample.c --ir-format=ll
./extern-project/build-llvm20/concurrency_consumer /tmp/sample.c --ir-format=bcconcurrency_consumer keeps backward compatibility with the legacy positional format (ll|bc) as second argument.
CompileResult now exposes a structured CompileError:
error.code: typedstd::error_codebacked byCompileErrc(coretrace_concurrency_error.hpp)error.phase: coarse pipeline stage (validate_input,build_command,backend_compile,ir_parse)error.message: contextual details (file path, parser diagnostics, backend details, ...)
Use formatCompileError(result.error) to render a stable CLI/log-friendly message.
Run the C++ test suite (unit + CLI integration) with CTest:
ctest --test-dir build --output-on-failureOptional Python integration tests:
python3 tests/integration/cli/test_analyzer.py
python3 -m pytest tests/integration/cli/test_human_output_golden.py
CORETRACE_ANALYZER_BIN=./build/coretrace_concurrency_analyzer \
python3 -m pytest tests/integration/cli/test_human_output_golden.py- Format:
./scripts/format.sh - Check:
./scripts/format-check.sh - Naming/style conventions: see
CONTRIBUTING.md - Fixture corpora under
tests/fixtures/are excluded from clang-format checks.
This project is licensed under the Apache License 2.0. See LICENSE and NOTICE.