From 70fa826501758f3c24754bf1ad1f3e32d93d607d Mon Sep 17 00:00:00 2001 From: wateryzephyr Date: Thu, 11 Oct 2018 17:56:22 -0700 Subject: [PATCH 1/2] [bazel] Use tmp dir for intermediate NVCC source files * When using the local cuda cross-compilation toolchain, header file changes to cc_library would not trigger rebuilds for dependent cc_binary rules. --- third_party/gpus/cuda_configure.bzl | 33 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl index 831a3067b2413c..e2d74672e6dd13 100644 --- a/third_party/gpus/cuda_configure.bzl +++ b/third_party/gpus/cuda_configure.bzl @@ -144,13 +144,20 @@ def _get_python_bin(repository_ctx): def _get_nvcc_tmp_dir_for_windows(repository_ctx): - """Return the tmp directory for nvcc to generate intermediate source files.""" + """Return the Windows tmp directory for nvcc to generate intermediate source files.""" escaped_tmp_dir = escape_string( - get_env_var(repository_ctx, "TMP", "C:\\Windows\\Temp").replace( - "\\", "\\\\"),) + get_env_var(repository_ctx, "TMP", "C:\\Windows\\Temp").replace( + "\\", "\\\\"),) return escaped_tmp_dir + "\\\\nvcc_inter_files_tmp_dir" +def _get_nvcc_tmp_dir_for_unix(repository_ctx): + """Return the UNIX tmp directory for nvcc to generate intermediate source files.""" + escaped_tmp_dir = escape_string( + get_env_var(repository_ctx, "TMPDIR", "/tmp")) + return escaped_tmp_dir + "/nvcc_inter_files_tmp_dir" + + def _get_msvc_compiler(repository_ctx): vc_path = find_vc_path(repository_ctx) return find_msvc_tool(repository_ctx, vc_path, "cl.exe").replace("\\", "/") @@ -162,16 +169,18 @@ def _get_win_cuda_defines(repository_ctx): # If we are not on Windows, return empty vaules for Windows specific fields. # This ensures the CROSSTOOL file parser is happy. if not _is_windows(repository_ctx): + escaped_cxx_include_directory = \ + "cxx_builtin_include_directory: \"%s\"" % _get_nvcc_tmp_dir_for_unix(repository_ctx) return { - "%{msvc_env_tmp}": "", - "%{msvc_env_path}": "", - "%{msvc_env_include}": "", - "%{msvc_env_lib}": "", - "%{msvc_cl_path}": "", - "%{msvc_ml_path}": "", - "%{msvc_link_path}": "", - "%{msvc_lib_path}": "", - "%{cxx_builtin_include_directory}": "", + "%{msvc_env_tmp}": "", + "%{msvc_env_path}": "", + "%{msvc_env_include}": "", + "%{msvc_env_lib}": "", + "%{msvc_cl_path}": "", + "%{msvc_ml_path}": "", + "%{msvc_link_path}": "", + "%{msvc_lib_path}": "", + "%{cxx_builtin_include_directory}": escaped_cxx_include_directory, } vc_path = find_vc_path(repository_ctx) From 9f25a94c75c708189d903930535a2115b86b94b5 Mon Sep 17 00:00:00 2001 From: Gunhan Gulsoy Date: Fri, 22 Feb 2019 17:21:19 -0800 Subject: [PATCH 2/2] Update cuda_configure.bzl --- third_party/gpus/cuda_configure.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl index e2d74672e6dd13..31249f6d9cb645 100644 --- a/third_party/gpus/cuda_configure.bzl +++ b/third_party/gpus/cuda_configure.bzl @@ -1580,6 +1580,8 @@ cuda_configure = repository_rule( _TF_CUDA_CONFIG_REPO, "NVVMIR_LIBRARY_DIR", _PYTHON_BIN_PATH, + "TMP", + "TMPDIR", ], )