-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
Hugo edited this page Feb 26, 2026
·
1 revision
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 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
Developer