[5a4941]: / third_party / tensorflow.bzl.patch

Download this file

142 lines (137 with data), 5.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -2877,6 +2877,28 @@
**kwargs
)
+def _symlink_impl(ctx):
+ """Creates a symbolic link between src and out."""
+ out = ctx.outputs.out
+ src = ctx.attr.src.files.to_list()[0]
+ cmd = "ln -f -r -s %s %s" % (src.path, out.path)
+ ctx.actions.run_shell(
+ inputs = [src],
+ outputs = [out],
+ command = cmd,
+ )
+
+symlink = rule(
+ implementation = _symlink_impl,
+ attrs = {
+ "src": attr.label(
+ mandatory = True,
+ allow_single_file = True,
+ ),
+ "out": attr.output(mandatory = True),
+ },
+)
+
# buildozer: disable=function-docstring-args
def pybind_extension_opensource(
name,
@@ -3012,46 +3034,46 @@
if link_in_framework:
srcs += tf_binary_additional_srcs()
- cc_binary(
- name = so_file,
- srcs = srcs + hdrs,
- data = data,
- copts = copts + [
- "-fno-strict-aliasing",
- "-fexceptions",
- ] + select({
- clean_dep("//tensorflow:windows"): [],
- "//conditions:default": [
- "-fvisibility=hidden",
- ],
- }),
- linkopts = linkopts + _rpath_linkopts(name) + select({
- clean_dep("//tensorflow:macos"): [
- # TODO: the -w suppresses a wall of harmless warnings about hidden typeinfo symbols
- # not being exported. There should be a better way to deal with this.
- "-Wl,-w",
- "-Wl,-exported_symbols_list,$(location %s)" % exported_symbols_file,
- ],
- clean_dep("//tensorflow:windows"): [],
- "//conditions:default": [
- "-Wl,--version-script",
- "$(location %s)" % version_script_file,
- ],
- }),
- deps = deps + [
- exported_symbols_file,
- version_script_file,
- ],
- defines = defines,
- features = features + ["-use_header_modules"],
- linkshared = 1,
- testonly = testonly,
- licenses = licenses,
- visibility = visibility,
- deprecation = deprecation,
- restricted_to = restricted_to,
- compatible_with = compatible_with,
- )
+ # cc_binary(
+ # name = so_file,
+ # srcs = srcs + hdrs,
+ # data = data,
+ # copts = copts + [
+ # "-fno-strict-aliasing",
+ # "-fexceptions",
+ # ] + select({
+ # clean_dep("//tensorflow:windows"): [],
+ # "//conditions:default": [
+ # "-fvisibility=hidden",
+ # ],
+ # }),
+ # linkopts = linkopts + _rpath_linkopts(name) + select({
+ # clean_dep("//tensorflow:macos"): [
+ # # TODO: the -w suppresses a wall of harmless warnings about hidden typeinfo symbols
+ # # not being exported. There should be a better way to deal with this.
+ # "-Wl,-w",
+ # "-Wl,-exported_symbols_list,$(location %s)" % exported_symbols_file,
+ # ],
+ # clean_dep("//tensorflow:windows"): [],
+ # "//conditions:default": [
+ # "-Wl,--version-script",
+ # "$(location %s)" % version_script_file,
+ # ],
+ # }),
+ # deps = deps + [
+ # exported_symbols_file,
+ # version_script_file,
+ # ],
+ # defines = defines,
+ # features = features + ["-use_header_modules"],
+ # linkshared = 1,
+ # testonly = testonly,
+ # licenses = licenses,
+ # visibility = visibility,
+ # deprecation = deprecation,
+ # restricted_to = restricted_to,
+ # compatible_with = compatible_with,
+ # )
# For Windows, emulate the above filegroup with the shared object.
native.alias(
@@ -3073,11 +3095,21 @@
testonly = testonly,
)
+ # To prevent ODR violations, all of the extensions must live in one
+ # extension module. And to be compatible with existing protobuf
+ # generated code, that module must be _message.so.
+ pyext_so = name + ".so"
+ symlink(
+ name = name + "_symlink",
+ out = pyext_so,
+ src = "@com_google_protobuf//:python/google/protobuf/pyext/_message.so",
+ )
+
native.py_library(
name = name,
data = select({
"@org_tensorflow//tensorflow:windows": [pyd_file],
- "//conditions:default": [so_file],
+ "//conditions:default": [pyext_so],
}) + pytype_srcs,
deps = pytype_deps,
srcs_version = srcs_version,