diff options
author | Matt Turner <[email protected]> | 2017-02-14 08:21:43 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2017-02-15 13:59:51 -0800 |
commit | 656e30b6860461b2bd725590488126d5e7e10ec1 (patch) | |
tree | 5b331637303f495d07dee423700eabb0a9c96dca /src | |
parent | d4fa083e11fa71abd50e615d6f02b6da4ea34644 (diff) |
anv: Use build-id for pipeline cache UUID.
The --build-id=... ld flag has been present since binutils-2.18,
released 28 Aug 2007.
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/Makefile.am | 1 | ||||
-rw-r--r-- | src/intel/vulkan/anv_device.c | 28 |
2 files changed, 8 insertions, 21 deletions
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am index 95f276ed7e1..4197b0e77c7 100644 --- a/src/intel/vulkan/Makefile.am +++ b/src/intel/vulkan/Makefile.am @@ -165,6 +165,7 @@ libvulkan_intel_la_LDFLAGS = \ -module \ -no-undefined \ -avoid-version \ + -Wl,--build-id=sha1 \ $(BSYMBOLIC) \ $(GC_SECTIONS) \ $(LD_NO_UNDEFINED) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index d1a6cc8e9c0..cae5feff948 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -21,18 +21,17 @@ * IN THE SOFTWARE. */ -#include <dlfcn.h> #include <assert.h> #include <stdbool.h> #include <string.h> #include <sys/mman.h> -#include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include "anv_private.h" #include "util/strtod.h" #include "util/debug.h" +#include "util/build_id.h" #include "util/vk_util.h" #include "genxml/gen7_pack.h" @@ -56,30 +55,17 @@ compiler_perf_log(void *data, const char *fmt, ...) } static bool -anv_get_function_timestamp(void *ptr, uint32_t* timestamp) -{ - Dl_info info; - struct stat st; - if (!dladdr(ptr, &info) || !info.dli_fname) - return false; - - if (stat(info.dli_fname, &st)) - return false; - - *timestamp = st.st_mtim.tv_sec; - return true; -} - -static bool anv_device_get_cache_uuid(void *uuid) { - uint32_t timestamp; + const struct build_id_note *note = build_id_find_nhdr("libvulkan_intel.so"); + if (!note) + return false; - memset(uuid, 0, VK_UUID_SIZE); - if (!anv_get_function_timestamp(anv_device_get_cache_uuid, ×tamp)) + unsigned len = build_id_length(note); + if (len < VK_UUID_SIZE) return false; - snprintf(uuid, VK_UUID_SIZE, "anv-%d", timestamp); + build_id_read(note, uuid, VK_UUID_SIZE); return true; } |