all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 02171ac6cfddd65fb70cf0eb6768a299a8826d07 2052 bytes (raw)
name: gnu/packages/patches/vlang-accommodate-timestamps.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
From 64e7c548843c7938fcfa6b697108d28aa26f4d69 Mon Sep 17 00:00:00 2001
From: Ryan Prior <rprior@protonmail.com>
Date: Thu, 31 Dec 2020 02:31:38 -0600
Subject: [PATCH] v.util: accomodate reproducible build environments like guix,
 by not recompiling cmd/tools when mtime < 1024 (#7702)

---
 vlib/v/util/util.v | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v
index 811b71585..1ed32bacf 100644
--- a/vlib/v/util/util.v
+++ b/vlib/v/util/util.v
@@ -179,7 +179,10 @@ pub fn should_recompile_tool(vexe string, tool_source string) bool {
 	if !os.exists(tool_exe) {
 		should_compile = true
 	} else {
-		if os.file_last_mod_unix(tool_exe) <= os.file_last_mod_unix(vexe) {
+		mtime_vexe := os.file_last_mod_unix(vexe)
+		mtime_tool_exe := os.file_last_mod_unix(tool_exe)
+		mtime_tool_source := os.file_last_mod_unix(tool_source)
+		if mtime_tool_exe <= mtime_vexe {
 			// v was recompiled, maybe after v up ...
 			// rebuild the tool too just in case
 			should_compile = true
@@ -192,10 +195,19 @@ pub fn should_recompile_tool(vexe string, tool_source string) bool {
 				should_compile = false
 			}
 		}
-		if os.file_last_mod_unix(tool_exe) <= os.file_last_mod_unix(tool_source) {
+		if mtime_tool_exe <= mtime_tool_source {
 			// the user changed the source code of the tool, or git updated it:
 			should_compile = true
 		}
+		// GNU Guix and possibly other environments, have bit for bit reproducibility in mind,
+		// including filesystem attributes like modification times, so they set the modification
+		// times of executables to a small number like 0, 1 etc. In this case, we should not
+		// recompile even if other heuristics say that we should. Users in such environments,
+		// have to explicitly do: `v cmd/tools/vfmt.v`, and/or install v from source, and not
+		// use the system packaged one, if they desire to develop v itself.
+		if mtime_vexe < 1024 && mtime_tool_exe < 1024 {
+			should_compile = false
+		}
 	}
 	return should_compile
 }
-- 
2.29.2


debug log:

solving 02171ac6cf ...
found 02171ac6cf in https://yhetil.org/guix/20210101192713.23655-6-rprior@protonmail.com/

applying [1/1] https://yhetil.org/guix/20210101192713.23655-6-rprior@protonmail.com/
diff --git a/gnu/packages/patches/vlang-accommodate-timestamps.patch b/gnu/packages/patches/vlang-accommodate-timestamps.patch
new file mode 100644
index 0000000000..02171ac6cf

1:22: space before tab in indent.
 	if !os.exists(tool_exe) {
1:23: space before tab in indent.
 		should_compile = true
1:24: space before tab in indent.
 	} else {
1:30: space before tab in indent.
 			// v was recompiled, maybe after v up ...
1:31: space before tab in indent.
 			// rebuild the tool too just in case
Checking patch gnu/packages/patches/vlang-accommodate-timestamps.patch...
Applied patch gnu/packages/patches/vlang-accommodate-timestamps.patch cleanly.
warning: squelched 11 whitespace errors
warning: 16 lines add whitespace errors.

index at:
100644 02171ac6cfddd65fb70cf0eb6768a299a8826d07	gnu/packages/patches/vlang-accommodate-timestamps.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.