intel/uuid: use git-sha1/package for the driver UUID

We can't read information from the loaded shared object because we have
different objects for Vulkan and OpenGL drivers, but we need to share
the same UUID for both.

Hence let's use SHA1 from the Git commit and package version.

v2: use also package version for the case of building from tarball (Eric)
v3: fix typos in comment (Tapani)

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7025>
diff --git a/src/intel/common/gen_uuid.c b/src/intel/common/gen_uuid.c
index 02dfb54..921c43d 100644
--- a/src/intel/common/gen_uuid.c
+++ b/src/intel/common/gen_uuid.c
@@ -22,7 +22,7 @@
  */
 
 #include "gen_uuid.h"
-#include "util/build_id.h"
+#include "git_sha1.h"
 #include "util/mesa-sha1.h"
 
 void
@@ -56,18 +56,20 @@
                            const struct gen_device_info *devinfo,
                            size_t size)
 {
-   const struct build_id_note *note =
-      build_id_find_nhdr_for_addr(gen_uuid_compute_driver_id);
-   assert(note && "Failed to find build-id");
+   const char* intelDriver = PACKAGE_VERSION MESA_GIT_SHA1;
+   struct mesa_sha1 sha1_ctx;
+   uint8_t sha1[20];
 
-   unsigned build_id_len = build_id_length(note);
-   assert(build_id_len >= size && "build-id too short");
+   assert(size <= sizeof(sha1));
 
    /* The driver UUID is used for determining sharability of images and memory
-    * between two Vulkan instances in separate processes, or for
-    * interoperability between Vulkan and OpenGL.  People who want to * share
-    * memory need to also check the device UUID so all this * needs to be is
-    * the build-id.
+    * between two Vulkan instances in separate processes, but also to
+    * determining memory objects and sharability between Vulkan and OpenGL
+    * driver. People who want to share memory need to also check the device
+    * UUID.
     */
-   memcpy(uuid, build_id_data(note), size);
+   _mesa_sha1_init(&sha1_ctx);
+   _mesa_sha1_update(&sha1_ctx, intelDriver, strlen(intelDriver) * sizeof(char));
+   _mesa_sha1_final(&sha1_ctx, sha1);
+   memcpy(uuid, sha1, size);
 }