diff --git a/.github/workflows/Windows.yml b/.github/workflows/Windows.yml index 9a5d09153..460b248fe 100644 --- a/.github/workflows/Windows.yml +++ b/.github/workflows/Windows.yml @@ -21,13 +21,13 @@ jobs: fail-fast: false matrix: include: - - name: win2025-msvc-clang-repl-19 + - name: win2025-shared-lib os: windows-2025 - compiler: msvc - clang-runtime: '19' + compiler: clang + clang-runtime: '18' cling: Off llvm_enable_projects: "clang" - llvm_targets_to_build: "host;NVPTX" + llvm_targets_to_build: "host" steps: - uses: actions/checkout@v4 @@ -73,7 +73,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' }}-shared-lib lookup-only: true - name: Setup default Build Type on Windows @@ -93,10 +93,10 @@ jobs: choco install llvm --version=$ver --no-progress -my clang --version # - $env:CC="clang" - $env:CXX="clang++" - echo "CC=clang" >> $env:GITHUB_ENV - echo "CXX=clang++" >> $env:GITHUB_ENV + $env:CC="clang-cl" + $env:CXX="clang-cl" + echo "CC=clang-cl" >> $env:GITHUB_ENV + echo "CXX=clang-cl" >> $env:GITHUB_ENV } elseif ( "${{ matrix.compiler }}" -imatch "msvc" ) { @@ -130,7 +130,7 @@ jobs: } else { - git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git + git clone --depth=1 -b llvm-export-api-20.0 https://github.com/fsfod/llvm-project.git } cd llvm-project @@ -139,20 +139,24 @@ jobs: if ( "${{ matrix.cling }}" -imatch "On" ) { cd build - cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" ` + cmake -G Ninja -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" ` -DLLVM_EXTERNAL_PROJECTS=cling ` -DLLVM_EXTERNAL_CLING_SOURCE_DIR="$env:CLING_DIR" ` -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" ` -DCMAKE_BUILD_TYPE=Release ` -DLLVM_ENABLE_ASSERTIONS=ON ` -DCLANG_ENABLE_STATIC_ANALYZER=OFF ` + -DLLVM_ENABLE_PLUGINS=On ` -DCLANG_ENABLE_ARCMT=OFF ` -DCLANG_ENABLE_FORMAT=OFF ` -DCLANG_ENABLE_BOOTSTRAP=OFF ` -DLLVM_ENABLE_ZSTD=OFF ` -DLLVM_ENABLE_TERMINFO=OFF ` -DLLVM_ENABLE_LIBXML2=OFF ` - ..\llvm + -DLLVM_BUILD_LLVM_DYLIB_VIS=On ` + -DLLVM_DYLIB_COMPONENTS="BinaryFormat;Core;Object;OrcJit;Support;FrontendDriver;OrcDebugging;Coverage;FrontendHLSL;LTO;clangCodeGen;clangStaticAnalyzerCore" ` + -DLLVM_LINK_LLVM_DYLIB=On ` + -DCLANG_LINK_CLANG_DYLIB=On -DCMAKE_ASM_MASM_COMPILER=llvm-ml -DCMAKE_ASM_MASM_FLAGS="-m64" ..\llvm cmake --build . --config Release --target clang --parallel ${{ env.ncpus }} cmake --build . --config Release --target cling --parallel ${{ env.ncpus }} # Now build gtest.a and gtest_main for CppInterOp to run its tests. @@ -174,18 +178,19 @@ jobs: } cd build echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" - cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" ` + cmake -G Ninja -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" ` -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" ` - -DCMAKE_BUILD_TYPE=Release ` - -DLLVM_ENABLE_ASSERTIONS=ON ` + -DCMAKE_BUILD_TYPE=Release ` + -DLLVM_ENABLE_ASSERTIONS=ON ` + -DCMAKE_CXX_COMPILER=clang-cl ` + -DCMAKE_C_COMPILER=clang-cl ` -DCLANG_ENABLE_STATIC_ANALYZER=OFF ` -DCLANG_ENABLE_ARCMT=OFF ` - -DCLANG_ENABLE_FORMAT=OFF ` - -DCLANG_ENABLE_BOOTSTRAP=OFF ` - -DLLVM_ENABLE_ZSTD=OFF ` - -DLLVM_ENABLE_TERMINFO=OFF ` - -DLLVM_ENABLE_LIBXML2=OFF ` - ..\llvm + -DLLVM_ENABLE_PLUGINS=On ` + -DLLVM_BUILD_LLVM_DYLIB_VIS=On ` + -DLLVM_BUILD_LLVM_DYLIB=On ` + -DLLVM_LINK_LLVM_DYLIB=On ` + -DCLANG_LINK_CLANG_DYLIB=On -DCMAKE_ASM_MASM_COMPILER=llvm-ml -DCMAKE_ASM_MASM_FLAGS="-m64" ..\llvm cmake --build . --config Release --target clang clangInterpreter clangStaticAnalyzerCore --parallel ${{ env.ncpus }} } cd ..\ @@ -224,10 +229,10 @@ jobs: fail-fast: false matrix: include: - - name: win2025-msvc-clang-repl-19 + - name: win2025-shared-lib os: windows-2025 - compiler: msvc - clang-runtime: '19' + compiler: clang + clang-runtime: '18' cling: Off cppyy: Off @@ -283,10 +288,10 @@ jobs: choco install llvm --version=$ver --no-progress -my clang --version # - $env:CC="clang" - $env:CXX="clang++" - echo "CC=clang" >> $env:GITHUB_ENV - echo "CXX=clang++" >> $env:GITHUB_ENV + $env:CC="clang-cl" + $env:CXX="clang-cl" + echo "CC=clang-cl" >> $env:GITHUB_ENV + echo "CXX=clang-cl" >> $env:GITHUB_ENV } elseif ( "${{ matrix.compiler }}" -imatch "msvc" ) { @@ -304,7 +309,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' }}-shared-lib - name: Build and Test/Install CppInterOp on Windows systems run: | @@ -356,23 +361,28 @@ jobs: echo "CPPINTEROP_BUILD_DIR=$env:CPPINTEROP_BUILD_DIR" >> $env:GITHUB_ENV if ( "${{ matrix.cling }}" -imatch "On" ) { - cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ` + cmake -G Ninja -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ` -DUSE_CLING=ON ` -DUSE_REPL=OFF ` + -DBUILD_SHARED_LIBS=ON ` -DCling_DIR="$env:LLVM_BUILD_DIR\tools\cling" ` -DLLVM_DIR="$env:LLVM_BUILD_DIR" ` -DLLVM_ENABLE_WERROR=On ` + -DLLVM_BUILD_LLVM_DYLIB_VIS=On -DLLVM_LINK_LLVM_DYLIB=On -DCLANG_LINK_CLANG_DYLIB=On -DDISABLE_LLVM_LINK_LLVM_DYLIB=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 }} ` + cmake -G Ninja -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ` -DLLVM_DIR="$env:LLVM_BUILD_DIR\lib\cmake\llvm" ` -DLLVM_ENABLE_WERROR=On ` + -DBUILD_SHARED_LIBS=ON ` + -DLLVM_LINK_LLVM_DYLIB=On ` + -DCLANG_LINK_CLANG_DYLIB=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 googletest --parallel ${{ env.ncpus }} } - cmake --build . --config ${{ env.BUILD_TYPE }} --target check-cppinterop --parallel ${{ env.ncpus }} + cmake --build . --config ${{ env.BUILD_TYPE }} --target check-cppinterop - name: Setup tmate session if: ${{ failure() && runner.debug }} diff --git a/CMakeLists.txt b/CMakeLists.txt index b27d0a762..582c2d03a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,14 +67,14 @@ include(GNUInstallDirs) ## Define supported version of clang and llvm set(CLANG_MIN_SUPPORTED 13.0) - set(CLANG_MAX_SUPPORTED "19.1.x") - set(CLANG_VERSION_UPPER_BOUND 20.0.0) + set(CLANG_MAX_SUPPORTED "20.1.x") + set(CLANG_VERSION_UPPER_BOUND 21.0.0) set(LLD_MIN_SUPPORTED 13.0) - set(LLD_MAX_SUPPORTED "19.1.x") - set(LLD_VERSION_UPPER_BOUND 20.0.0) + set(LLD_MAX_SUPPORTED "20.1.x") + set(LLD_VERSION_UPPER_BOUND 21.0.0) set(LLVM_MIN_SUPPORTED 13.0) - set(LLVM_MAX_SUPPORTED "19.1.x") - set(LLVM_VERSION_UPPER_BOUND 20.0.0) + set(LLVM_MAX_SUPPORTED "20.1.x") + set(LLVM_VERSION_UPPER_BOUND 21.0.0) ## Set Cmake packages search order diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt index 933505691..c912d1e99 100644 --- a/lib/Interpreter/CMakeLists.txt +++ b/lib/Interpreter/CMakeLists.txt @@ -29,14 +29,16 @@ if(EMSCRIPTEN) PUBLIC "SHELL: -s WASM_BIGINT" ) else() - set(LLVM_LINK_COMPONENTS - ${LLVM_TARGETS_TO_BUILD} - BinaryFormat - Core - Object - OrcJit - Support - ) + IF(NOT WIN32) + set(LLVM_LINK_COMPONENTS + ${LLVM_TARGETS_TO_BUILD} + BinaryFormat + Core + Object + OrcJit + Support + ) + endif() # FIXME: Investigate why this needs to be conditionally included. if ("LLVMFrontendDriver" IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND LLVM_LINK_COMPONENTS FrontendDriver) @@ -77,7 +79,7 @@ else() if(NOT WIN32) list(APPEND link_libs dl) endif() - + # Get rid of libLLVM-X.so which is appended to the list of static libraries. if (LLVM_LINK_LLVM_DYLIB) set(new_libs ${link_libs}) @@ -89,8 +91,10 @@ else() if (NOT transitive_libs) continue() endif() + string(REPLACE "version;" "" transitive_libs "${transitive_libs}") foreach(transitive_lib ${transitive_libs}) get_target_property(lib_type ${transitive_lib} TYPE) + message(STATUS "lib_type ${lib_type}") if("${lib_type}" STREQUAL "STATIC_LIBRARY") list(APPEND static_transitive_libs ${transitive_lib}) else() @@ -124,8 +128,8 @@ else() clangStaticAnalyzerCore ) endif(LLVM_LINK_LLVM_DYLIB) - - add_llvm_library(clangCppInterOp + if(NOT WIN32) + llvm_add_library(clangCppInterOp DISABLE_LLVM_LINK_LLVM_DYLIB CppInterOp.cpp CXCppInterOp.cpp @@ -133,6 +137,14 @@ else() LINK_LIBS ${link_libs} ) + else() + llvm_add_library(clangCppInterOp + DISABLE_LLVM_LINK_LLVM_DYLIB + CppInterOp.cpp + CXCppInterOp.cpp + ${DLM} + ) + endif() endif() string(REPLACE ";" "\;" _VER CPPINTEROP_VERSION) diff --git a/unittests/CppInterOp/CUDATest.cpp b/unittests/CppInterOp/CUDATest.cpp index ea171b46e..17bf80dff 100644 --- a/unittests/CppInterOp/CUDATest.cpp +++ b/unittests/CppInterOp/CUDATest.cpp @@ -46,18 +46,12 @@ TEST(DISABLED_CUDATest, Sanity) { #else TEST(CUDATest, Sanity) { #endif // CLANG_VERSION_MAJOR < 16 -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif if (!HasCudaSDK()) GTEST_SKIP() << "Skipping CUDA tests as CUDA SDK not found"; EXPECT_TRUE(Cpp::CreateInterpreter({}, {"--cuda"})); } TEST(CUDATest, CUDAH) { -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif if (!HasCudaSDK()) GTEST_SKIP() << "Skipping CUDA tests as CUDA SDK not found"; @@ -67,9 +61,6 @@ TEST(CUDATest, CUDAH) { } TEST(CUDATest, CUDARuntime) { -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif if (!HasCudaRuntime()) GTEST_SKIP() << "Skipping CUDA tests as CUDA runtime not found"; diff --git a/unittests/CppInterOp/FunctionReflectionTest.cpp b/unittests/CppInterOp/FunctionReflectionTest.cpp index efc1ca815..12b2ccd6d 100644 --- a/unittests/CppInterOp/FunctionReflectionTest.cpp +++ b/unittests/CppInterOp/FunctionReflectionTest.cpp @@ -800,9 +800,6 @@ TEST(FunctionReflectionTest, IsStaticMethod) { TEST(FunctionReflectionTest, GetFunctionAddress) { if (llvm::sys::RunningOnValgrind()) GTEST_SKIP() << "XFAIL due to Valgrind report"; -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif std::vector Decls, SubDecls; std::string code = "int f1(int i) { return i * i; }"; @@ -1129,9 +1126,6 @@ TEST(FunctionReflectionTest, GetFunctionArgDefault) { TEST(FunctionReflectionTest, Construct) { if (llvm::sys::RunningOnValgrind()) GTEST_SKIP() << "XFAIL due to Valgrind report"; -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif Cpp::CreateInterpreter(); @@ -1170,10 +1164,6 @@ TEST(FunctionReflectionTest, Destruct) { if (llvm::sys::RunningOnValgrind()) GTEST_SKIP() << "XFAIL due to Valgrind report"; -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif - Cpp::CreateInterpreter(); Interp->declare(R"( diff --git a/unittests/CppInterOp/InterpreterTest.cpp b/unittests/CppInterOp/InterpreterTest.cpp index 22c5f0e99..5d72fe3cb 100644 --- a/unittests/CppInterOp/InterpreterTest.cpp +++ b/unittests/CppInterOp/InterpreterTest.cpp @@ -57,9 +57,6 @@ TEST(InterpreterTest, DebugFlag) { } TEST(InterpreterTest, Evaluate) { -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif if (llvm::sys::RunningOnValgrind()) GTEST_SKIP() << "XFAIL due to Valgrind report"; // EXPECT_TRUE(Cpp::Evaluate(I, "") == 0); @@ -76,9 +73,6 @@ TEST(InterpreterTest, Evaluate) { } TEST(InterpreterTest, Process) { -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif if (llvm::sys::RunningOnValgrind()) GTEST_SKIP() << "XFAIL due to Valgrind report"; Cpp::CreateInterpreter(); @@ -128,9 +122,6 @@ TEST(InterpreterTest, DetectResourceDir) { #else TEST(InterpreterTest, DISABLED_DetectResourceDir) { #endif // LLVM_BINARY_DIR -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif Cpp::CreateInterpreter(); EXPECT_STRNE(Cpp::DetectResourceDir().c_str(), Cpp::GetResourceDir()); llvm::SmallString<256> Clang(LLVM_BINARY_DIR); @@ -140,9 +131,6 @@ TEST(InterpreterTest, DISABLED_DetectResourceDir) { } TEST(InterpreterTest, DetectSystemCompilerIncludePaths) { -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif std::vector includes; Cpp::DetectSystemCompilerIncludePaths(includes); EXPECT_FALSE(includes.empty()); diff --git a/unittests/CppInterOp/JitTest.cpp b/unittests/CppInterOp/JitTest.cpp index 310f87efe..5d0e55d58 100644 --- a/unittests/CppInterOp/JitTest.cpp +++ b/unittests/CppInterOp/JitTest.cpp @@ -14,9 +14,6 @@ static int printf_jit(const char* format, ...) { TEST(JitTest, InsertOrReplaceJitSymbol) { if (llvm::sys::RunningOnValgrind()) GTEST_SKIP() << "XFAIL due to Valgrind report"; -#ifdef _WIN32 - GTEST_SKIP() << "Disabled on Windows. Needs fixing."; -#endif std::vector Decls; std::string code = R"( extern "C" int printf(const char*,...);