On Sat, 2022-09-17 at 14:56 +0300, Andrey Konovalov wrote:
> When building an OpenCL program clover needs to locate opencl-c.h
> include file. This include file location is passed via cpp args using
> CLANG_RESOURCE_DIR macro. To set CLANG_RESOURCE_DIR value meson currently
> uses "$(llvm-config --libdir)" which results in path to sysroot included
> into CLANG_RESOURCE_DIR. Then clBuildProgram() fails with
> "fatal error: 'opencl-c.h' file not found".
> 
> Work this around by using '/usr/lib' instead of the libdir value
> exported by LLVM.
> 
> Microsoft/Intel CLC should suffer from the same issue, and the similar
> workaround should work in this case too.
> 
> Signed-off-by: Andrey Konovalov <[email protected]>
> ---
>  ...-meson.CLANG_RESOURCE_DIR-workaround.patch | 42 +++++++++++++++++++
>  meta/recipes-graphics/mesa/mesa.inc           |  1 +
>  2 files changed, 43 insertions(+)
>  create mode 100644 
> meta/recipes-graphics/mesa/files/0001-meson.CLANG_RESOURCE_DIR-workaround.patch
> 
> diff --git 
> a/meta/recipes-graphics/mesa/files/0001-meson.CLANG_RESOURCE_DIR-workaround.patch
>  
> b/meta/recipes-graphics/mesa/files/0001-meson.CLANG_RESOURCE_DIR-workaround.patch
> new file mode 100644
> index 0000000000..db60fe407f
> --- /dev/null
> +++ 
> b/meta/recipes-graphics/mesa/files/0001-meson.CLANG_RESOURCE_DIR-workaround.patch
> @@ -0,0 +1,42 @@
> +From: Andrey Konovalov <[email protected]>
> +Date: Fri, 16 Sep 2022 16:58:20 +0000
> +Subject: [PATCH] CLANG_RESOURCE_DIR workaround
> +
> +Setting CLANG_RESOURCE_DIR to "$(llvm-config --libdir)something"
> +results in clBuildProgram() error when an OpenCL program is being
> +built on the target. The reason is that $(llvm-config --libdir) output
> +includes path to the sysroot directory.
> +
> +Work this around by using '/usr/lib' instead of the libdir value
> +exported by LLVM.
> +
> +Upstream-Status: Inappropriate
> +Signed-off-by: Andrey Konovalov <[email protected]>
> +
> +---
> +
> +--- a/src/gallium/frontends/clover/meson.build       2022-09-16 
> 10:24:55.910577158 +0000
> ++++ b/src/gallium/frontends/clover/meson.build       2022-09-16 
> 10:28:13.112804197 +0000
> +@@ -71,8 +71,7 @@ libclllvm = static_library(
> +     clover_opencl_cpp_args,
> +     clover_spirv_cpp_args,
> +     '-DCLANG_RESOURCE_DIR="@0@"'.format(join_paths(
> +-      dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 
> 'libdir'), 'clang',
> +-      dep_llvm.version(), 'include',
> ++      '/usr/lib', 'clang', dep_llvm.version(), 'include',
> +     )),
> +   ],
> +   gnu_symbol_visibility : 'hidden',
> +--- a/src/compiler/clc/meson.build   2022-09-16 16:40:10.641735401 +0000
> ++++ b/src/compiler/clc/meson.build   2022-09-16 16:50:18.095700452 +0000
> +@@ -39,7 +39,9 @@ files_libclc = files(
> +   'clc_helpers.cpp',
> + )
> + 
> +-_libclc_cpp_args = ['-DCLANG_RESOURCE_DIR="@0@"'.format(clang_resource_dir)]
> ++_libclc_cpp_args = ['-DCLANG_RESOURCE_DIR="@0@"'.format(join_paths(
> ++                       '/usr/lib', 'clang', dep_llvm.version(), 'include'
> ++                    ))]
> + if with_microsoft_clc
> +   _libclc_cpp_args += ['-DUSE_STATIC_OPENCL_C_H=1']
> + endif

libdir might not be /usr/lib so this isn't always going to be
correct...

Cheers,

Richard
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#170834): 
https://lists.openembedded.org/g/openembedded-core/message/170834
Mute This Topic: https://lists.openembedded.org/mt/93741466/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to