-
Notifications
You must be signed in to change notification settings - Fork 34
Out-Of-Process Interpreter for CppInterOp #717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kr-2003
wants to merge
16
commits into
compiler-research:main
Choose a base branch
from
kr-2003:cppinterop-out
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
460fc97
Out-Of-Process on CppInterOp
72fee63
Fixing syntax error in CI
d77c457
Adding strne in debug flag
6742433
Creating Interpreter in Evaluate
6cf1da4
Creating Interpreter in Evaluate
7217df9
[experimental] removing evaluate test
334b02e
Fixing llvm 20 patch
kr-2003 3d9669d
Changed patch name
kr-2003 ab50e04
Changed patch name
kr-2003 c9a4426
Linting fix and patch name change
kr-2003 9e18da6
Changing llvm patch
kr-2003 748d7c0
OrcRuntime path hardcoding removed
kr-2003 bf2637e
Resolving comments and formatting
kr-2003 f06dcc8
Merge branch 'main' into cppinterop-out
kr-2003 9250d0f
Formatting
kr-2003 cfbb303
Formatting changes
kr-2003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,4 +1,5 @@ | ||||
# CppInterOp | ||||
|
||||
<div align="center"> | ||||
|
||||
[](https://github.com/compiler-research/CppInterOp/actions/workflows/main.yml) | ||||
|
@@ -111,6 +112,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 and MacOS 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 | ||||
|
@@ -140,6 +148,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 | ||||
|
@@ -167,6 +214,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 | ||||
|
@@ -202,7 +253,7 @@ and clone cppyy-backend repository where we will be installing the CppInterOp li | |||
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git | ||||
``` | ||||
|
||||
#### Build Cling and related dependencies | ||||
### Build Cling and related dependencies | ||||
|
||||
The Cling interpreter and depends on its own customised version of `llvm-project`, | ||||
hosted under the `root-project` (see the git path below). | ||||
|
@@ -265,6 +316,23 @@ Now CppInterOp can be built. This can be done by executing | |||
```bash | ||||
mkdir CppInterOp/build/ | ||||
cd CppInterOp/build/ | ||||
``` | ||||
|
||||
On Windows execute | ||||
|
||||
```powershell | ||||
mkdir CppInterOp\build\ | ||||
cd CppInterOp\build\ | ||||
``` | ||||
|
||||
```powershell | ||||
cmake -DLLVM_DIR=$env:LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$env:LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR .. | ||||
cmake --build . --target install --parallel $env:ncpus | ||||
``` | ||||
|
||||
on Windows. If alternatively you would like to install CppInterOp with Cling then execute the following commands on Linux and MacOS. | ||||
|
||||
```bash | ||||
Comment on lines
+319
to
+335
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this added Windows related text. It makes 0 sense. This is not in the Windows section, and is text that is already contained in the readme in the Windows section Line 388 in fe3de3c
|
||||
cmake -DBUILD_SHARED_LIBS=ON -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -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) | ||||
``` | ||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.