mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
util: add disk_cache_get_function_identifier()
This can be used as a drop in replacement for
disk_cache_get_function_timestamp().
Here we use build-id to generate a driver-id rather than build
timestamp if available. This should resolve issues such as
distros using reproducable builds and flatpak not having
real build timestamps.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 83ea8dd99b)
This commit is contained in:
parent
d776ccd2da
commit
06e726ddb5
1 changed files with 16 additions and 0 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include "util/build_id.h"
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -112,6 +113,21 @@ disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
disk_cache_get_function_identifier(void *ptr, uint32_t *id)
|
||||
{
|
||||
#ifdef HAVE_DL_ITERATE_PHDR
|
||||
const struct build_id_note *note = NULL;
|
||||
if ((note = build_id_find_nhdr_for_addr(ptr))) {
|
||||
const uint8_t *id_sha1 = build_id_data(note);
|
||||
assert(id_sha1);
|
||||
*id = *id_sha1;
|
||||
return true;
|
||||
} else
|
||||
#endif
|
||||
return disk_cache_get_function_timestamp(ptr, id);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Provide inlined stub functions if the shader cache is disabled. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue