aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar lissyx <lissyx+github@lissyx.dyndns.org>2018-02-02 03:03:31 +0100
committerGravatar Andrew Harp <andrewharp@users.noreply.github.com>2018-02-01 21:03:31 -0500
commitb0d432dcc8c52177ebbaeb3a74d488f0af702f21 (patch)
tree05688289460d8066d0bf04a007c1ce233e32a9d2
parent56663eedd7296d85c9adb3e9537ddac521719445 (diff)
Force sorting of CUDA and Python headers to avoid spurious rebuilds (#16586)
If one does try to re-use Bazel cache of a TensorFlow CUDA-enabled or Python-enabled build, then it might happen that readdir() syscall behind the use of find in _read_dir() will generate a different ordering of the very same list of headers. This will make new genrules for symlinking the CUDA headers and in the end it will result in different actionKey computed by Bazel, hence invalidating the action cache. Fixes #16585
-rw-r--r--third_party/gpus/cuda_configure.bzl2
-rw-r--r--third_party/py/python_configure.bzl2
2 files changed, 2 insertions, 2 deletions
diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl
index 8e1dd8a54f..255ae01190 100644
--- a/third_party/gpus/cuda_configure.bzl
+++ b/third_party/gpus/cuda_configure.bzl
@@ -826,7 +826,7 @@ def symlink_genrule_for_dir(repository_ctx, src_dir, dest_dir, genrule_name,
if src_dir != None:
src_dir = _norm_path(src_dir)
dest_dir = _norm_path(dest_dir)
- files = _read_dir(repository_ctx, src_dir)
+ files = '\n'.join(sorted(_read_dir(repository_ctx, src_dir).splitlines()))
# Create a list with the src_dir stripped to use for outputs.
dest_files = files.replace(src_dir, '').splitlines()
src_files = files.splitlines()
diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl
index c16eb3a12a..954f21f5f8 100644
--- a/third_party/py/python_configure.bzl
+++ b/third_party/py/python_configure.bzl
@@ -118,7 +118,7 @@ def _symlink_genrule_for_dir(repository_ctx, src_dir, dest_dir, genrule_name,
if src_dir != None:
src_dir = _norm_path(src_dir)
dest_dir = _norm_path(dest_dir)
- files = _read_dir(repository_ctx, src_dir)
+ files = '\n'.join(sorted(_read_dir(repository_ctx, src_dir).splitlines()))
# Create a list with the src_dir stripped to use for outputs.
dest_files = files.replace(src_dir, '').splitlines()
src_files = files.splitlines()