[Buildroot] [PATCH v4 4/7] package/opencl-headers: new package

Antoine Coutant antoine.coutant at smile.fr
Wed Feb 21 13:26:10 UTC 2024


Yann, All,

On 12/02/2024 14:44, Antoine Coutant wrote:
>
> Yann, All,
>
> On 07/02/2024 16:58, Yann E. MORIN wrote:
>> Antoine, All,
>>
>> On 2024-02-02 10:36 +0100, Antoine Coutant spake thusly:
>>> From: Sebastian Weyer<sebastian.weyer at smile.fr>
>>>
>>> These headers provide the C language API bindings. It is a complement to
>>> the C++ bindings already available in opencl-clhpp. This package is
>>> required to build opencl-icd-loader:
>>>
>>> https://github.com/KhronosGroup/OpenCL-ICD-Loader#dependencies
>>>
>>> Signed-off-by: Sebastian Weyer<sebastian.weyer at smile.fr>
>>> Signed-off-by: Antoine Coutant<antoine.coutant at smile.fr>
>>> ---
>> [--SNIP--]
>>> diff --git a/package/opencl-headers/Config.in b/package/opencl-headers/Config.in
>>> new file mode 100644
>>> index 0000000000..092d8a2a4d
>>> --- /dev/null
>>> +++ b/package/opencl-headers/Config.in
>>> @@ -0,0 +1,7 @@
>>> +config BR2_PACKAGE_OPENCL_HEADERS
>>> +	bool "opencl-headers"
>>> +	depends on BR2_PACKAGE_HAS_LIBOPENCL
>> BR2_PACKAGE_HAS_LIBOPENCL can be set by mesa3d when BR2_PACKAGE_MESA3D_OPENCL
>> is enabled. In this case, will mesa3d install its own headers? If so,
>> that will generate a conflict.
>
> BR2_PACKAGE_HAS_LIBOPENCL doesn't guarantee that CL headers
>
> will be installed. Mesa3d install headers if Clover is enabled and
>
> opencl-icd is disabled [1]. So you are right, it will generate conflict in
>
> case OpenCL-Headers and Clover are built without icd mode.
>
>> Furthermore, this will also conflict with mesa3d-headers, and it also
>> installs CL headers.
> Yes, this will generate the same conflict here...


Besides, the Mesa build system does not install headers if icd option

is enabled. I think the reason is that OpenCL-ICD-Loader explicitly

depends on OpenCL-Headers [1]. Thus, mesa lets users install the

headers that match opencl-icd-loader version.


Mesa build system is designed to not install CL headers when they

are installed by ICD Loader. However, Buildroot package

mesa3d-headers does not check this condition and install CL headers

as soon as libopencl is present. Thus, I think that I will add a

dependency to prevent mesa3d-headers from installing headers when

OpenCL-Headers package is selected.


[1]: 
https://github.com/KhronosGroup/OpenCL-ICD-Loader?tab=readme-ov-file#dependencies


>> So, why do we need opencl-headers and can't rely on the existing
>> mesa3d-headers package?
>
> The problem is that the headers installed by mesa differ from those
>
> in the OpenCL-Headers package.
>
> $ diff -q OpenCL-Headers/CL/cl_icd.h mesa/include/CL/cl_icd.h
> Files OpenCL-Headers/CL/cl_icd.h and mesa/include/CL/cl_icd.h differ
>
> This diff was performed using OpenCL-Headers v2023.12.14 and
>
> mesa-23.3.4. Moreover, cl_layer.h, cl_half.h and cl_function_types.h 
> files are
>
> missing from mesa headers. These differences causes errors when building
>
> opencl-icd-loader:
>
> ...
>
> ./build/opencl-icd-loader-2023.12.14/loader/icd.c:23:10: fatal error: 
> CL/cl_layer.h: No such file or directory
>
>    23 | #include <CL/cl_layer.h>
>
> | ^~~~~~~~~~~~~~~
>
> compilation terminated.
>
> ./build/opencl-icd-loader-2023.12.14/loader/icd_dispatch.c:26:8: 
> error: unknown type name ‘clGetICDLoaderInfoOCLICD_t’
>
>    26 | static clGetICDLoaderInfoOCLICD_t clGetICDLoaderInfoOCLICD;
>
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ...
>
> This is why we cannot rely on mesa3d headers and why OpenCL-Headers
>
> package is required.
>
>> Regards,
>> Yann E. MORIN.
>
> I will add guards to prevent conflicts in the v5. And add some lines
>
> in the commit log to explain why mesa3d headers can't be used to
>
> build OpenCL-ICD-Loader.
>
>
> Thanks for your feedback !
>
>
> [1]: 
> https://gitlab.freedesktop.org/mesa/mesa/-/blob/23.3/include/meson.build?ref_type=heads#L135
>
>
> Regards,
>
> Antoine Coutant
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildroot.org/pipermail/buildroot/attachments/20240221/dcbf2e75/attachment-0001.html>


More information about the buildroot mailing list