0

When my C++ application has access to the headers and libraries of a Clang/LLVM implementation, what is the proper, platform-invariant way of invoking that compiler through the API of headers.

I simply want to have compiler paths and intermediate code resolved and stored by the API, so that I don't have to manually provide compiler path, invocation flags and temporary storage.

So that instead of:

#include <system>
std::string compiler_absolute_path;
std::string source_file;
std::string header_dir;

int main()
{
    std::system(compiler_absolute_path + " " + ...);
}

I want something platform-invariant like this:

#include <ClangCompilerAPI>

std::string code_string;


int main()
{
    auto compiled_thing = ClangAPI::Compile(code_string, flags, options, ...)
    
    //Dynamically link to compiled_thing without having to mess with the filesystem ...
}

Do you know of where I can find the introductions to do this, alternatively how one should approach it in the least painful and most robust manner?

Under CMake, I have used the LLVM ORC which provides a JIT-API, but this seem to apply to LLVM-IR code.

Anon232
  • 3
  • 6

0 Answers0