Skip to content

Commit af3b295

Browse files
author
kr-2003
committed
addition of oop jit execution
1 parent 0153cbc commit af3b295

File tree

9 files changed

+61
-6
lines changed

9 files changed

+61
-6
lines changed

.github/actions/Build_LLVM/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ runs:
6868
-DLLVM_INCLUDE_TESTS=OFF \
6969
../llvm
7070
ninja clang clangInterpreter clangStaticAnalyzerCore -j ${{ env.ncpus }}
71-
if [[ "${{ matrix.llvm_enable_runtimes }}" == "clang;compile-rt" ]]; then
71+
if [[ "${{ matrix.oop-jit }}" == "On" ]]; then
7272
if [[ "${{ runner.os }}" == "Linux" ]]; then
7373
ninja clang clang-repl llvm-jitlink-executor orc_rt -j $(nproc --all)
7474
elif [[ "${{ runner.os }}" == "macOS" ]]; then

.github/actions/Build_and_Test_CppInterOp/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ runs:
4040
-DLLVM_ENABLE_WERROR=On \
4141
../
4242
else
43-
if [[ "${{ matrix.llvm_enable_runtimes }}" == "clang;compile-rt" ]]; then
43+
if [[ "${{ matrix.oop-jit }}" == "On" ]]; then
4444
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
4545
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
4646
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \

.github/workflows/MacOS-arm.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
cppyy: Off
3131
llvm_enable_projects: "clang;compiler-rt"
3232
llvm_targets_to_build: "host"
33+
oop-jit: On
3334
- name: osx15-arm-clang-clang-repl-19-cppyy
3435
os: macos-15
3536
compiler: clang
@@ -38,6 +39,7 @@ jobs:
3839
cppyy: On
3940
llvm_enable_projects: "clang"
4041
llvm_targets_to_build: "host"
42+
oop-jit: Off
4143
- name: osx15-arm-clang-clang-repl-18-cppyy
4244
os: macos-15
4345
compiler: clang
@@ -46,6 +48,7 @@ jobs:
4648
cppyy: On
4749
llvm_enable_projects: "clang"
4850
llvm_targets_to_build: "host"
51+
oop-jit: Off
4952
- name: osx15-arm-clang-clang-repl-17-cppyy
5053
os: macos-15
5154
compiler: clang
@@ -54,6 +57,7 @@ jobs:
5457
cppyy: On
5558
llvm_enable_projects: "clang"
5659
llvm_targets_to_build: "host"
60+
oop-jit: Off
5761
- name: osx15-arm-clang-clang-repl-16
5862
os: macos-15
5963
compiler: clang
@@ -62,6 +66,7 @@ jobs:
6266
cppyy: Off
6367
llvm_enable_projects: "clang"
6468
llvm_targets_to_build: "host"
69+
oop-jit: Off
6570
- name: osx15-arm-clang-clang18-cling-cppyy
6671
os: macos-15
6772
compiler: clang
@@ -71,6 +76,7 @@ jobs:
7176
cling-version: '1.2'
7277
llvm_enable_projects: "clang"
7378
llvm_targets_to_build: "host;NVPTX"
79+
oop-jit: Off
7480

7581
steps:
7682
- uses: actions/checkout@v4
@@ -109,7 +115,7 @@ jobs:
109115
path: |
110116
llvm-project
111117
${{ matrix.cling=='On' && 'cling' || '' }}
112-
key: v1-${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}
118+
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}
113119

114120
- name: Setup default Build Type
115121
run: |

.github/workflows/MacOS.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
cppyy: Off
3131
llvm_enable_projects: "clang;compiler-rt"
3232
llvm_targets_to_build: "host"
33+
oop-jit: On
3334
- name: osx13-x86-clang-clang-repl-19-cppyy
3435
os: macos-13
3536
compiler: clang
@@ -38,6 +39,7 @@ jobs:
3839
cppyy: On
3940
llvm_enable_projects: "clang"
4041
llvm_targets_to_build: "host"
42+
oop-jit: Off
4143
- name: osx13-x86-clang-clang-repl-18-cppyy
4244
os: macos-13
4345
compiler: clang
@@ -46,6 +48,7 @@ jobs:
4648
cppyy: On
4749
llvm_enable_projects: "clang"
4850
llvm_targets_to_build: "host"
51+
oop-jit: Off
4952
- name: osx13-x86-clang-clang-repl-17-cppyy
5053
os: macos-13
5154
compiler: clang
@@ -54,13 +57,15 @@ jobs:
5457
cppyy: On
5558
llvm_enable_projects: "clang"
5659
llvm_targets_to_build: "host"
60+
oop-jit: Off
5761
- name: osx13-x86-clang-clang-repl-16
5862
os: macos-13
5963
compiler: clang
6064
clang-runtime: '16'
6165
cling: Off
6266
llvm_enable_projects: "clang"
6367
llvm_targets_to_build: "host"
68+
oop-jit: Off
6469
- name: osx13-x86-clang-clang18-cling-cppyy
6570
os: macos-13
6671
compiler: clang
@@ -70,6 +75,7 @@ jobs:
7075
cling-version: '1.2'
7176
llvm_enable_projects: "clang"
7277
llvm_targets_to_build: "host;NVPTX"
78+
oop-jit: Off
7379

7480
steps:
7581
- uses: actions/checkout@v4

.github/workflows/Ubuntu-arm.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
llvm_enable_projects: "clang;compiler-rt"
3232
llvm_targets_to_build: "host;NVPTX"
3333
coverage: true
34+
oop-jit: On
3435
- name: ubu24-arm-gcc12-clang-repl-20
3536
os: ubuntu-24.04-arm
3637
compiler: gcc-12
@@ -39,6 +40,7 @@ jobs:
3940
cppyy: Off
4041
llvm_enable_projects: "clang"
4142
llvm_targets_to_build: "host;NVPTX"
43+
oop-jit: Off
4244
- name: ubu24-arm-gcc12-clang-repl-19-cppyy
4345
os: ubuntu-24.04-arm
4446
compiler: gcc-12
@@ -47,6 +49,7 @@ jobs:
4749
cppyy: On
4850
llvm_enable_projects: "clang"
4951
llvm_targets_to_build: "host;NVPTX"
52+
oop-jit: Off
5053
- name: ubu24-arm-gcc12-clang-repl-18-cppyy
5154
os: ubuntu-24.04-arm
5255
compiler: gcc-12
@@ -55,6 +58,7 @@ jobs:
5558
cppyy: On
5659
llvm_enable_projects: "clang"
5760
llvm_targets_to_build: "host;NVPTX"
61+
oop-jit: Off
5862
- name: ubu24-arm-gcc12-clang-repl-17-cppyy
5963
os: ubuntu-24.04-arm
6064
compiler: gcc-12
@@ -63,6 +67,7 @@ jobs:
6367
cppyy: On
6468
llvm_enable_projects: "clang"
6569
llvm_targets_to_build: "host;NVPTX"
70+
oop-jit: Off
6671
- name: ubu24-arm-gcc12-clang-repl-16
6772
os: ubuntu-24.04-arm
6873
compiler: gcc-12
@@ -71,6 +76,7 @@ jobs:
7176
cppyy: Off
7277
llvm_enable_projects: "clang"
7378
llvm_targets_to_build: "host;NVPTX"
79+
oop-jit: Off
7480
- name: ubu24-arm-gcc9-clang18-cling-cppyy
7581
os: ubuntu-24.04-arm
7682
compiler: gcc-9
@@ -80,6 +86,7 @@ jobs:
8086
cling-version: '1.2'
8187
llvm_enable_projects: "clang"
8288
llvm_targets_to_build: "host;NVPTX"
89+
oop-jit: Off
8390

8491
steps:
8592
- uses: actions/checkout@v4

.github/workflows/Ubuntu.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
cppyy: Off
3131
llvm_enable_projects: "clang;compiler-rt"
3232
llvm_targets_to_build: "host;NVPTX"
33+
oop-jit: On
3334
- name: ubu24-x86-gcc12-clang-repl-19-cppyy
3435
os: ubuntu-24.04
3536
compiler: gcc-12
@@ -38,6 +39,7 @@ jobs:
3839
cppyy: On
3940
llvm_enable_projects: "clang"
4041
llvm_targets_to_build: "host;NVPTX"
42+
oop-jit: Off
4143
- name: ubu24-x86-gcc12-clang-repl-18-cppyy
4244
os: ubuntu-24.04
4345
compiler: gcc-12
@@ -46,6 +48,7 @@ jobs:
4648
cppyy: On
4749
llvm_enable_projects: "clang"
4850
llvm_targets_to_build: "host;NVPTX"
51+
oop-jit: Off
4952
- name: ubu24-x86-gcc12-clang-repl-17-cppyy
5053
os: ubuntu-24.04
5154
compiler: gcc-12
@@ -54,6 +57,7 @@ jobs:
5457
cppyy: On
5558
llvm_enable_projects: "clang"
5659
llvm_targets_to_build: "host;NVPTX"
60+
oop-jit: Off
5761
- name: ubu24-x86-gcc12-clang-repl-16
5862
os: ubuntu-24.04
5963
compiler: gcc-12
@@ -62,6 +66,7 @@ jobs:
6266
cppyy: Off
6367
llvm_enable_projects: "clang"
6468
llvm_targets_to_build: "host;NVPTX"
69+
oop-jit: Off
6570
- name: ubu24-x86-gcc9-clang18-cling-cppyy
6671
os: ubuntu-24.04
6772
compiler: gcc-9
@@ -71,6 +76,7 @@ jobs:
7176
cling-version: '1.2'
7277
llvm_enable_projects: "clang"
7378
llvm_targets_to_build: "host;NVPTX"
79+
oop-jit: Off
7480

7581
steps:
7682
- uses: actions/checkout@v4

lib/CppInterOp/Compatibility.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,11 @@ createClangInterpreter(std::vector<const char*>& args, bool outOfProcess) {
265265
EPC = ExitOnError(
266266
launchExecutor(OOPExecutor, UseSharedMemory, SlabAllocateSizeString));
267267

268-
269-
std::string OrcRuntimePath = std::string(LLVM_SOURCE_DIR) + "/build/lib/clang/20/lib/darwin/liborc_rt_osx.a";
268+
#ifdef __APPLE__
269+
std::string OrcRuntimePath = std::string(LLVM_SOURCE_DIR) + "/build/lib/clang/20/lib/darwin/liborc_rt_osx.a";
270+
#else
271+
std::string OrcRuntimePath = std::string(LLVM_SOURCE_DIR) + "/build/lib/x86_64-unknown-linux-gnu/liborc_rt.a";
272+
#endif
270273
if (EPC) {
271274

272275
CB.SetTargetTriple(EPC->getTargetTriple().getTriple());

unittests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ endfunction()
5151

5252
add_subdirectory(CppInterOp)
5353

54-
add_custom_target(check-cppinterop COMMAND ${CMAKE_CTEST_COMMAND} -V
54+
add_custom_target(check-cppinterop COMMAND ${CMAKE_CTEST_COMMAND} -V --build-config $<CONFIG>
5555
DEPENDS CppInterOpUnitTests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
5656

5757
set_target_properties(check-cppinterop PROPERTIES FOLDER "CppInterOp tests")

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,33 @@ TEST(InterpreterTest, Process) {
146146
clang_Interpreter_dispose(CXI);
147147
}
148148

149+
#ifdef CPPINTEROP_WITH_OOP_JIT
150+
TEST(InterpreterTest, OopJITProcess) {
151+
#ifdef _WIN32
152+
GTEST_SKIP() << "Disabled on Windows. Needs fixing.";
153+
#endif
154+
if (llvm::sys::RunningOnValgrind())
155+
GTEST_SKIP() << "XFAIL due to Valgrind report";
156+
std::vector<const char*> interpreter_args = { "-include", "new" };
157+
auto* I = Cpp::CreateInterpreter(interpreter_args, {}, true);
158+
EXPECT_TRUE(Cpp::Process("") == 0);
159+
EXPECT_TRUE(Cpp::Process("int a = 12;") == 0);
160+
EXPECT_FALSE(Cpp::Process("error_here;") == 0);
161+
// Linker/JIT error.
162+
EXPECT_FALSE(Cpp::Process("int f(); int res = f();") == 0);
163+
164+
// C API
165+
auto* CXI = clang_createInterpreterFromRawPtr(I);
166+
clang_Interpreter_declare(CXI, "#include <iostream>", false);
167+
clang_Interpreter_process(CXI, "int c = 42;");
168+
auto* CXV = clang_createValue();
169+
auto Res = clang_Interpreter_evaluate(CXI, "c", CXV);
170+
EXPECT_EQ(Res, CXError_Success);
171+
clang_Value_dispose(CXV);
172+
clang_Interpreter_dispose(CXI);
173+
}
174+
#endif
175+
149176
TEST(InterpreterTest, EmscriptenExceptionHandling) {
150177
#ifndef EMSCRIPTEN
151178
GTEST_SKIP() << "This test is intended to check exception handling for Emscripten builds.";

0 commit comments

Comments
 (0)