meson: Add mesa-clc and install-mesa-clc options

Due to the cross build issues in current meson, we adds new options to
allow mesa_clc and vtn_bindgen to be installed or searched on the
system.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32719>
This commit is contained in:
Mary Guillemard
2024-12-02 09:11:35 +01:00
committed by Marge Bot
parent 4226be0c75
commit 13fe5a597b
4 changed files with 40 additions and 15 deletions

View File

@@ -811,7 +811,7 @@ if with_gallium_rusticl or with_nouveau_vk or with_tools.contains('etnaviv')
endif endif
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 dep_clc = null_dep
if with_gallium_clover or with_clc if with_gallium_clover or with_clc

View File

@@ -743,3 +743,20 @@ option(
'none', 'dri2' '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).'
)

View File

@@ -117,15 +117,20 @@ idep_mesaclc = declare_dependency(
link_args : _idep_mesaclc_link_args, link_args : _idep_mesaclc_link_args,
) )
prog_mesa_clc = executable( if get_option('mesa-clc') == 'system'
'mesa_clc', prog_mesa_clc = find_program('mesa_clc', native : true)
['mesa_clc.c'], else
include_directories : [inc_include, inc_src], prog_mesa_clc = executable(
c_args : [pre_args, no_override_init_args], 'mesa_clc',
link_args : [ld_args_build_id], ['mesa_clc.c'],
dependencies : [idep_mesaclc, dep_llvm, dep_spirv_tools, idep_getopt], include_directories : [inc_include, inc_src],
# If we can run host binaries directly, just build mesa_clc for the host. c_args : [pre_args, no_override_init_args],
# Most commonly this happens when doing a cross compile from an x86_64 build link_args : [ld_args_build_id],
# machine to an x86 host dependencies : [idep_mesaclc, dep_llvm, dep_spirv_tools, idep_getopt],
native : not meson.can_run_host_binaries(), # 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

View File

@@ -77,12 +77,14 @@ spirv2nir = executable(
install : with_tools.contains('nir'), 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 # 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 # XXX: Build by default once https://github.com/mesonbuild/meson/pull/12022
# ships. # 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( prog_vtn_bindgen = executable(
'vtn_bindgen', 'vtn_bindgen',
['vtn_bindgen.c'], ['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 # Most commonly this happens when doing a cross compile from an x86_64 build
# machine to an x86 host # machine to an x86 host
native : not meson.can_run_host_binaries(), native : not meson.can_run_host_binaries(),
install : get_option('install-mesa-clc'),
) )
endif endif