Skip to content

[wip] Add Windows support for cppyy #605

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

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
20ac9af
Add initial attempt to build cppyy on Windows
mcbarton May 28, 2025
e562abc
Debug action.yml
mcbarton May 29, 2025
cede61d
Debug action.yml
mcbarton May 29, 2025
0abfdcd
Try -DBUILD_SHARED_LIBS=ON Windows
mcbarton May 29, 2025
a5576ac
Revert previous change
mcbarton May 29, 2025
4e71a86
Update action.yml
mcbarton May 29, 2025
a9a9dd5
Update action.yml
mcbarton May 30, 2025
a2c1aa9
[debug] disable CppInterOp tests Windows shared library build
mcbarton May 30, 2025
519e408
Try fix PR
mcbarton Jun 4, 2025
f6fbca2
Update action.yml
mcbarton Jun 4, 2025
fa4ceb2
Try exporting new set of symbols msvc
mcbarton Jun 4, 2025
9da90d2
Update CMakeLists.txt to export more symbols
mcbarton Jun 4, 2025
cd7e336
Update CMakeLists.txt to export more symbols
mcbarton Jun 4, 2025
593164a
Update CMakeLists.txt
mcbarton Jun 4, 2025
712c77b
Update CMakeLists.txt
mcbarton Jun 4, 2025
466c6c8
Update CMakeLists.txt
mcbarton Jun 4, 2025
9549a65
Update CMakeLists.txt
mcbarton Jun 4, 2025
63f11ce
Update CMakeLists.txt
mcbarton Jun 4, 2025
c63d450
Update CMakeLists.txt
mcbarton Jun 4, 2025
3e1cc81
Update CMakeLists.txt
mcbarton Jun 4, 2025
2c2d652
Update CMakeLists.txt
mcbarton Jun 4, 2025
0db2b7d
Update CMakeLists.txt
mcbarton Jun 4, 2025
9107d44
Update CMakeLists.txt
mcbarton Jun 4, 2025
66f0f66
Update CMakeLists.txt
mcbarton Jun 4, 2025
3879ce3
Update CMakeLists.txt
mcbarton Jun 4, 2025
577de75
Update CMakeLists.txt
mcbarton Jun 4, 2025
75cc1f9
Update CMakeLists.txt
mcbarton Jun 4, 2025
e566c83
Update CMakeLists.txt
mcbarton Jun 4, 2025
bc825cf
Update CMakeLists.txt
mcbarton Jun 4, 2025
7e2514b
Update CMakeLists.txt
mcbarton Jun 4, 2025
86bd0d7
Update CMakeLists.txt
mcbarton Jun 4, 2025
590f9c0
Update CMakeLists.txt
mcbarton Jun 4, 2025
64c7aff
Update CMakeLists.txt
mcbarton Jun 4, 2025
8020b1e
Update CMakeLists.txt
mcbarton Jun 4, 2025
051bde8
Update action.yml
mcbarton Jun 4, 2025
a0c57d2
Try new solution
mcbarton Jun 5, 2025
e2c1f61
Update clangCppInterOp.def
mcbarton Jun 9, 2025
72b70b2
Merge branch 'main' into Add-Windows-support-cppyy
mcbarton Jun 9, 2025
6a0e006
Update clangCppInterOp.def
mcbarton Jun 10, 2025
2ab4ec3
Update clangCppInterOp.def
mcbarton Jun 10, 2025
83837d6
Update clangCppInterOp.def
mcbarton Jun 10, 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
20 changes: 10 additions & 10 deletions .github/actions/Build_and_Test_CppInterOp/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ runs:
echo "CLING_BUILD_DIR=$env:CLING_BUILD_DIR"
echo "CLING_BUILD_DIR=$env:CLING_BUILD_DIR" >> $env:GITHUB_ENV

$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;"
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH"
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH" >> $env:GITHUB_ENV
$env:IncludePath="$env:IncludePath;$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;"
echo "IncludePath=$env:IncludePath"
echo "IncludePath=$env:IncludePath" >> $env:GITHUB_ENV
}
else
{
$env:CPLUS_INCLUDE_PATH="$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;"
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH"
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH" >> $env:GITHUB_ENV
$env:IncludePath="$env:IncludePath;$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;"
echo "IncludePath=$env:IncludePath"
echo "IncludePath=$env:IncludePath" >> $env:GITHUB_ENV
}

$env:CB_PYTHON_DIR="$env:PWD_DIR\cppyy-backend\python"
Expand All @@ -113,7 +113,7 @@ runs:
# Build CppInterOp next to cling and llvm-project.
mkdir build
cd build
$env:CPPINTEROP_BUILD_DIR="$env:PWD_DIR"
$env:CPPINTEROP_BUILD_DIR=$PWD.Path
echo "CPPINTEROP_BUILD_DIR=$env:CPPINTEROP_BUILD_DIR"
echo "CPPINTEROP_BUILD_DIR=$env:CPPINTEROP_BUILD_DIR" >> $env:GITHUB_ENV
if ( "${{ matrix.cling }}" -imatch "On" )
Expand All @@ -123,14 +123,14 @@ runs:
-DCPPINTEROP_USE_REPL=OFF `
-DCling_DIR="$env:LLVM_BUILD_DIR\tools\cling" `
-DLLVM_DIR="$env:LLVM_BUILD_DIR" `
-DLLVM_ENABLE_WERROR=On `
-DLLVM_ENABLE_WERROR=On -DBUILD_SHARED_LIBS=ON `
-DClang_DIR="$env:LLVM_BUILD_DIR" -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} -DCMAKE_INSTALL_PREFIX="$env:CPPINTEROP_DIR" ..\
}
else
{
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} `
-DLLVM_DIR="$env:LLVM_BUILD_DIR\lib\cmake\llvm" `
-DLLVM_ENABLE_WERROR=On `
-DLLVM_ENABLE_WERROR=On -DBUILD_SHARED_LIBS=ON `
-DClang_DIR="$env:LLVM_BUILD_DIR\lib\cmake\clang" -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} -DCMAKE_INSTALL_PREFIX="$env:CPPINTEROP_DIR" ..\
}
cmake --build . --config ${{ env.BUILD_TYPE }} --target check-cppinterop --parallel ${{ env.ncpus }}
cmake --build . --config ${{ env.BUILD_TYPE }} --target check-cppinterop
99 changes: 99 additions & 0 deletions .github/actions/Build_and_Test_cppyy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,102 @@ runs:
tail -n1 test_xfailed.log
echo "Return Code: ${RETCODE}"
exit $RETCODE

- name: Build and Install cppyy-backend
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
# Download cppyy-backend
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git
cd cppyy-backend
mkdir $env:CPPINTEROP_DIR\lib
mkdir build
cd build
# Install CppInterOp
cd $env:CPPINTEROP_BUILD_DIR
cmake --build . --target install --parallel ${{ env.ncpus }}
find.exe . -name "*.dll"
find.exe . -name "*.lib"
cd ..\cppyy-backend\build\
# Build and Install cppyy-backend
cmake -DCppInterOp_DIR=$env:CPPINTEROP_DIR -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ..
cmake --build . --config ${{ env.BUILD_TYPE }} --parallel ${{ env.ncpus }}
find.exe . -name "*"
cp Release\libcppyy-backend.dll $env:CPPINTEROP_DIR\lib\
cd ..

- name: Install CPyCppyy
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
python -m venv .venv
. .\.venv\Scripts\Activate.ps1
# Install CPyCppyy
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git
mkdir CPyCppyy\build
cd CPyCppyy\build
cmake ..
cmake --build . --parallel ${{ env.ncpus }}
#
env:CPYCPPYY_DIR = $PWD.Path
cd ../..
# We need CPYCPPYY_DIR later
echo "CPYCPPYY_DIR=$env:CPYCPPYY_DIR" >> $env:GITHUB_ENV

- name: Install cppyy
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
# source virtual environment
. .\.venv\Scripts\Activate.ps1
# Install cppyy
git clone --depth=1 https://github.com/compiler-research/cppyy.git
cd cppyy
python -m pip install --upgrade . --no-deps
cd ..

- name: Run cppyy
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
# Run cppyy
. .\.venv\Scripts\Activate.ps1
$env:PYTHONPATH=$env:PYTHONPATH:$env:CPYCPPYY_DIR:$env:CB_PYTHON_DIR
python -c "import cppyy"
# We need PYTHONPATH later
echo "PYTHONPATH=$env:PYTHONPATH" >> $GITHUB_ENV

- name: Run the tests
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
# Run the tests
. .\.venv\Scripts\Activate.ps1
cd cppyy\test
echo ::group::Prepare For Testing
make all
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install pytest-xdist
python -m pip install numba
echo ::endgroup::
echo ::group::Run complete test suite
$ErrorActionPreference = "Stop"
python -m pytest -sv -ra 2>&1 | Tee-Object -FilePath complete_testrun.log
$ErrorActionPreference = "Continue"
echo ::group::Crashing Test Logs
# See if we don't have a crash that went away
# Comment out all xfails but the ones that have a run=False condition.
find.exe . -name "*.py" -exec sed.exe -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \;
python -m pytest -n 1 -m "xfail" --runxfail -sv -ra --max-worker-restart 512 2>&1 | Tee-Object -FilePath test_crashed.log
$LASTEXITCODE = 0
git checkout .
echo ::endgroup::
echo ::group::XFAIL Test Logs
# Rewrite all xfails that have a run clause to skipif. This way we will
# avoid conditionally crashing xfails
find.exe . -name "*.py" -exec sed.exe -i -E 's/(^ *)@mark.xfail\(run=(.*)/\[email protected](condition=not \2/g' {} \;
# See if we don't have an xfail that went away
python -m pytest --runxfail -sv -ra | tee test_xfailed.log 2>&1 || true
git checkout .
echo ::endgroup::
2 changes: 2 additions & 0 deletions .github/workflows/Windows-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ jobs:

- uses: ./.github/actions/Build_and_Test_CppInterOp

- uses: ./.github/actions/Build_and_Test_cppyy

- name: Setup tmate session
if: ${{ failure() && runner.debug }}
uses: mxschmitt/action-tmate@v3
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ jobs:

- uses: ./.github/actions/Build_and_Test_CppInterOp

- uses: ./.github/actions/Build_and_Test_cppyy

- name: Setup tmate session
if: ${{ failure() && runner.debug }}
uses: mxschmitt/action-tmate@v3
Expand Down
6 changes: 6 additions & 0 deletions lib/CppInterOp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,9 @@ string(REPLACE ";" "\;" _VER CPPINTEROP_VERSION)
set_source_files_properties(CppInterOp.cpp PROPERTIES COMPILE_DEFINITIONS
"LLVM_BINARY_DIR=\"${LLVM_BINARY_DIR}\";CPPINTEROP_VERSION=\"${_VAR}\""
)

if(MSVC)
set_target_properties(clangCppInterOp PROPERTIES
LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/clangCppInterOp.def"
)
endif()
66 changes: 66 additions & 0 deletions lib/CppInterOp/clangCppInterOp.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
LIBRARY clangCppInterOp
EXPORTS
?write@raw_ostream@llvm@@QEAAAEAV12@PEBD_K@Z
__imp_?classof@DeclContext@clang@@SA_NPEBVDecl@2@@Z
?create@Interpreter@clang@@SA?AV?$Expected@V?$unique_ptr@VInterpreter@clang@@U?$default_delete@VInterpreter@clang@@@std@@@std@@@llvm@@V?$unique_ptr@VCompilerInstance@clang@@U?$default_delete@VCompilerInstance@clang@@@std@@@std@@@Z
?errs@llvm@@YAAEAVraw_fd_ostream@1@XZ
?DestroyDataAndMakeUninit@APValue@clang@@AEAAXXZ
?dbgs@llvm@@YAAEAVraw_ostream@1@XZ
?fatalUncheckedError@Error@llvm@@AEBAXXZ
?logAllUnhandledErrors@llvm@@YAXVError@1@AEAVraw_ostream@1@VTwine@1@@Z
?isFloatingType@Type@clang@@QEBA_NXZ
?getDecl@TagType@clang@@QEBAPEAVTagDecl@2@XZ
?hasDefiningAttr@Decl@clang@@QEBA_NXZ
?getNumParams@FunctionDecl@clang@@QEBAIXZ
?getTemplateInstantiationPattern@FunctionDecl@clang@@QEBAPEAV12@_N@Z
?getTemplateSpecializationArgs@FunctionDecl@clang@@QEBAPEBVTemplateArgumentList@2@XZ
?initSlowCase@APInt@llvm@@AEAAX_K_N@Z
?compare@APInt@llvm@@AEBAHAEBV12@@Z
?compareSigned@APInt@llvm@@AEBAHAEBV12@@Z
?compareValues@APSInt@llvm@@SAHAEBV12@0@Z
??1raw_ostream@llvm@@UEAA@XZ
??1raw_string_ostream@llvm@@UEAA@XZ
?write_impl@raw_string_ostream@llvm@@EEAAXPEBD_K@Z
?changeColor@raw_ostream@llvm@@UEAAAEAV12@W4Colors@12@_N1@Z
?resetColor@raw_ostream@llvm@@UEAAAEAV12@XZ
?reverseColor@raw_ostream@llvm@@UEAAAEAV12@XZ
?preferred_buffer_size@raw_ostream@llvm@@MEBA_KXZ
?SetBufferAndMode@raw_ostream@llvm@@AEAAXPEAD_KW4BufferKind@12@@Z
?flush_nonempty@raw_ostream@llvm@@AEAAXXZ
?anchor@raw_ostream@llvm@@EEAAXXZ
?maybeMangleDeclName@compat@@YAXAEBVGlobalDecl@clang@@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
?grow_pod@?$SmallVectorBase@I@llvm@@IEAAXPEAX_K1@Z
??0APInt@llvm@@QEAA@IV?$ArrayRef@_K@1@@Z
?sext@APInt@llvm@@QEBA?AV12@I@Z
?zext@APInt@llvm@@QEBA?AV12@I@Z
?allocate_buffer@llvm@@YAPEAX_K0@Z
?RehashTable@StringMapImpl@llvm@@IEAAII@Z
?LookupBucketFor@StringMapImpl@llvm@@IEAAIVStringRef@2@I@Z
?hash@StringMapImpl@llvm@@SAIVStringRef@2@@Z
?getUnqualifiedDesugaredType@Type@clang@@QEBAPEBV12@XZ
?getASTContext@Decl@clang@@QEBAAEAVASTContext@2@XZ
?getAttrs@Decl@clang@@QEBAAEBV?$SmallVector@PEAVAttr@clang@@$03@llvm@@XZ
?lookup@DeclContext@clang@@QEBA?AVDeclContextLookupResult@2@VDeclarationName@2@@Z
?isThisDeclarationADefinition@VarDecl@clang@@QEBA?AW4DefinitionKind@12@AEAVASTContext@2@@Z
?isInjectedClassName@RecordDecl@clang@@QEBA_NXZ
?getTypeDeclTypeSlow@ASTContext@clang@@AEBA?AVQualType@2@PEBVTypeDecl@2@@Z
?getComplexType@ASTContext@clang@@QEBA?AVQualType@2@V32@@Z
?createMangleContext@ASTContext@clang@@QEAAPEAVMangleContext@2@PEBVTargetInfo@2@@Z
?getSpecializations@ClassTemplateDecl@clang@@IEBAAEAV?$FoldingSetVector@VClassTemplateSpecializationDecl@clang@@V?$SmallVector@PEAVClassTemplateSpecializationDecl@clang@@$07@llvm@@@llvm@@XZ
?getSpecializedTemplate@VarTemplateSpecializationDecl@clang@@QEBAPEAVVarTemplateDecl@2@XZ
?shouldMangleDeclName@MangleContext@clang@@QEAA_NPEBVNamedDecl@2@@Z
?mangleName@MangleContext@clang@@QEAAXVGlobalDecl@2@AEAVraw_ostream@llvm@@@Z
?getStdNamespace@Sema@clang@@QEBAPEAVNamespaceDecl@2@XZ
?castToDeclContext@Decl@clang@@SAPEAVDeclContext@2@PEBV12@@Z
?decls_begin@DeclContext@clang@@QEBA?AVdecl_iterator@12@XZ
?classof@DeclContext@clang@@SA_NPEBVDecl@2@@Z
?Parse@Interpreter@clang@@QEAA?AV?$Expected@AEAUPartialTranslationUnit@clang@@@llvm@@VStringRef@4@@Z
?Execute@Interpreter@clang@@QEAA?AVError@llvm@@AEAUPartialTranslationUnit@2@@Z
?getLValueReferenceType@ASTContext@clang@@QEBA?AVQualType@2@V32@_N@Z
?getCompilerInstance@Interpreter@clang@@QEAAPEAVCompilerInstance@2@XZ
?RunningOnValgrind@sys@llvm@@YA_NXZ
?grow_pod@?$SmallVectorBase@_K@llvm@@IEAAXPEAX_K1@Z
?access@fs@sys@llvm@@YA?AVerror_code@std@@AEBVTwine@3@W4AccessMode@123@@Z
?CreateCpp@IncrementalCompilerBuilder@clang@@QEAA?AV?$Expected@V?$unique_ptr@VCompilerInstance@clang@@U?$default_delete@VCompilerInstance@clang@@@std@@@std@@@llvm@@XZ
?getMainExecutable@fs@sys@llvm@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBDPEAX@Z
?parent_path@path@sys@llvm@@YA?AVStringRef@3@V43@W4Style@123@@Z
Loading