Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
460fc97
Out-Of-Process on CppInterOp
Sep 20, 2025
72fee63
Fixing syntax error in CI
Sep 20, 2025
d77c457
Adding strne in debug flag
Sep 20, 2025
6742433
Creating Interpreter in Evaluate
Sep 20, 2025
6cf1da4
Creating Interpreter in Evaluate
Sep 20, 2025
7217df9
[experimental] removing evaluate test
Sep 20, 2025
334b02e
Fixing llvm 20 patch
kr-2003 Oct 1, 2025
3d9669d
Changed patch name
kr-2003 Oct 1, 2025
ab50e04
Changed patch name
kr-2003 Oct 1, 2025
c9a4426
Linting fix and patch name change
kr-2003 Oct 1, 2025
9e18da6
Changing llvm patch
kr-2003 Oct 1, 2025
748d7c0
OrcRuntime path hardcoding removed
kr-2003 Oct 2, 2025
bf2637e
Resolving comments and formatting
kr-2003 Oct 2, 2025
f06dcc8
Merge branch 'main' into cppinterop-out
kr-2003 Oct 2, 2025
9250d0f
Formatting
kr-2003 Oct 2, 2025
cfbb303
Formatting changes
kr-2003 Oct 2, 2025
b32b7b8
Refactoring StreamCaptureInfo, resolving comments
kr-2003 Oct 9, 2025
d57d112
Removing unnecessary windows section
kr-2003 Oct 9, 2025
b6177a8
resolving comments
kr-2003 Oct 10, 2025
85da62f
Formatting changes
kr-2003 Oct 10, 2025
f330c78
Formatting changes
kr-2003 Oct 10, 2025
a3fd0a9
Documentation change
kr-2003 Oct 10, 2025
609f7a4
Removing extra format changes
kr-2003 Oct 11, 2025
62443bb
Merge branch 'main' into cppinterop-out
kr-2003 Oct 11, 2025
18b5b3c
refactoring the StreamCaptureInfo
kr-2003 Oct 12, 2025
5621046
refactoring the StreamCaptureInfo, formatting
kr-2003 Oct 12, 2025
e2b35ec
using stringify macro
kr-2003 Oct 15, 2025
1d307ff
check introduced for redir. file
kr-2003 Oct 15, 2025
3580f96
Merge branch 'main' into cppinterop-out
kr-2003 Oct 15, 2025
8829b88
Resolving conflicts after thread-safety revert
kr-2003 Oct 15, 2025
02f0f4f
removing unused variable
kr-2003 Oct 15, 2025
5296a33
redirecting stderr
kr-2003 Oct 17, 2025
ad47408
passing by value instead of reference
kr-2003 Oct 17, 2025
f5f7fef
Error log update
kr-2003 Oct 17, 2025
30c89be
TestUtils refactoring, custom deleter removal
kr-2003 Oct 17, 2025
a4b186a
get in-process pid instead of 0
kr-2003 Oct 17, 2025
1e3fd0f
Removed pid test
kr-2003 Oct 17, 2025
eb34615
Disable DynamicLibTests for OOP
kr-2003 Oct 18, 2025
f047650
resolving comments
kr-2003 Oct 21, 2025
fdd3dfb
Parameterized Test fixtures
kr-2003 Oct 21, 2025
1a3d3d6
Parameterized Test fixtures
kr-2003 Oct 21, 2025
93c7441
Added constructors in TestConfig
kr-2003 Oct 21, 2025
6c26160
Changing test fixture to TypedTests
kr-2003 Oct 21, 2025
ee93b0e
ems test fix, dyn-lib-man test skip
kr-2003 Oct 22, 2025
7cb45d2
Disabled debugFlag test
kr-2003 Oct 22, 2025
dbb1cdc
Resolving comments
kr-2003 Oct 22, 2025
7765e67
outofprocess var resolution
kr-2003 Oct 22, 2025
a2a3dce
clang format
kr-2003 Oct 22, 2025
acf6ebf
[DO NOT MERGE] valgrind suppression file generation
kr-2003 Oct 22, 2025
94b9a8e
[DO NOT MERGE] valgrind suppression file generation
kr-2003 Oct 22, 2025
a615546
[DO NOT MERGE] valgrind suppression file generation
kr-2003 Oct 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/actions/Build_LLVM/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ runs:
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
ninja clingInterpreter -j ${{ env.ncpus }}
else
if [[ "${{ matrix.oop-jit }}" == "On" ]]; then
git apply -v ../patches/llvm/clang20-1-out-of-process.patch
echo "Apply clang20-1-out-of-process.patch:"
fi
cd build
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" \
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \
Expand All @@ -58,6 +62,14 @@ runs:
-DLLVM_INCLUDE_TESTS=OFF \
../llvm
ninja clang clangInterpreter clangStaticAnalyzerCore -j ${{ env.ncpus }}
if [[ "${{ matrix.oop-jit }}" == "On" ]]; then
if [[ "${{ matrix.os }}" == macos* ]]; then
SUFFIX="_osx"
elif [[ "${{ matrix.os }}" == ubuntu* ]]; then
SUFFIX="-x86_64"
fi
ninja llvm-jitlink-executor orc_rt${SUFFIX} -j ${{ env.ncpus }}
fi
cd ./tools/
rm -rf $(find . -maxdepth 1 ! -name "clang" ! -name ".")
cd ..
Expand Down
14 changes: 13 additions & 1 deletion .github/actions/Build_and_Test_CppInterOp/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 'Builds and test CppInterOp'
description: 'This action builds and tests CppInterOp for native platforms'

# REVERT BEFORE MERGING
runs:
using: composite
steps:
Expand Down Expand Up @@ -48,6 +49,7 @@ runs:
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
-DLLVM_ENABLE_WERROR=On \
-DLLVM_BUILT_WITH_OOP_JIT=${{ matrix.oop-jit }} \
../
fi
docs_on=$(echo "${{ matrix.documentation }}" | tr '[:lower:]' '[:upper:]')
Expand All @@ -58,7 +60,17 @@ runs:
cmake --build . --target check-cppinterop --parallel ${{ env.ncpus }}
os="${{ matrix.os }}"
if [[ "${os}" != "macos"* ]]; then
valgrind --show-error-list=yes --track-origins=yes --error-exitcode=1 unittests/CppInterOp/CppInterOpTests/unittests/bin/${{ env.BUILD_TYPE }}/CppInterOpTests
valgrind \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--gen-suppressions=all \
--log-fd=9 \
unittests/CppInterOp/CppInterOpTests/unittests/bin/${{ env.BUILD_TYPE }}/CppInterOpTests \
9>>memcheck.log

echo "======= Valgrind log (for suppression generation) ======="
cat memcheck.log
fi
fi
echo "CB_PYTHON_DIR=$CB_PYTHON_DIR" >> $GITHUB_ENV
Expand Down
57 changes: 39 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ jobs:
matrix:
include:
# Ubuntu Arm Jobs
- name: ubu22-arm-gcc12-clang-repl-20-coverage
os: ubuntu-22.04-arm
compiler: gcc-12
clang-runtime: '20'
cling: Off
cppyy: Off
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"
coverage: true
- name: ubu24-arm-gcc12-clang-repl-20
os: ubuntu-24.04-arm
compiler: gcc-12
Expand Down Expand Up @@ -66,6 +57,16 @@ jobs:
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"
# Ubuntu X86 Jobs
- name: ubu22-x86-gcc12-clang-repl-20-coverage
os: ubuntu-22.04
compiler: gcc-12
clang-runtime: '20'
cling: Off
cppyy: Off
llvm_enable_projects: "clang;compiler-rt"
llvm_targets_to_build: "host;NVPTX"
coverage: true
oop-jit: On
- name: ubu24-x86-gcc12-clang-repl-20
os: ubuntu-24.04
compiler: gcc-12
Expand All @@ -74,6 +75,15 @@ jobs:
cppyy: Off
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"
- name: ubu24-x86-gcc12-clang-repl-20-out-of-process
os: ubuntu-24.04
compiler: gcc-12
clang-runtime: '20'
cling: Off
cppyy: Off
llvm_enable_projects: "clang;compiler-rt"
llvm_targets_to_build: "host;NVPTX"
oop-jit: On
- name: ubu24-x86-gcc12-clang-repl-19-cppyy
os: ubuntu-24.04
compiler: gcc-12
Expand All @@ -100,6 +110,15 @@ jobs:
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"
# MacOS Arm Jobs
- name: osx15-arm-clang-clang-repl-20-out-of-process
os: macos-15
compiler: clang
clang-runtime: '20'
cling: Off
cppyy: Off
llvm_enable_projects: "clang;compiler-rt"
llvm_targets_to_build: "host"
oop-jit: On
- name: osx15-arm-clang-clang-repl-20
os: macos-15
compiler: clang
Expand Down Expand Up @@ -220,7 +239,7 @@ jobs:
path: |
llvm-project
${{ matrix.cling=='On' && 'cling' || '' }}
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' }}
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' }}${{ matrix.oop-jit == 'On' && '-oop' || '' }}

- name: Setup default Build Type
uses: ./.github/actions/Miscellaneous/Select_Default_Build_Type
Expand All @@ -236,14 +255,16 @@ jobs:
with:
cache-hit: ${{ steps.cache.outputs.cache-hit }}

- name: Cache LLVM-${{ matrix.clang-runtime }} and ${{ matrix.cling == 'On' && 'Cling' || 'Clang-REPL' }} build
uses: actions/cache/save@v4
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
with:
path: |
llvm-project
${{ matrix.cling=='On' && 'cling' || '' }}
key: ${{ steps.cache.outputs.cache-primary-key }}
# REVERT BEFORE MERGING
# - name: Cache LLVM-${{ matrix.clang-runtime }} and ${{ matrix.cling == 'On' && 'Cling' || 'Clang-REPL' }} build
# uses: actions/cache/save@v4
# if: ${{ steps.cache.outputs.cache-hit != 'true' }}
# with:
# path: |
# llvm-project
# ${{ matrix.cling=='On' && 'cling' || '' }}
# key: ${{ steps.cache.outputs.cache-primary-key }}
# REVERT BEFORE MERGING

- name: Setup code coverage
if: ${{ success() && (matrix.coverage == true) }}
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@ include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})

string(REGEX REPLACE "/lib/cmake/llvm$" "" LLVM_BUILD_LIB_DIR "${LLVM_DIR}")
add_definitions(-DLLVM_BUILD_LIB_DIR="${LLVM_BUILD_LIB_DIR}")

if(LLVM_BUILT_WITH_OOP_JIT)
if((CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") OR
(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64"))
add_definitions(-DLLVM_BUILT_WITH_OOP_JIT)
else()
message(FATAL_ERROR "LLVM_BUILT_WITH_OOP_JIT is only supported on Darwin arm64 or Linux x86_64. Build aborted.")
endif()
endif()

# If the llvm sources are present add them with higher priority.
if (LLVM_BUILD_MAIN_SRC_DIR)
# LLVM_INCLUDE_DIRS contains the include paths to both LLVM's source and
Expand Down
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.g
cd llvm-project
```

If you want to have out-of-process JIT execution enabled in CppInterOp, then apply this patch on Linux-x86_64 and MacOS-Darwin environment.
> Note that this patch will not work for Windows because out-of-process JIT execution is currently implemented for Linux-x86_64 and MacOS-Darwin only.

```bash
git apply -v ../CppInterOp/patches/llvm/clang20-1-out-of-process.patch
```

##### Build Clang-REPL

Clang-REPL is an interpreter that CppInterOp works alongside. Build Clang (and
Expand Down Expand Up @@ -140,6 +147,45 @@ export LLVM_DIR=$PWD
cd ../
```

##### Build Clang-REPL with Out-of-Process JIT Execution

To have ``Out-of-Process JIT Execution`` enabled, run following commands to build clang and clang-repl to support this feature:
> Only for Linux x86_64 and Macos amr64

```bash
mkdir build
cd build
cmake -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
../llvm
```

###### For Linux x86_64

```bash
cmake --build . --target clang clang-repl llvm-jitlink-executor orc_rt-x86_64 --parallel $(nproc --all)
```

###### For MacOS arm64

```bash
cmake --build . --target clang clang-repl llvm-jitlink-executor orc_rt_osx --parallel $(sysctl -n hw.ncpu)
```

Note the 'llvm-project' directory location by executing

```bash
cd ../
export LLVM_DIR=$PWD
cd ../
```

#### Environment variables

You will need to define the following environment variables for the build of CppInterOp and cppyy (as they clear for a new session, it is recommended that you also add these to your .bashrc in linux, .bash_profile if on MacOS). On Linux and MacOS you define as follows
Expand Down Expand Up @@ -167,6 +213,10 @@ cmake -DBUILD_SHARED_LIBS=ON -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off
cmake --build . --target install --parallel $(nproc --all)
```

and

> Do make sure to pass ``DLLVM_BUILT_WITH_OOP_JIT=ON``, if you want to have out-of-process JIT execution feature enabled.

#### Testing CppInterOp

To test the built CppInterOp execute the following command in the CppInterOP build folder on Linux and MacOS
Expand Down
41 changes: 41 additions & 0 deletions docs/DevelopersDocumentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ Clone the 20.x release of the LLVM project repository.
git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git
cd llvm-project

If you want to have out-of-process JIT execution enabled in CppInterOp, then apply this patch on Linux-x86_64 and MacOS-Darwin environment.
.. note::

This patch will not work for Windows because out-of-process JIT execution is currently implemented for Linux and MacOS only.

.. code:: bash

git apply -v ../CppInterOp/patches/llvm/clang20-1-out-of-process.patch

******************
Build Clang-REPL
******************
Expand Down Expand Up @@ -99,6 +108,34 @@ On Windows you execute the following
$env:LLVM_DIR= $PWD.Path
cd ..\

***************************************************
Build Clang-REPL with Out-of-Process JIT Execution
***************************************************

To have `Out-of-Process JIT Execution` enabled, run following commands to build clang and clang-repl to support this feature:

.. note::

Only for Linux x86_64 and Macos arm64

.. code:: bash
mkdir build
cd build
cmake -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
../llvm

# For Linux x86_64
cmake --build . --target clang clang-repl llvm-jitlink-executor orc_rt-x86_64 --parallel $(nproc --all)
# For MacOS arm64
cmake --build . --target clang clang-repl llvm-jitlink-executor orc_rt_osx --parallel $(sysctl -n hw.ncpu)

**************************************
Build Cling and related dependencies
**************************************
Expand Down Expand Up @@ -261,6 +298,10 @@ commands on Linux and MacOS
cmake -DBUILD_SHARED_LIBS=ON -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
cmake --build . --target install --parallel $(nproc --all)

.. note::

Do make sure to pass ``DLLVM_BUILT_WITH_OOP_JIT=ON``, if you want to have out-of-process JIT execution feature enabled.

and

.. code:: powershell
Expand Down
41 changes: 41 additions & 0 deletions docs/InstallationAndUsage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ Clone the 20.x release of the LLVM project repository.
git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git
cd llvm-project

If you want to have out-of-process JIT execution enabled in CppInterOp, then apply this patch on Linux-x86_64 and MacOS-Darwin environment.
.. note::

This patch will not work for Windows because out-of-process JIT execution is currently implemented for Linux and MacOS only.

.. code:: bash

git apply -v ../CppInterOp/patches/llvm/clang20-1-out-of-process.patch

******************
Build Clang-REPL
******************
Expand Down Expand Up @@ -99,6 +108,34 @@ On Windows you execute the following
$env:LLVM_DIR= $PWD.Path
cd ..\

***************************************************
Build Clang-REPL with Out-of-Process JIT Execution
***************************************************

To have `Out-of-Process JIT Execution` enabled, run following commands to build clang and clang-repl to support this feature:

.. note::

Only for Linux x86_64 and Macos arm64

.. code:: bash
mkdir build
cd build
cmake -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
../llvm

# For Linux x86_64
cmake --build . --target clang clang-repl llvm-jitlink-executor orc_rt-x86_64 --parallel $(nproc --all)
# For MacOS arm64
cmake --build . --target clang clang-repl llvm-jitlink-executor orc_rt_osx --parallel $(sysctl -n hw.ncpu)

**************************************
Build Cling and related dependencies
**************************************
Expand Down Expand Up @@ -263,6 +300,10 @@ commands on Linux and MacOS
cmake -DBUILD_SHARED_LIBS=ON -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
cmake --build . --target install --parallel $(nproc --all)

.. note::

Do make sure to pass ``DLLVM_BUILT_WITH_OOP_JIT=ON``, if you want to have out-of-process JIT execution feature enabled.

and

.. code:: powershell
Expand Down
7 changes: 7 additions & 0 deletions include/CppInterOp/CppInterOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <cstdint>
#include <set>
#include <string>
#include <sys/types.h>
#include <vector>

// The cross-platform CPPINTEROP_API macro definition
Expand Down Expand Up @@ -935,6 +936,12 @@ CPPINTEROP_API void CodeComplete(std::vector<std::string>& Results,
///\returns 0 on success, non-zero on failure.
CPPINTEROP_API int Undo(unsigned N = 1);

#ifndef _WIN32
/// Returns the process ID of the executor process.
/// \returns the PID of the executor process.
CPPINTEROP_API pid_t GetExecutorPID();
#endif

} // end namespace Cpp

#endif // CPPINTEROP_CPPINTEROP_H
Loading
Loading