如何在没有可执行调用的情况下通过API使用LLVM/Clang进行编译?

如何在没有可执行调用的情况下通过API使用LLVM/Clang进行编译?,clang,llvm,llvm-ir,Clang,Llvm,Llvm Ir,我想用LLVM/clangapi在我的演示应用程序中将源文件编译成LLVM-IR,而不调用Clang可执行文件。似乎驱动程序仍然使用可执行文件执行编译(我使用了稍微修改过的) 它真的需要clang路径吗?我如何通过LLVM/clang API编译LLVM IR,而无需执行调用?如果当前API无法使用它,我如何修改API以使用静态库而不是可执行文件?您可能需要查看根“Clang”项目,以了解JIT后端的Clang示例。我发现它确实使用了Clang开箱即用的可执行文件。cling是否在没有可执行调用

我想用LLVM/clangapi在我的演示应用程序中将源文件编译成LLVM-IR,而不调用
Clang
可执行文件。似乎
驱动程序
仍然使用可执行文件执行
编译
(我使用了稍微修改过的)


它真的需要clang路径吗?我如何通过LLVM/clang API编译LLVM IR,而无需执行调用?如果当前API无法使用它,我如何修改API以使用静态库而不是可执行文件?

您可能需要查看根“Clang”项目,以了解JIT后端的Clang示例。我发现它确实使用了
Clang
开箱即用的可执行文件。cling是否在没有可执行调用的情况下编译LLVM IR?
string clangPath = "clang";

string inputPath = "../test/hello_world.cpp";
string outputPath = "hello_world.ll";

// "clang -S -emit-llvm ../test/hello_world.cpp -v"
vector<const char *> args;
args.push_back(clangPath.c_str());
args.push_back("-S");
args.push_back("-emit-llvm");
args.push_back(inputPath.c_str());
args.push_back("-v");

// ...
MBA-Anton:build asmirnov$ ./clang_ir
Starting ----
making driver
making compilation
clang version 3.4 (branches/release_34 198679)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
printing actions:
0: input, "../test/hello_world.cpp", c++
1: preprocessor, {0}, c++-cpp-output
2: compiler, {1}, ir
3: bind-arch, "x86_64", {2}, ir
Done ----
 "clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-llvm -disable-free -main-file-name hello_world.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 224.1 -v -coverage-file /Users/asmirnov/Documents/dev/src/clang_jni/mac/build/hello_world.ll -resource-dir ../lib/clang/3.4 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/asmirnov/Documents/dev/src/clang_jni/mac/build -ferror-limit 19 -fmessage-length 100 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o hello_world.ll -x c++ ../test/hello_world.cpp
error: unable to execute command: Executable "clang" doesn't exist!