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

    <tr>
        <th>Summary</th>
        <td>
            OpenCL C source that does not use image functions cannot be compiled on OpenCL 3.0 devices without image support
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    This issue was discovered with PoCL updating their CUDA device support to OpenCL 3.0, as reported [in this PoCL issue](https://github.com/pocl/pocl/issues/1339). The PoCL CUDA device does not support images, so it does not define the `__opencl_c_images` extension.

As a result, when `opencl-c.h` is included to build *any* device code (even device code that does not make use of image functions or types), the compilation produces 172 errors to the tune of
```
error: /usr/local/lib/../share/pocl/include/opencl-c.h:15178:46: use of type '__read_only image2d_t' requires __opencl_c_images support
```

This has been observed with LLVM 14, 15 and 16 at least.

I believe this is due to the “core” image functions in `opencl-c.h` being declared without proper fencing. The whole section of the header should be fenced by an
```
#if defined(__IMAGE_SUPPORT__) || defined(__opencl_c_images)
```
or similar.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2PozgQ_TXOpTQITAjxgUMmGVYj9ahbuz17RcauBO86NuuP9ObfrwykO93T2igCgase79WrKu69OhnEhlRfSXVY8RgG65rHXtuzvax6K6_N86A8KO8jwgv3IJUX9oIOJbyoMMCT3T9AHCUPypwgDKgc7H8ediDxogSCj-NoXYBg4XFEs3-AMssJ3QP34DAdoQRSfVUGQvrShDd9jlQHQrdDCKMn5Y7QltD2pMIQ-0zYM6HtaIV-u005ntC2KEtGKMvgecAZ7p6PtOjB2PBKTJ35KeXtwVtQ4S1A4lEZTJKAbPKusyMaoTvRLRmbHPDfgMYrazKSH0i-m687Dxwc-qhDgn0Z0CSEOf-LyIaUmopqhI4SZapNH5WWQOiOmyuhr2yFlQiE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