zink: relax build-id length assertion for Mach-O

`disk_cache_init` asserts `build_id_len == BUILD_ID_EXPECTED_HASH_LENGTH`
(20, the size of a GNU build-id SHA1 on ELF). Mach-O has no GNU
build-id; the closest equivalent is `LC_UUID`, which is 16 bytes.
`build_id_length()` therefore returns a non-20 value on macOS and the
assert fires as soon as `ENABLE_SHADER_CACHE` is on.

Relax the assertion to `<=` so any non-empty build id of acceptable
length is accepted while still catching impossibly long ones. The hash
only needs *some* unique-per-build identifier; the actual byte count
hashed is whatever `build_id_length()` returned.

Cc: mesa-stable
Suggested-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Signed-off-by: Louis Montagne <louis@askem.eu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41361>
This commit is contained in:
Louis Montagne 2026-05-05 16:20:45 +02:00 committed by xpo
parent 28011852f4
commit 14992361a4

View file

@ -318,7 +318,7 @@ disk_cache_init(struct zink_screen *screen)
const struct build_id_note *note =
build_id_find_nhdr_for_addr(disk_cache_init);
unsigned build_id_len = build_id_length(note);
assert(note && build_id_len == BUILD_ID_EXPECTED_HASH_LENGTH);
assert(note && build_id_len <= BUILD_ID_EXPECTED_HASH_LENGTH);
_mesa_blake3_update(&ctx, build_id_data(note), build_id_len);
#endif