Issue 1:
During compilation of TF, tensorflow_framework target (libtensorflow_framework.so) will end up with multiple definitions of zlib. The reason is that protobuf will bring zlib

whereas the rest of the system is using zlib_archive. There is a patch //third_party/protobuf/protobuf.patch to force the protobuf to use zlib_archive but it is not working because the logic introduced in thrid_party/repo.bzl to use git apply command instead of patch -p1 on Unix machine is not working.

System information

OS Platform and Distribution: Linux Ubuntu 18.04.2 LTS

TensorFlow: Branch # master, Commit # 7ab1171

Python version: python3.6

Bazel version: 0.24.1

GCC/Compiler version: 7.3.1

Diff view

diff --git a/third_party/repo.bzl b/third_party/repo.bzl
index a7506b4efe..083ebf9d6a 100644
--- a/third_party/repo.bzl
+++ b/third_party/repo.bzl
@@ -62,13 +62,15 @@ def _repos_are_siblings():
return Label("@foo//bar").workspace_root.startswith("../")

# Apply a patch_file to the repository root directory
-# Runs 'git apply' on Unix, 'patch -p1' on Windows.
+# Runs 'patch -p1'
def _apply_patch(ctx, patch_file):
- if _is_windows(ctx):
- patch_command = ["patch", "-p1", "-d", ctx.path("."), "-i", ctx.path(patch_file)]
- else:
- patch_command = ["git", "apply", "-v", ctx.path(patch_file)]
- cmd = _wrap_bash_cmd(ctx, patch_command)
+ # Don't check patch on Windows, because patch is only available under bash.
+ if not _is_windows(ctx) and not ctx.which("patch"):
+ fail("patch command is not found, please install it")
+ cmd = _wrap_bash_cmd(
+ ctx,
+ ["patch", "-p1", "-d", ctx.path("."), "-i", ctx.path(patch_file)],
+ )
_execute_and_check_ret_code(ctx, cmd)

def _apply_delete(ctx, paths):

Issue 2:
During compilation of TF, tensorflow_framework target (libtensorflow_framework.so) will end up with multiple definitions of zlib. The reason is that protobuf will bring zlib

whereas the rest of the system is using zlib_archive. There is a patch //third_party/protobuf/protobuf.patch to force the protobuf to use zlib_archive but it is not working because the logic introduced in thrid_party/repo.bzl to use git apply command instead of patch -p1 on Unix machine is not working.

System information

OS Platform and Distribution: Linux Ubuntu 18.04.2 LTS

TensorFlow: Branch # master, Commit # 7ab1171

Python version: python3.6

Bazel version: 0.24.1

GCC/Compiler version: 7.3.1

Diff view

diff --git a/third_party/repo.bzl b/third_party/repo.bzl
index a7506b4efe..083ebf9d6a 100644
--- a/third_party/repo.bzl
+++ b/third_party/repo.bzl
@@ -62,13 +62,15 @@ def _repos_are_siblings():
return Label("@foo//bar").workspace_root.startswith("../")

# Apply a patch_file to the repository root directory
-# Runs 'git apply' on Unix, 'patch -p1' on Windows.
+# Runs 'patch -p1'
def _apply_patch(ctx, patch_file):
- if _is_windows(ctx):
- patch_command = ["patch", "-p1", "-d", ctx.path("."), "-i", ctx.path(patch_file)]
- else:
- patch_command = ["git", "apply", "-v", ctx.path(patch_file)]
- cmd = _wrap_bash_cmd(ctx, patch_command)
+ # Don't check patch on Windows, because patch is only available under bash.
+ if not _is_windows(ctx) and not ctx.which("patch"):
+ fail("patch command is not found, please install it")
+ cmd = _wrap_bash_cmd(
+ ctx,
+ ["patch", "-p1", "-d", ctx.path("."), "-i", ctx.path(patch_file)],
+ )
_execute_and_check_ret_code(ctx, cmd)

def _apply_delete(ctx, paths):