diff --git a/meson.build b/meson.build index 766883d84e7..23ab29c7e3c 100644 --- a/meson.build +++ b/meson.build @@ -811,7 +811,7 @@ if with_gallium_rusticl or with_nouveau_vk or with_tools.contains('etnaviv') endif endif -with_clc = with_microsoft_clc or with_intel_clc or with_gallium_asahi or with_asahi_vk or with_gallium_rusticl +with_clc = get_option('mesa-clc') != 'auto' or with_microsoft_clc or with_intel_clc or with_gallium_asahi or with_asahi_vk or with_gallium_rusticl dep_clc = null_dep if with_gallium_clover or with_clc diff --git a/meson_options.txt b/meson_options.txt index 27a4fcff247..0b9282cccd6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -743,3 +743,20 @@ option( 'none', 'dri2' ], ) + +option( + 'mesa-clc', + type : 'combo', + value : 'auto', + choices : [ + 'enabled', 'system', 'auto' + ], + description : 'Build the mesa-clc compiler or use a system version.' +) + +option( + 'install-mesa-clc', + type : 'boolean', + value : false, + description : 'Install the mesa-clc compiler (if needed for cross builds).' +) diff --git a/src/compiler/clc/meson.build b/src/compiler/clc/meson.build index 74767d08de2..4875d71ca21 100644 --- a/src/compiler/clc/meson.build +++ b/src/compiler/clc/meson.build @@ -117,15 +117,20 @@ idep_mesaclc = declare_dependency( link_args : _idep_mesaclc_link_args, ) -prog_mesa_clc = executable( - 'mesa_clc', - ['mesa_clc.c'], - include_directories : [inc_include, inc_src], - c_args : [pre_args, no_override_init_args], - link_args : [ld_args_build_id], - dependencies : [idep_mesaclc, dep_llvm, dep_spirv_tools, idep_getopt], - # If we can run host binaries directly, just build mesa_clc for the host. - # Most commonly this happens when doing a cross compile from an x86_64 build - # machine to an x86 host - native : not meson.can_run_host_binaries(), -) +if get_option('mesa-clc') == 'system' + prog_mesa_clc = find_program('mesa_clc', native : true) +else + prog_mesa_clc = executable( + 'mesa_clc', + ['mesa_clc.c'], + include_directories : [inc_include, inc_src], + c_args : [pre_args, no_override_init_args], + link_args : [ld_args_build_id], + dependencies : [idep_mesaclc, dep_llvm, dep_spirv_tools, idep_getopt], + # If we can run host binaries directly, just build mesa_clc for the host. + # Most commonly this happens when doing a cross compile from an x86_64 build + # machine to an x86 host + native : not meson.can_run_host_binaries(), + install : get_option('install-mesa-clc'), + ) +endif diff --git a/src/compiler/spirv/meson.build b/src/compiler/spirv/meson.build index 07ef13faf6e..451fc98a9cc 100644 --- a/src/compiler/spirv/meson.build +++ b/src/compiler/spirv/meson.build @@ -77,12 +77,14 @@ spirv2nir = executable( install : with_tools.contains('nir'), ) +if get_option('mesa-clc') == 'system' + prog_vtn_bindgen = find_program('vtn_bindgen', native : true) # Due to the cross build issues in current meson, we only build vtn_bindgen when -# building drivers that need it. +# building drivers that need it or mesa-clc is explictly required. # # XXX: Build by default once https://github.com/mesonbuild/meson/pull/12022 # ships. -if with_gallium_asahi or with_asahi_vk +elif get_option('mesa-clc') != 'auto' or with_gallium_asahi or with_asahi_vk prog_vtn_bindgen = executable( 'vtn_bindgen', ['vtn_bindgen.c'], @@ -93,6 +95,7 @@ if with_gallium_asahi or with_asahi_vk # Most commonly this happens when doing a cross compile from an x86_64 build # machine to an x86 host native : not meson.can_run_host_binaries(), + install : get_option('install-mesa-clc'), ) endif