mesa/src/util/blake3/meson.build
Dmitry Baryshkov b9c6afd3a7
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
meson: disable SIMD blake optimisations on x32 host
On X.org startup libgallium crashes on x32 hosts inside
blake3_hash_many_sse41(), most likely because of the different pointer
size. Disable SIMD blake implementation if x32 is detected.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34453>
2025-04-11 20:57:38 +00:00

52 lines
1.9 KiB
Meson

files_blake3 = [
'blake3.c',
'blake3_dispatch.c',
'blake3_portable.c'
]
blake3_defs = []
is_windows = host_machine.system() == 'windows'
is_msvc = meson.get_compiler('c').get_id() == 'msvc'
cpu_family = host_machine.cpu_family()
blake3_x86_no_simd_defs = ['-DBLAKE3_NO_SSE2', '-DBLAKE3_NO_SSE41', '-DBLAKE3_NO_AVX2', '-DBLAKE3_NO_AVX512']
if cpu_family == 'x86_64'
if is_windows
if is_msvc
# An up-to-date version of Meson, not using the VS backend is needed.
# See https://github.com/mesonbuild/meson/issues/11653
if meson.backend() == 'ninja' and add_languages('masm', required : false)
files_blake3 += ['blake3_sse2_x86-64_windows_msvc.masm', 'blake3_sse41_x86-64_windows_msvc.masm', 'blake3_avx2_x86-64_windows_msvc.masm', 'blake3_avx512_x86-64_windows_msvc.masm']
else
blake3_defs += blake3_x86_no_simd_defs
endif
else
files_blake3 += ['blake3_sse2_x86-64_windows_gnu.S', 'blake3_sse41_x86-64_windows_gnu.S', 'blake3_avx2_x86-64_windows_gnu.S', 'blake3_avx512_x86-64_windows_gnu.S']
endif
# Disable blake assembly for x32, x86-64 with 32-bit pointers.
# GNU triplet is x86_64-linux-gnux32
elif cc.sizeof('void *') == 4
blake3_defs += blake3_x86_no_simd_defs
else
files_blake3 += ['blake3_sse2_x86-64_unix.S', 'blake3_sse41_x86-64_unix.S', 'blake3_avx2_x86-64_unix.S', 'blake3_avx512_x86-64_unix.S']
endif
elif cpu_family == 'x86'
# There are no assembly versions for 32-bit x86. Compiling the C versions require a different compilation flag per
# file, which is not well supported by Meson. Leave SIMD support out for now.
blake3_defs += blake3_x86_no_simd_defs
elif cpu_family == 'aarch64'
files_blake3 += ['blake3_neon.c']
endif
blake3 = static_library(
'blake3',
files_blake3,
c_args : blake3_defs,
gnu_symbol_visibility : 'hidden',
build_by_default : false,
)
idep_blake3 = declare_dependency(
link_with : blake3,
)