Skip to content

Commit 416b4ec

Browse files
committed
[ur] Add support for clang-cl.exe on Windows
Fix compilation of passing function pointers to `std::ostream`s when compiling with `clang-cl.exe` on Windows. Extend the GitHub Actions matrix on Windows to test both the `cl.exe` and `clang-cl.exe` compiler frontends.
1 parent f12e1fb commit 416b4ec

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

.github/workflows/cmake.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
matrix:
9999
os: ['windows-2019', 'windows-2022']
100100
build_type: [Debug, Release]
101+
compiler: [{c: cl.exe, cxx: cl.exe}, {c: clang-cl.exe, cxx: clang-cl.exe}]
101102
runs-on: ${{matrix.os}}
102103

103104
steps:
@@ -114,6 +115,8 @@ jobs:
114115
run: >
115116
cmake
116117
-B${{github.workspace}}/build
118+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
119+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
117120
-DCMAKE_POLICY_DEFAULT_CMP0094=NEW
118121
-DUR_ENABLE_TRACING=ON
119122
-DUR_DEVELOPER_MODE=ON

cmake/helpers.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function(add_ur_target_compile_options name)
7878
endif()
7979
elseif(MSVC)
8080
target_compile_options(${name} PRIVATE
81-
/MP
81+
$<$<CXX_COMPILER_ID:MSVC>:/MP> # clang-cl.exe does not support /MP
8282
/W3
8383
/MD$<$<CONFIG:Debug>:d>
8484
/GS

scripts/templates/params.hpp.mako

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ from templates import helper as th
3636
${x}_params::serializePtr(os, ${caller.body()});
3737
%elif th.type_traits.is_handle(itype):
3838
${x}_params::serializePtr(os, ${caller.body()});
39+
%elif iname and iname.startswith("pfn"):
40+
os << reinterpret_cast<void*>(${caller.body()});
3941
%else:
4042
os << ${caller.body()};
4143
%endif

source/common/ur_params.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11342,7 +11342,7 @@ operator<<(std::ostream &os,
1134211342
os << ", ";
1134311343
os << ".pfnDeleter = ";
1134411344

11345-
os << *(params->ppfnDeleter);
11345+
os << reinterpret_cast<void *>(*(params->ppfnDeleter));
1134611346

1134711347
os << ", ";
1134811348
os << ".pUserData = ";
@@ -12995,7 +12995,7 @@ operator<<(std::ostream &os,
1299512995
os << ", ";
1299612996
os << ".pfnNotify = ";
1299712997

12998-
os << *(params->ppfnNotify);
12998+
os << reinterpret_cast<void *>(*(params->ppfnNotify));
1299912999

1300013000
os << ", ";
1300113001
os << ".pUserData = ";

0 commit comments

Comments
 (0)