<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/122453>122453</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            OpenCL C++: printf becomes mangled c++ symbol, not working with e.g. pocl and llvm-spirv
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          davidrohr
      </td>
    </tr>
</table>

<pre>
    With clang 19.1.3, the following example
```
__kernel void test()
{
 printf("test");
}
```
compiles in OpenCL C mode to SPIRV:
```
clang++ --target=spirv64 -cl-std=CL2.0 -fno-integrated-objemitter -o test.spirv test.cl -O0
```
but in C++ for OpenCL mode
```
clang++ --target=spirv64 -cl-std=CLC++2021 -fno-integrated-objemitter -o test.spirv test.cl -O0
```
I get:
```
error: 0: Unresolved external reference to "_Z6printfPU3AS2Kcz".
clang++: error: spirv-link command failed with exit code 1 (use -v to see invocation)
```
(the same happens with `-cl-std clc++`).

It seems that the LLVM-SPIRV translater expects an unmangled printf symbol, but llvm emits a C++ mangled symbol.
It works when I use the experimental internal SPIRV emiter via `-fintegrated-objemitter`.

Also with POCL it does not work due to the mangled symbol (see https://github.com/pocl/pocl/issues/1759), thus I assume llvm should produce an unmangled printf symbol as specified in OpenCL 1.2. Or all other software packages will need to adapt for `clc++`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVEuL4zgQ_jXypbCR5cSxDz7kQUOzWXrYYWZhL40sVWxNy5KR5KRnf_0i2_1kmcOyEOIQS1Xfq4p7rzqD2JDtgWxPCZ9Cb10j-VVJZ3uXtFb-bP5UoQehuekgr7M8Kwg7QugRLlZre1OmA3zmw6iR0D0p6fqh-8fHJ3QGNVytkhDQB8Iqwup4bHcgdA-jUyZc5n_Z8p7F98VhPnL6VE_YYVQaPSgDDyOa4xmOMFiJECx8_XL_x3dS7D_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