util: bring back fix to avoid strict aliasing bugs in xxhash

This is commit b9e163fa67 that got lost in xxhash upgrade 070bf8986c.

Fixes graphics artifacts seen in multiple workloads with Intel driver
when using clang compiler.

Fixes also CTS tests:

 dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_cubemap
 dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_3d
 dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_2d_array
 dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_2d_multisample_array

v2: pass arguments from meson.build instead of hardcoding
    (Eric Engestrom)

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14684
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14107
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13895
Fixes: 070bf8986c ("util: Upgrade xxhash.h to v0.8.3")
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
(cherry picked from commit d2351b3d04)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40092>
This commit is contained in:
Tapani Pälli 2026-02-23 09:08:17 +02:00 committed by Eric Engestrom
parent a457021d67
commit befb9af14b
2 changed files with 7 additions and 1 deletions

View file

@ -794,7 +794,7 @@
"description": "util: bring back fix to avoid strict aliasing bugs in xxhash",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "070bf8986ce08bc58d1263fefb9e2e33de9e6bf4",
"notes": null

View file

@ -349,9 +349,15 @@ _libmesa_util = static_library(
build_by_default : false
)
# Mesa leaves strict aliasing on in the compiler, and xxhash code likes to
# dereference the passed in data as u32*, which means that the compiler is
# free to move the u32 read before the write of the struct members being
# hashed, and in practice it did in Freedreno and Intel drivers.
# Forcing 2 flags below prevents it.
idep_mesautil = declare_dependency(
sources : [shader_stats_h],
link_with : _libmesa_util,
compile_args : [ '-DXXH_FORCE_ALIGN_CHECK=0', '-DXXH_FORCE_MEMORY_ACCESS=0' ],
include_directories : [inc_util],
dependencies : deps_for_libmesa_util,
)