Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Add C++ linkage specification in SYCL assert headers (#15570)
Some SYCL applications are seeing compilation failures related to the SYCL assert headers. Specifically, they are wrapping the SYCL assert headers in C linkage specifications in their applications. These headers in turn include files that contain templates which emit errors under C linkage specifications so this PR explicitly adds C++ linkage specifications in the header contents to override any extra specification that the clients may add. Here is an example of faulty client code: ``` #ifdef __cplusplus extern "C" { #endif #include <assert.h> #ifdef __cplusplus } #endif int main() {} ``` Error fragments: ``` /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_types.hpp:140:1: error: templates must have C++ linkage 140 | template <typename T, std::size_t R, std::size_t C, MatrixLayout L, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 141 | Scope::Flag S = Scope::Flag::Subgroup, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 142 | MatrixUse U = MatrixUse::MatrixA> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../test.cpp:2:1: note: extern "C" language linkage specification begins here 2 | extern "C" { | ^ In file included from ../test.cpp:5: In file included from /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/sycl/stl_wrappers/assert.h:21: In file included from /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_vars.hpp:13: /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_types.hpp:156:1: error: templates must have C++ linkage 156 | template <typename dataT> | ^~~~~~~~~~~~~~~~~~~~~~~~~ ../test.cpp:2:1: note: extern "C" language linkage specification begins here 2 | extern "C" { | ^ In file included from ../test.cpp:5: In file included from /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/sycl/stl_wrappers/assert.h:21: In file included from /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_vars.hpp:13: /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_types.hpp:158:1: error: templates must have C++ linkage 158 | template <typename dataT> | ^~~~~~~~~~~~~~~~~~~~~~~~~ ../test.cpp:2:1: note: extern "C" language linkage specification begins here 2 | extern "C" { | ^ In file included from ../test.cpp:5: In file included from /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/sycl/stl_wrappers/assert.h:21: In file included from /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_vars.hpp:13: /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_types.hpp:162:1: error: templates must have C++ linkage 162 | template <typename dataT, int dims> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../test.cpp:2:1: note: extern "C" language linkage specification begins here 2 | extern "C" { | ^ In file included from ../test.cpp:5: In file included from /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/sycl/stl_wrappers/assert.h:21: In file included from /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_vars.hpp:13: /nfs/site/home/lbushi/sycl_workspace/llvm/build/bin/../include/CL/__spirv/spirv_types.hpp:177:1: error: templates must have C++ linkage 177 | template <int Bits> using ap_int = _BitInt(Bits); | ^~~~~~~~~~~~~~~~~~~ ../test.cpp:2:1: note: extern "C" language linkage specification begins here 2 | extern "C" { | ^ ```
- Loading branch information