aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-09-01 08:17:03 -0700
committerDmitry Vyukov <dvyukov@google.com>2019-09-01 20:42:42 -0700
commitdb7c31ca79638f50cbb920add433b46cd66e9890 (patch)
tree925523fc4d0e968c3b8eac2db90395dd6605a210
parentaaf9e5bb5ebb5baf5ac19f83e7ae6984ee21e8f5 (diff)
pkg/build: make linux builds more deterministic
Kbuild inserts build timestamp into every build. This makes vmlinux change always even if no present. Make the build more deterministic. We plan to use it for detecting no-op changes during bisection. Update #1271
-rw-r--r--pkg/build/linux.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/build/linux.go b/pkg/build/linux.go
index 735118a1a..b9301d3d9 100644
--- a/pkg/build/linux.go
+++ b/pkg/build/linux.go
@@ -128,6 +128,16 @@ func runMake(kernelDir string, args ...string) error {
return err
}
cmd.Dir = kernelDir
+ cmd.Env = append([]string{}, os.Environ()...)
+ // This makes the build [more] deterministic:
+ // 2 builds from the same sources should result in the same vmlinux binary.
+ // We plan to use it for detecting no-op changes during bisection.
+ cmd.Env = append(cmd.Env,
+ "KBUILD_BUILD_VERSION=0",
+ "KBUILD_BUILD_TIMESTAMP=now",
+ "KBUILD_BUILD_USER=syzkaller",
+ "KBUILD_BUILD_HOST=syzkaller",
+ )
_, err := osutil.Run(time.Hour, cmd)
return err
}