From 3619611b31bade726b3dd3d0583ff41a5794cad3 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Wed, 16 Apr 2025 14:35:37 +0300 Subject: [PATCH] mesa-clc: add an option to force inclusion of OpenCL headers Currently mesa-clc bundles OpenCL headers from Clang only if the static LLVM is used (which means Clang / LLVM are not present on the target system). In some cases (e.g. when building in OpenEmbedded environemnt) it is desirable to have shared LLVM library, but skip installing the whole Clang runtime just to compile shaders. Add an option that forces OpenCL headers to be bundled with the mesa-clc binary. Signed-off-by: Dmitry Baryshkov Part-of: (cherry picked from commit 419a9e9d4277cf187f8a2da3ec151beadb00b311) --- .pick_status.json | 2 +- meson.options | 10 ++++++++++ src/compiler/clc/meson.build | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 5c4bb1827d5..fe4941e37eb 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -464,7 +464,7 @@ "description": "mesa-clc: add an option to force inclusion of OpenCL headers", "nominated": false, "nomination_type": 0, - "resolution": 4, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/meson.options b/meson.options index 78e12ba00c8..06ff1b24bd7 100644 --- a/meson.options +++ b/meson.options @@ -795,6 +795,16 @@ option( description : 'Install the mesa-clc compiler (if needed for cross builds).' ) +option( + 'mesa-clc-bundle-headers', + type : 'combo', + value : 'auto', + choices : [ + 'enabled', 'auto' + ], + description : 'Bundle the OpenCL headers into the mesa-clc binary (default to bundle if static LLVM is used). Note, it might require rebuilding mesa-clc if opencl-c.h or opencl-c-base.h are changed (e.g. on Clang upgrades).' +) + option( 'precomp-compiler', type : 'combo', diff --git a/src/compiler/clc/meson.build b/src/compiler/clc/meson.build index 263eba52719..9ff61440f0d 100644 --- a/src/compiler/clc/meson.build +++ b/src/compiler/clc/meson.build @@ -11,7 +11,8 @@ _libmesaclc_c_args = [] _libmesaclc_cpp_args = ['-DLLVM_LIB_DIR="@0@"'.format(llvm_libdir)] _libmesaclc_sources = [] -if not _shared_llvm +if not _shared_llvm or \ + get_option('mesa-clc-bundle-headers') == 'enabled' # LLVM 16 moved clang header path from using full version to only major version if dep_llvm.version().version_compare('< 16') # Prior to LLVM 16, this path used a full version