[Mesa-dev] [PATCH v4 2/4] anv: use cache uuid based on the build timestamp.

Emil Velikov emil.l.velikov at gmail.com
Fri Jun 24 18:59:12 UTC 2016


From: Emil Velikov <emil.velikov at collabora.com>

Do not rely on the git sha1:
 - its current truncated form makes it less unique
 - it does not attribute for local (Vulkand or otherwise) changes

Use a timestamp produced at the time of build. It's perfectly unique,
unless someone explicitly thinkers with their system clock. Even then
chances of producing the exact same one are very small, if not zero.

v2: Remove .tmp rule. Its not needed since we want for the header to be
regenerated on each time we call make (Eric).

v3:
 - Honour SOURCE_DATE_EPOCH, to make the build reproducible (Michel)
 - Replace the generated header with a define, to prevent needless
builds on consecutive `make' and/or `make install' calls. (Dave)

v4:
 - Keep the timestamp generation at make time. (Jason)

Cc: Michel Dänzer <michel at daenzer.net>
Cc: Dave Airlie <airlied at gmail.com>
Cc: Jason Ekstrand <jason at jlekstrand.net>
Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
This should resolve the incremental builds, yet the solution looks quite
nasty. As always, input on a cleaner one is appreciated.
---
 configure.ac                      |  2 ++
 src/intel/vulkan/Makefile.am      | 12 ++++++++----
 src/intel/vulkan/Makefile.sources |  4 +++-
 src/intel/vulkan/anv_device.c     |  3 +--
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index cc9bc47..acdb8c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2593,6 +2593,8 @@ AC_SUBST([XA_MINOR], $XA_MINOR)
 AC_SUBST([XA_TINY], $XA_TINY)
 AC_SUBST([XA_VERSION], "$XA_MAJOR.$XA_MINOR.$XA_TINY")
 
+AC_SUBST([TIMESTAMP_CMD], '`test $(SOURCE_DATE_EPOCH) && echo $(SOURCE_DATE_EPOCH) || date +%s`')
+
 AC_ARG_ENABLE(valgrind,
               [AS_HELP_STRING([--enable-valgrind],
                              [Build mesa with valgrind support (default: auto)])],
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 4d9ff90..c2ebc28 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -33,10 +33,11 @@ lib_LTLIBRARIES = libvulkan_intel.la
 check_LTLIBRARIES = libvulkan-test.la
 
 PER_GEN_LIBS = \
-   libanv-gen7.la \
-   libanv-gen75.la \
-   libanv-gen8.la \
-   libanv-gen9.la
+	libanv-device.la \
+	libanv-gen7.la \
+	libanv-gen75.la \
+	libanv-gen8.la \
+	libanv-gen9.la
 
 noinst_LTLIBRARIES = $(PER_GEN_LIBS)
 
@@ -63,6 +64,9 @@ AM_CPPFLAGS = \
 
 AM_CFLAGS = -Wno-override-init -msse2
 
+libanv_device_la_CPPFLAGS = $(AM_CPPFLAGS) -DANV_TIMESTAMP=\"$(TIMESTAMP_CMD)\"
+libanv_device_la_SOURCES = $(ANV_DEVICE_FILES)
+
 libanv_gen7_la_CFLAGS = $(AM_CFLAGS) -DGEN_VERSIONx10=70
 libanv_gen7_la_SOURCES = $(GEN7_FILES)
 
diff --git a/src/intel/vulkan/Makefile.sources b/src/intel/vulkan/Makefile.sources
index aa1459a..e4e4884 100644
--- a/src/intel/vulkan/Makefile.sources
+++ b/src/intel/vulkan/Makefile.sources
@@ -24,7 +24,6 @@ VULKAN_FILES := \
 	anv_batch_chain.c \
 	anv_cmd_buffer.c \
 	anv_descriptor_set.c \
-	anv_device.c \
 	anv_dump.c \
 	anv_formats.c \
 	anv_genX.h \
@@ -52,6 +51,9 @@ VULKAN_FILES := \
 	genX_pipeline_util.h \
 	vk_format_info.h
 
+ANV_DEVICE_FILES := \
+	anv_device.c
+
 VULKAN_WSI_WAYLAND_FILES := \
 	anv_wsi_wayland.c
 
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index ea8e875..b463d44 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -28,7 +28,6 @@
 #include <fcntl.h>
 
 #include "anv_private.h"
-#include "git_sha1.h"
 #include "util/strtod.h"
 #include "util/debug.h"
 
@@ -426,7 +425,7 @@ void
 anv_device_get_cache_uuid(void *uuid)
 {
    memset(uuid, 0, VK_UUID_SIZE);
-   snprintf(uuid, VK_UUID_SIZE, "anv-%s", MESA_GIT_SHA1 + 4);
+   snprintf(uuid, VK_UUID_SIZE, "anv-%s", ANV_TIMESTAMP);
 }
 
 void anv_GetPhysicalDeviceProperties(
-- 
2.8.2



More information about the mesa-dev mailing list