cuda_configure: force nvcc exit code to 0
This is preparing executing repository_rule commands remotely.
PiperOrigin-RevId: 293425855
Change-Id: Id161c34d60119a7dc2aaf964c15f49efe2ef8c8f
diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl
index f74202f..5ce3cde 100644
--- a/third_party/gpus/cuda_configure.bzl
+++ b/third_party/gpus/cuda_configure.bzl
@@ -39,6 +39,7 @@
)
load(
"//third_party/remote_config:common.bzl",
+ "get_bash_bin",
"get_python_bin",
"is_windows",
"raw_exec",
@@ -338,13 +339,11 @@
cuda_config.cuda_toolkit_path,
".exe" if cuda_config.cpu_value == "Windows" else "",
))
- result = raw_exec(repository_ctx, [
- nvcc_path,
- "-v",
- "/dev/null",
- "-o",
- "/dev/null",
- ])
+
+ # The expected exit code of this command is non-zero. Bazel remote execution
+ # only caches commands with zero exit code. So force a zero exit code.
+ cmd = "%s -v /dev/null -o /dev/null ; [ $? -eq 1 ]" % str(nvcc_path)
+ result = raw_exec(repository_ctx, [get_bash_bin(repository_ctx), "-c", cmd])
target_dir = ""
for one_line in result.stderr.splitlines():
if one_line.startswith("#$ _TARGET_DIR_="):