-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
Hugo edited this page Feb 26, 2026
·
1 revision
CoreTrace Compiler is structured as a thin CLI layer over a reusable compilation library. The design goal is fidelity to Clang driver behavior while allowing controlled in-process interception for instrumentation.
| Component | Location | Responsibility |
|---|---|---|
| CLI parsing | src/cli/ |
Parse --help, --instrument, --in-mem; forward the rest |
| Compile orchestration | src/compilerlib/compiler.cpp |
Build args, create driver, execute jobs |
| Toolchain resolution | src/compilerlib/toolchain.cpp |
Resolve clang path, resource dir, sysroot, C++ mode |
| Instrumentation passes | src/compilerlib/instrumentation/ |
Transform LLVM modules |
| Frontend customization | src/compilerlib/frontend/ |
OptNoneAction wrapper |
| Runtime library | src/runtime/ |
Implement __ct_* runtime hooks |
ArgBuilder:
- extracts runtime config from
--ct-*flags, - normalizes
-o=/-x=syntax, - resolves toolchain and injects
-resource-dir/-isysrootwhen needed, - appends runtime library and platform link flags for instrumented link jobs.
DriverSession builds a Clang Compilation, then CoreTrace splits jobs into:
-
cc1jobs - non-
cc1jobs (assembler/linker/etc.)
- Fast path: non-instrumented
ToFileand no--ct-optnone- delegates directly to
Driver::ExecuteCompilation.
- delegates directly to
- Managed path: instrumentation,
ToMemory, or optnone injection- runs
cc1jobs in-process (Cc1Runner), - runs non-
cc1jobs viaLinker.
- runs
- Driver fidelity: still uses Clang driver for job planning and most execution decisions.
- Controlled interception: only
cc1is intercepted when needed. - Separation of concerns:
- toolchain detection is isolated,
- argument shaping is centralized,
- runtime behavior is configured through explicit globals/env.
| Type | Purpose |
|---|---|
CompileContext |
Per-invocation state container |
RuntimeConfig |
Parsed --ct-* behavior flags |
DriverConfig |
Resolved toolchain settings |
JobPlan |
Split of cc1 vs other driver jobs |
| Target | Type | Notes |
|---|---|---|
cc |
executable | CLI binary |
compilerlib_static |
static lib | recommended embedding target |
compilerlib_shared |
shared lib | optional embedding target |
ct_instrument_runtime |
static lib | linked into instrumented outputs |
Start
Architecture
Instrumentation
Developer