Repository navigation
API Reference
Public headers are under include/compilerlib/.
enum class OutputMode
{
ToFile,
ToMemory,
};struct CompileResult
{
bool success;
std::string diagnostics;
std::string llvmIR;
};CompileResult compile(
const std::vector<std::string>& args,
OutputMode mode = OutputMode::ToFile,
bool instrument = false
);Behavior summary:
-
ToFile: compile/link outputs on disk -
ToMemory: return LLVM IR inCompileResult::llvmIR(single-job constraint) -
instrument=true: run instrumentation pipeline and runtime linking for link jobs
int compile_c(int argc, const char** argv, char* output_buffer, int buffer_size);Notes:
- Parses
--in-memand--instrumentsimilarly to CLI. - Writes diagnostics text into
output_buffer. - Returns
1on success,0on failure.
struct DriverConfig
{
std::string clang_path;
std::string resource_dir;
std::string sysroot;
bool add_resource_dir = false;
bool add_sysroot = false;
bool force_cxx_driver = false;
};bool resolveDriverConfig(
const std::vector<std::string>& args,
DriverConfig& out,
std::string& error
);Use this when embedding and you need toolchain decisions independent of full compile execution.
struct RuntimeArchives
{
std::string runtime; // libct_instrument_runtime
std::string logger; // libcoretrace_logger
};
bool resolveRuntimeArchives(RuntimeArchives& out, std::string& error);Locates the instrumentation runtime archives linked into instrumented programs. This is what makes an installed prefix relocatable: nothing is baked in as an absolute path.
Search order:
CT_RUNTIME_LIB_DIR-
<executable dir>/../lib— the installed layout - the executable's own directory
- the build-tree paths recorded at configure time
A directory is accepted only when it holds both archives. A directory with just one is
skipped rather than half-used, which is what turns a partial install into a clear
instrumentation runtime archives not found instead of a confusing link error.
With -DCORETRACE_COMPILER_BUILD_RUNTIME=OFF no archive is built or installed, so only step 1
can succeed — see Runtime Library.
struct RuntimeConfig
{
bool shadow_enabled = false;
bool shadow_aggressive = false;
bool bounds_no_abort = false;
bool trace_enabled = true;
bool alloc_enabled = true;
bool bounds_enabled = true;
bool vtable_enabled = false;
bool vcall_trace_enabled = false;
bool vtable_diag_enabled = false;
bool autofree_enabled = false;
bool alloc_trace_enabled = true;
bool bounds_without_alloc = false;
bool optnone_enabled = false;
};void extractRuntimeConfig(
const std::vector<std::string>& input,
std::vector<std::string>& filtered,
RuntimeConfig& config
);- consumes/removes
--ct-*options fromfiltered - fills
configwith effective runtime/instrumentation behavior
void emitRuntimeConfigGlobals(llvm::Module& module, const RuntimeConfig& config);Emits weak globals consumed by runtime startup (ct_runtime_env.cpp).
target_link_libraries(my_app PRIVATE cc::compilerlib_static)
# or
target_link_libraries(my_app PRIVATE cc::compilerlib_shared)See Integration Guide for full setup.
Start
Architecture
Instrumentation
Platforms
Developer