diff --git a/.github/workflows/markdown-linter.yml b/.github/workflows/markdown-linter.yml index 539f8845d..66133c3c7 100644 --- a/.github/workflows/markdown-linter.yml +++ b/.github/workflows/markdown-linter.yml @@ -36,4 +36,5 @@ jobs: VALIDATE_ALL_CODEBASE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_MARKDOWN: true - DEFAULT_BRANCH: ${{ github.base_ref }} \ No newline at end of file + DEFAULT_BRANCH: ${{ github.base_ref }} + MARKDOWN_LINT_CONFIG_FILE: .markdownlint.json diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 000000000..c40ca334b --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,3 @@ +{ + "no-duplicate-heading": false +} diff --git a/README.md b/README.md index 02d9fd923..8a774b2f7 100644 --- a/README.md +++ b/README.md @@ -82,9 +82,12 @@ adding speed and resilience with it. Build instructions for CppInterOp and its dependencies are as follows. CppInterOP can be built with either Cling and Clang-REPL, so instructions will differ slightly depending on which option you would like to build, but should be clear from the section title which instructions to follow. +
+Linux/MacOS + #### Clone CppInterOp and cppyy-backend -First clone the CppInterOp repository, as this contains patches that need to be applied to the subsequently cloned llvm-project repo (these patches are only applied if building CppInterOp with Clang-REPL) +First clone the CppInterOp repository, as this may contain patches that need to be applied to the subsequently cloned llvm-project repo (these patches are only applied if building CppInterOp with Clang-REPL) ```bash git clone --depth=1 https://github.com/compiler-research/CppInterOp.git @@ -108,7 +111,7 @@ cd llvm-project ##### Build Clang-REPL Clang-REPL is an interpreter that CppInterOp works alongside. Build Clang (and -Clang-REPL along with it). On Linux and MacOS you do this by executing the following +Clang-REPL along with it) by executing command ```bash @@ -126,25 +129,7 @@ cmake -DLLVM_ENABLE_PROJECTS=clang \ cmake --build . --target clang clang-repl --parallel $(nproc --all) ``` -On Windows you would do this by executing the following - -```powershell -$env:ncpus = $([Environment]::ProcessorCount) -mkdir build -cd build -cmake -DLLVM_ENABLE_PROJECTS=clang ` - -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 - cmake --build . --target clang clang-repl --parallel $env:ncpus -``` - -Note the 'llvm-project' directory location. On linux and MacOS you execute the following +Note the 'llvm-project' directory location by executing ```bash cd ../ @@ -152,20 +137,12 @@ export LLVM_DIR=$PWD cd ../ ``` -On Windows you execute the following - -```powershell -cd ..\ -$env:LLVM_DIR= $PWD.Path -cd ..\ -``` - #### Build Cling and related dependencies Besides the Clang-REPL interpreter, CppInterOp also works alongside the Cling interpreter. Cling depends on its own customised version of `llvm-project`, hosted under the `root-project` (see the git path below). -Use the following build instructions to build on Linux and MacOS +Use the following build instructions to build ```bash git clone https://github.com/root-project/cling.git @@ -179,7 +156,7 @@ cd llvm-project/build cmake -DLLVM_ENABLE_PROJECTS=clang \ -DLLVM_EXTERNAL_PROJECTS=cling \ -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \ - -DLLVM_TARGETS_TO_BUILD="host;NVPTX" \ + -DLLVM_TARGETS_TO_BUILD="host;NVPTX" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ @@ -191,36 +168,7 @@ cmake --build . --target clang --parallel $(nproc --all) cmake --build . --target cling --parallel $(nproc --all) ``` -Use the following build instructions to build on Windows - -```powershell -git clone https://github.com/root-project/cling.git -cd .\cling\ -git checkout tags/v1.2 -git apply -v ..\CppInterOp\patches\llvm\cling1.2-LookupHelper.patch -cd .. -git clone --depth=1 -b cling-llvm18 https://github.com/root-project/llvm-project.git -$env:ncpus = $([Environment]::ProcessorCount) -$env:PWD_DIR= $PWD.Path -$env:CLING_DIR="$env:PWD_DIR\cling" -mkdir llvm-project\build -cd llvm-project\build -cmake -DLLVM_ENABLE_PROJECTS=clang ` - -DLLVM_EXTERNAL_PROJECTS=cling ` - -DLLVM_EXTERNAL_CLING_SOURCE_DIR="$env:CLING_DIR" ` - -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 -cmake --build . --target clang --parallel $env:ncpus -cmake --build . --target cling --parallel $env:ncpus -``` - -Note the 'llvm-project' directory location. On linux and MacOS you execute the following +Note the 'llvm-project' directory location by executing the following ```bash cd ../ @@ -228,17 +176,9 @@ export LLVM_DIR=$PWD cd ../ ``` -On Windows you execute the following - -```powershell -cd ..\ -$env:LLVM_DIR= $PWD.Path -cd ..\ -``` - #### Environment variables -Regardless of whether you are building CppInterOP with Cling or Clang-REPL you will need to define the following environment variables (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, or profile.ps1 on Windows). On Linux and MacOS you define as follows +Regardless of whether you are building CppInterOP with Cling or Clang-REPL you will need to define the following environment variables (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 ```bash export CB_PYTHON_DIR="$PWD/cppyy-backend/python" @@ -265,73 +205,29 @@ If on MacOS you will also need the following environment variable defined export SDKROOT=`xcrun --show-sdk-path` ``` -On Windows you define as follows (assumes you have defined $env:PWD_DIR= $PWD.Path ) - -```powershell -$env:CB_PYTHON_DIR="$env:PWD_DIR\cppyy-backend\python" -$env:CPPINTEROP_DIR="$env:CB_PYTHON_DIR\cppyy_backend" -``` - -If building against clang-repl you will have the following defined - -```powershell -$env:CPLUS_INCLUDE_PATH="$env:CPLUS_INCLUDE_PATH;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_DIR\build\include;$env:LLVM_DIR\build\tools\clang\include" -``` - -and if building against cling - -```powershell -$env:CLING_DIR="$env:PWD_DIR\cling" -$env:CLING_BUILD_DIR="$env:PWD_DIR\cling\build" -$env:CPLUS_INCLUDE_PATH="$env:CLING_DIR\tools\cling\include;$env:CLING_BUILD_DIR\include;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include;" -``` - #### Build CppInterOp -Now CppInterOp can be installed. On Linux and MacOS execute +Now CppInterOp can be installed. Start by executing ```bash mkdir CppInterOp/build/ cd CppInterOp/build/ ``` -On Windows execute - -```powershell -mkdir CppInterOp\build\ -cd CppInterOp\build\ -``` - -Now if you want to build CppInterOp with Clang-REPL then execute the following commands on Linux and MacOS +Now if you want to build CppInterOp with Clang-REPL then execute the following commands ```bash 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) ``` -and - -```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 +If alternatively you would like to install CppInterOp with Cling then execute the following commands ```bash 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) ``` -and - -```powershell -cmake -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$env:LLVM_DIR\build\tools\cling -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. - #### Testing CppInterOp To test the built CppInterOp execute the following command in the CppInterOP build folder on Linux and MacOS @@ -340,25 +236,13 @@ To test the built CppInterOp execute the following command in the CppInterOP bui cmake --build . --target check-cppinterop --parallel $(nproc --all) ``` -and - -```powershell -cmake --build . --target check-cppinterop --parallel $env:ncpus -``` - -on Windows. Now go back to the top level directory in which your building CppInterOP. On Linux and MacOS you do this by executing +Now go back to the top level directory in which your building CppInterOP ```bash cd ../.. ``` -and - -```powershell -cd ..\.. -``` - -on Windows. Now you are in a position to install cppyy following the instructions below. +Now you are in a position to install cppyy following the instructions below. #### Building and Install cppyy-backend @@ -420,12 +304,6 @@ Export the `libcppyy` path to python: export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR ``` -and on Windows: - -```powershell -$env:PYTHONPATH="$env:PYTHONPATH;$env:CPYCPPYY_DIR;$env:CB_PYTHON_DIR" -``` - #### Install cppyy ```bash @@ -461,6 +339,162 @@ python -m pip install pytest python -m pytest -sv ``` +
+ + + +
+Windows + +#### Clone CppInterOp and cppyy-backend + +First clone the CppInterOp repository, as this may contain patches that need to be applied to the subsequently cloned llvm-project repo (these patches are only applied if building CppInterOp with Clang-REPL) + +```bash +git clone --depth=1 https://github.com/compiler-research/CppInterOp.git +``` + +and clone cppyy-backend repository where we will be installing the CppInterOp library + +```bash +git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git +``` + +#### Setup Clang-REPL + +Clone the 20.x release of the LLVM project repository. + +```bash +git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git +cd llvm-project +``` + +##### Build Clang-REPL + +Clang-REPL is an interpreter that CppInterOp works alongside. Build Clang (and +Clang-REPL along with it) by executing the following + +```powershell +$env:ncpus = $([Environment]::ProcessorCount) +mkdir build +cd build +cmake -DLLVM_ENABLE_PROJECTS=clang ` + -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 + cmake --build . --target clang clang-repl --parallel $env:ncpus +``` + +Note the 'llvm-project' directory location by executing the following + +```powershell +cd ..\ +$env:LLVM_DIR= $PWD.Path +cd ..\ +``` + +#### Build Cling and related dependencies + +Besides the Clang-REPL interpreter, CppInterOp also works alongside the Cling +interpreter. Cling depends on its own customised version of `llvm-project`, +hosted under the `root-project` (see the git path below). +Use the following build instructions to build + +```powershell +git clone https://github.com/root-project/cling.git +cd .\cling\ +git checkout tags/v1.2 +git apply -v ..\CppInterOp\patches\llvm\cling1.2-LookupHelper.patch +cd .. +git clone --depth=1 -b cling-llvm18 https://github.com/root-project/llvm-project.git +$env:ncpus = $([Environment]::ProcessorCount) +$env:PWD_DIR= $PWD.Path +$env:CLING_DIR="$env:PWD_DIR\cling" +mkdir llvm-project\build +cd llvm-project\build +cmake -DLLVM_ENABLE_PROJECTS=clang ` + -DLLVM_EXTERNAL_PROJECTS=cling ` + -DLLVM_EXTERNAL_CLING_SOURCE_DIR="$env:CLING_DIR" ` + -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 +cmake --build . --target clang --parallel $env:ncpus +cmake --build . --target cling --parallel $env:ncpus +``` + +Note the 'llvm-project' directory location by executing the following + +```powershell +cd ..\ +$env:LLVM_DIR= $PWD.Path +cd ..\ +``` + +#### Environment variables + +Regardless of whether you are building CppInterOP with Cling or Clang-REPL you will need to define the following environment variables (as they clear for a new session, it is recommended that you also add these to your profile.ps1). You define as follows (assumes you have defined $env:PWD_DIR= $PWD.Path ) + +```powershell +$env:CB_PYTHON_DIR="$env:PWD_DIR\cppyy-backend\python" +$env:CPPINTEROP_DIR="$env:CB_PYTHON_DIR\cppyy_backend" +``` + +If building against clang-repl you will have the following defined + +```powershell +$env:CPLUS_INCLUDE_PATH="$env:CPLUS_INCLUDE_PATH;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_DIR\build\include;$env:LLVM_DIR\build\tools\clang\include" +``` + +and if building against cling + +```powershell +$env:CLING_DIR="$env:PWD_DIR\cling" +$env:CLING_BUILD_DIR="$env:PWD_DIR\cling\build" +$env:CPLUS_INCLUDE_PATH="$env:CLING_DIR\tools\cling\include;$env:CLING_BUILD_DIR\include;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include;" +``` + +#### Build CppInterOp + +Now CppInterOp can be installed. Start by executing + +```powershell +mkdir CppInterOp\build\ +cd CppInterOp\build\ +``` + +Now if you want to build CppInterOp with Clang-REPL then execute the following + +```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 +``` + +If alternatively you would like to install CppInterOp with Cling then execute the following + +```powershell +cmake -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$env:LLVM_DIR\build\tools\cling -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 +``` + +#### Testing CppInterOp + +To test the built CppInterOp execute the following command in the CppInterOP build folder +and + +```powershell +cmake --build . --target check-cppinterop --parallel $env:ncpus +``` + ______________________________________________________________________ Further Reading: [C++ Language Interoperability Layer](https://compiler-research.org/libinterop/)