Skip to content

Commit 0153cbc

Browse files
author
kr-2003
committed
env var for oop jit in cppinterop
1 parent 17bd8ec commit 0153cbc

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

.github/actions/Build_and_Test_CppInterOp/action.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,29 @@ runs:
4040
-DLLVM_ENABLE_WERROR=On \
4141
../
4242
else
43-
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
43+
if [[ "${{ matrix.llvm_enable_runtimes }}" == "clang;compile-rt" ]]; then
44+
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
4445
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
4546
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
4647
-DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \
4748
-DBUILD_SHARED_LIBS=ON \
4849
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
4950
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
5051
-DLLVM_ENABLE_WERROR=On \
52+
-DCPPINTEROP_WITH_OOP_JIT=ON \
5153
../
54+
else
55+
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
56+
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
57+
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
58+
-DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \
59+
-DBUILD_SHARED_LIBS=ON \
60+
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
61+
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
62+
-DLLVM_ENABLE_WERROR=On \
63+
-DCPPINTEROP_WITH_OOP_JIT=OFF \
64+
../
65+
fi
5266
fi
5367
docs_on=$(echo "${{ matrix.documentation }}" | tr '[:lower:]' '[:upper:]')
5468
if [[ "${docs_on}" == "ON" ]]; then

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ else()
305305
message(FATAL_ERROR "We need either CPPINTEROP_USE_CLING or CPPINTEROP_USE_REPL")
306306
endif()
307307

308+
if(CPPINTEROP_WITH_OOP_JIT)
309+
add_definitions(-DCPPINTEROP_WITH_OOP_JIT)
310+
endif()
311+
308312
string(REGEX REPLACE "/build/lib/cmake/llvm$" "" LLVM_SOURCE_DIR "${LLVM_DIR}")
309313
add_definitions(-DLLVM_SOURCE_DIR="${LLVM_SOURCE_DIR}")
310314

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ cmake -DBUILD_SHARED_LIBS=ON -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_D
360360
cmake --build . --target install --parallel $(nproc --all)
361361
```
362362
363+
> Do make sure to add ``-DCPPINTEROP_WITH_OOP_JIT=ON``, if you want to have out-of-process JIT execution feature enabled.
364+
363365
and
364366
365367
```powershell

lib/CppInterOp/Compatibility.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,14 @@ inline void codeComplete(std::vector<std::string>& Results,
201201

202202
#include "llvm/Support/Error.h"
203203

204+
#ifdef CPPINTEROP_WITH_OOP_JIT
204205
#include "clang/Interpreter/RemoteJITUtils.h"
205206
#include "clang/Basic/Version.h"
206207
#include "llvm/TargetParser/Host.h"
207208

208209
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
210+
#endif
209211

210-
#include "llvm/Support/CommandLine.h"
211212

212213
static llvm::ExitOnError ExitOnError;
213214

@@ -253,6 +254,7 @@ createClangInterpreter(std::vector<const char*>& args, bool outOfProcess) {
253254
if (CudaEnabled)
254255
DeviceCI->LoadRequestedPlugins();
255256

257+
#ifdef CPPINTEROP_WITH_OOP_JIT
256258
std::unique_ptr<llvm::orc::LLJITBuilder> JB;
257259

258260
if(outOfProcess) {
@@ -277,6 +279,17 @@ createClangInterpreter(std::vector<const char*>& args, bool outOfProcess) {
277279
CudaEnabled ? clang::Interpreter::createWithCUDA(std::move(*ciOrErr),
278280
std::move(DeviceCI))
279281
: clang::Interpreter::create(std::move(*ciOrErr), std::move(JB));
282+
#else
283+
if(outOfProcess) {
284+
llvm::errs() << "[CreateClangInterpreter]: No compatibility with out-of-process JIT"
285+
<< "\n";
286+
return nullptr;
287+
}
288+
auto innerOrErr =
289+
CudaEnabled ? clang::Interpreter::createWithCUDA(std::move(*ciOrErr),
290+
std::move(DeviceCI))
291+
: clang::Interpreter::create(std::move(*ciOrErr));
292+
#endif
280293

281294
if (!innerOrErr) {
282295
llvm::logAllUnhandledErrors(innerOrErr.takeError(), llvm::errs(),

0 commit comments

Comments
 (0)