From 59530582a4133bf4719898648930792796cbd17e Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbarton@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:31:38 +0000 Subject: [PATCH] Add ability to compile CppInterOp and tests on Windows with different compiler (#195) --- .github/workflows/ci.yml | 132 +++++++++--------- README.md | 4 +- cmake/modules/GoogleTest.cmake | 2 +- lib/Interpreter/CppInterOp.cpp | 2 +- .../CppInterOp/TestSharedLib/TestSharedLib.h | 2 +- 5 files changed, 70 insertions(+), 72 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dc96df6f..0abcc5335 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,13 +162,14 @@ jobs: # cling-version: '1.0' # cppyy: On # xeus-clang-repl: On + #FIXME: Windows CppInterOp tests expected to fail + #until https://github.com/compiler-research/CppInterOp/issues/188 is solved - name: win2022-msvc-clang-repl-17 os: windows-2022 compiler: msvc clang-runtime: '17' cling: Off cppyy: Off - #Commented out until rest of ci for Windows tested #- name: win2022-msvc-clang-repl-17-cppyy # os: windows-2022 # compiler: msvc @@ -181,7 +182,6 @@ jobs: clang-runtime: '16' cling: Off cppyy: Off - #Commented out until rest of ci for Windows tested #- name: win2022-msvc-clang-repl-16-cppyy # os: windows-2022 # compiler: msvc @@ -195,7 +195,6 @@ jobs: cling: On cling-version: '1.0' cppyy: Off - #Commented out until rest of ci for Windows tested #- name: win2022-msvc-cling-cppyy # os: windows-2022 # compiler: msvc @@ -203,6 +202,66 @@ jobs: # cling: On # cling-version: '1.0' # cppyy: On + - name: osx14-arm-clang-clang-repl-17 + os: macos-14 + compiler: clang + clang-runtime: '17' + cling: Off + cppyy: Off + - name: osx14-arm-clang-clang-repl-17-cppyy + os: macos-14 + compiler: clang + clang-runtime: '17' + cling: Off + cppyy: On + - name: osx14-arm-clang-clang-repl-17-xeus-clang-repl + os: macos-14 + compiler: clang + clang-runtime: '17' + cling: Off + cppyy: On + xeus-clang-repl: On + - name: osx14-arm-clang-clang-repl-16 + os: macos-14 + compiler: clang + clang-runtime: '16' + cling: Off + cppyy: Off + - name: osx14-arm-clang-clang-repl-16-cppyy + os: macos-14 + compiler: clang + clang-runtime: '16' + cling: Off + cppyy: On + - name: osx14-arm-clang-clang-repl-16-xeus-clang-repl + os: macos-14 + compiler: clang + clang-runtime: '16' + cling: Off + cppyy: On + xeus-clang-repl: On + - name: osx14-arm-clang-clang13-cling + os: macos-14 + compiler: clang + clang-runtime: '13' + cling: On + cling-version: '1.0' + cppyy: Off + - name: osx14-arm-clang-clang13-cling-cppyy + os: macos-14 + compiler: clang + clang-runtime: '13' + cling: On + cling-version: '1.0' + cppyy: On + - name: osx14-arm-clang-clang13-cling-xeus-clang-repl + os: macos-14 + compiler: clang + clang-runtime: '13' + cling: On + cling-version: '1.0' + cppyy: On + xeus-clang-repl: On - name: osx13-x86-clang-clang-repl-17 os: macos-13 compiler: clang @@ -263,69 +322,6 @@ jobs: cling-version: '1.0' cppyy: On xeus-clang-repl: On - #Block commented out until free tier for m1 - #exists (expected sometime 2024) and key for os - #can be replaced - #- name: osx13-arm64-clang-clang-repl-17 - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '17' - # cling: Off - # cppyy: Off - #- name: osx13-arm64-clang-clang-repl-17-cppyy - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '17' - # cling: Off - # cppyy: On - #- name: osx13-arm64-clang-clang-repl-17-xeus-clang-repl - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '17' - # cling: Off - # cppyy: On - # xeus-clang-repl: On - #- name: osx13-arm64-clang-clang-repl-16 - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '16' - # cling: Off - # cppyy: Off - #- name: osx13-arm64-clang-clang-repl-16-cppyy - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '16' - # cling: Off - # cppyy: On - #- name: osx13-arm64-clang-clang-repl-16-xeus-clang-repl - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '16' - # cling: Off - # cppyy: On - # xeus-clang-repl: On - #- name: osx13-arm64-clang-clang13-cling - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '13' - # cling: On - # cling-version: '1.0' - # cppyy: Off - #- name: osx13-arm64-clang-clang13-cling-cppyy - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '13' - # cling: On - # cling-version: '1.0' - # cppyy: On - #- name: osx13-arm64-clang-clang13-cling-xeus-clang-repl - # os: macos-13-arm64 - # compiler: clang - # clang-runtime: '13' - # cling: On - # cling-version: '1.0' - # cppyy: On - # xeus-clang-repl: On steps: - uses: actions/checkout@v3 @@ -362,7 +358,6 @@ jobs: - name: Save PR Info on Windows systems if: ${{ runner.os == 'windows' }} run: | - #FIXME: CLING AND LLVM HASH currently hardcoded until windows equivalent of unix commands #can be found mkdir ./pr echo "${{ github.event.number }}" > ./pr/NR @@ -710,8 +705,11 @@ jobs: echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV - name: Build and Test/Install CppInterOp on Windows systems + continue-on-error: true if: ${{ runner.os == 'windows' }} run: | + #FIXME: Windows CppInterOp tests expected to fail + #until https://github.com/compiler-research/CppInterOp/issues/188 is solved $env:PWD_DIR= $PWD.Path $env:LLVM_DIR="$env:PWD_DIR\llvm-project" diff --git a/README.md b/README.md index 5a48f4443..6493dde44 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,7 @@ cmake --build . --target install --parallel $(nproc --all) ``` and ``` -cmake -DUSE_CLING=Off -DUSE_REPL=ON -DLLVM_DIR=$LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR .. +cmake -DUSE_CLING=Off -DUSE_REPL=ON -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 @@ -254,7 +254,7 @@ cmake --build . --target install --parallel $(nproc --all) ``` and ``` -cmake -DUSE_CLING=ON -DUSE_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=$env:CPPINTEROP_DIR .. +cmake -DUSE_CLING=ON -DUSE_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 ``` diff --git a/cmake/modules/GoogleTest.cmake b/cmake/modules/GoogleTest.cmake index c2d3fffba..035289f47 100644 --- a/cmake/modules/GoogleTest.cmake +++ b/cmake/modules/GoogleTest.cmake @@ -7,7 +7,7 @@ set(_gtest_byproducts ${_gtest_byproduct_binary_dir}/lib/libgmock_main.a ) -if(MSVC) +if(WIN32) set(EXTRA_GTEST_OPTS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=${_gtest_byproduct_binary_dir}/lib/ -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL:PATH=${_gtest_byproduct_binary_dir}/lib/ diff --git a/lib/Interpreter/CppInterOp.cpp b/lib/Interpreter/CppInterOp.cpp index fbdb01041..f70bc6443 100644 --- a/lib/Interpreter/CppInterOp.cpp +++ b/lib/Interpreter/CppInterOp.cpp @@ -34,7 +34,7 @@ #include // Stream redirect. -#ifdef WIN32 +#ifdef _WIN32 #include #ifndef STDOUT_FILENO #define STDOUT_FILENO 1 diff --git a/unittests/CppInterOp/TestSharedLib/TestSharedLib.h b/unittests/CppInterOp/TestSharedLib/TestSharedLib.h index 65b1d2fde..92633cdb7 100644 --- a/unittests/CppInterOp/TestSharedLib/TestSharedLib.h +++ b/unittests/CppInterOp/TestSharedLib/TestSharedLib.h @@ -2,7 +2,7 @@ #define UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB_H // Avoid having to mangle/demangle the symbol name in tests -#ifdef WIN32 +#ifdef _WIN32 extern "C" __declspec(dllexport) int ret_zero(); #else extern "C" int ret_zero();