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