Source: libxsmm
Version: 1.17-1
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0] we noticed that
libxsmm could not be built reproducibly.

This is because it ships a build.txt with an absolute build path and
uses the current date in some headers files. These are fixed in the
attached patch.

However, the ABSDIR (also in build.txt) is embedded in in the libxsmm.a
library in an ELF text header.


 [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
--- a/debian/patches/0003-Reproducible-build.patch      1970-01-01 
01:00:00.000000000 +0100
--- b/debian/patches/0003-Reproducible-build.patch      2022-06-20 
09:01:20.106293806 +0100
@@ -0,0 +1,39 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2022-06-20
+
+--- libxsmm-1.17.orig/scripts/libxsmm_config.py
++++ libxsmm-1.17/scripts/libxsmm_config.py
+@@ -10,9 +10,11 @@
+ # Hans Pabst (Intel Corp.)
+ 
###############################################################################
+ from string import Template
+-from datetime import date
++import datetime
+ import libxsmm_utilities
+ import fnmatch
++import os
++import time
+ import sys
+ 
+ 
+@@ -87,6 +89,10 @@ if __name__ == "__main__":
+         maxn = libxsmm_utilities.max_mnk(mnklist, avgdim, 1)
+         maxk = libxsmm_utilities.max_mnk(mnklist, avgdim, 2)
+ 
++        build_date = datetime.datetime.utcfromtimestamp(
++            int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
++        )
++
+         substitute = {
+             "VERSION": realversion,
+             "BRANCH": branch,
+@@ -94,7 +100,7 @@ if __name__ == "__main__":
+             "MINOR": minor,
+             "UPDATE": update,
+             "PATCH": patch,
+-            "DATE": date.today().strftime("%Y%m%d"),
++            "DATE": build_date.strftime("%Y%m%d"),
+             "CACHELINE": cacheline,
+             "PREFETCH": [-1, prefetch][0 <= prefetch],
+             "MAX_MNK": maxmnk,
--- a/debian/patches/series     2022-06-20 08:24:21.976388516 +0100
--- b/debian/patches/series     2022-06-20 08:46:51.618995900 +0100
@@ -1,2 +1,3 @@
 0001-Makefile-rebuild-fix.patch
 0002-Makefile-fix-pkgconfigdir.patch
+0003-Reproducible-build.patch
--- a/debian/rules      2022-06-20 08:24:21.976388516 +0100
--- b/debian/rules      2022-06-20 08:49:26.476766896 +0100
@@ -16,6 +16,8 @@
        # Do not include docs in /usr/share/libxsmm
        rm -f debian/*/usr/share/libxsmm/*.md
        rm -f debian/*/usr/share/libxsmm/*.pdf
+       # Do not include build.txt
+       rm -f ./debian/*/usr/share/libxsmm/build.txt
 
 execute_after_dh_installdocs:
        # Do not install broken symlinks
--- a/scripts/libxsmm_config.py 2022-06-20 08:24:21.984388483 +0100
--- b/scripts/libxsmm_config.py 2022-06-20 09:01:29.846352447 +0100
@@ -10,9 +10,11 @@
 # Hans Pabst (Intel Corp.)
 ###############################################################################
 from string import Template
-from datetime import date
+import datetime
 import libxsmm_utilities
 import fnmatch
+import os
+import time
 import sys
 
 
@@ -87,6 +89,10 @@
         maxn = libxsmm_utilities.max_mnk(mnklist, avgdim, 1)
         maxk = libxsmm_utilities.max_mnk(mnklist, avgdim, 2)
 
+        build_date = datetime.datetime.utcfromtimestamp(
+            int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
+        )
+
         substitute = {
             "VERSION": realversion,
             "BRANCH": branch,
@@ -94,7 +100,7 @@
             "MINOR": minor,
             "UPDATE": update,
             "PATCH": patch,
-            "DATE": date.today().strftime("%Y%m%d"),
+            "DATE": build_date.strftime("%Y%m%d"),
             "CACHELINE": cacheline,
             "PREFETCH": [-1, prefetch][0 <= prefetch],
             "MAX_MNK": maxmnk,

Reply via email to