aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorflow.bzl
diff options
context:
space:
mode:
authorGravatar Yifei Feng <yifeif@google.com>2018-02-22 14:24:57 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-02-22 14:29:27 -0800
commitdce9a49c19f406ba45919e8c94474e55dc5ccd54 (patch)
tree928db8a52603e00aef76985cda16b8bceb9debb2 /tensorflow/tensorflow.bzl
parentcb7e1963c625fd9713e7475d85621f95be6762f1 (diff)
Merge changes from github.
PiperOrigin-RevId: 186674197
Diffstat (limited to 'tensorflow/tensorflow.bzl')
-rw-r--r--tensorflow/tensorflow.bzl63
1 files changed, 58 insertions, 5 deletions
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index 82142fa21d..818d67f7b5 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -618,7 +618,7 @@ def tf_cc_test(name,
srcs=srcs + tf_binary_additional_srcs(),
copts=tf_copts() + extra_copts,
linkopts=select({
- "//tensorflow:android": [
+ clean_dep("//tensorflow:android"): [
"-pie",
],
clean_dep("//tensorflow:windows"): [],
@@ -1312,6 +1312,46 @@ def tf_extension_linkopts():
def tf_extension_copts():
return [] # No extension c opts
+# In tf_py_wrap_cc generated libraries
+# module init functions are not exported unless
+# they contain one of the keywords in the version file
+# this prevents custom python modules.
+# This function attempts to append init_module_name to list of
+# exported functions in version script
+def _append_init_to_versionscript_impl(ctx):
+ mod_name = ctx.attr.module_name
+ if ctx.attr.is_version_script:
+ ctx.actions.expand_template(
+ template=ctx.file.template_file,
+ output=ctx.outputs.versionscript,
+ substitutions={
+ "global:":"global:\n init_%s;\n PyInit_*;"%(mod_name),
+ },
+ is_executable=False,
+ )
+ else:
+ ctx.actions.expand_template(
+ template=ctx.file.template_file,
+ output=ctx.outputs.versionscript,
+ substitutions={
+ "*tensorflow*":"*tensorflow*\ninit_%s\nPyInit_*\n"%(mod_name),
+ },
+ is_executable=False,
+ )
+
+
+_append_init_to_versionscript= rule(
+ implementation=_append_init_to_versionscript_impl,
+ attrs={
+ "module_name":attr.string(mandatory=True),
+ "template_file":attr.label(allow_files=True,single_file=True,mandatory=True),
+ "is_version_script":attr.bool(default=True,
+ doc='whether target is a ld version script or exported symbol list',
+ mandatory=False),
+ },
+ outputs={"versionscript":"%{name}.lds"},
+)
+
def tf_py_wrap_cc(name,
srcs,
swig_includes=[],
@@ -1333,26 +1373,39 @@ def tf_py_wrap_cc(name,
toolchain_deps=["//tools/defaults:crosstool"],
module_name=module_name,
py_module_name=name)
+ vscriptname=name+"_versionscript"
+ _append_init_to_versionscript(
+ name=vscriptname,
+ module_name=module_name,
+ is_version_script=select({
+ "@local_config_cuda//cuda:darwin":False,
+ "//conditions:default":True,
+ }),
+ template_file=select({
+ "@local_config_cuda//cuda:darwin":clean_dep("//tensorflow:tf_exported_symbols.lds"),
+ "//conditions:default":clean_dep("//tensorflow:tf_version_script.lds")
+ })
+ )
extra_linkopts = select({
"@local_config_cuda//cuda:darwin": [
"-Wl,-exported_symbols_list",
- clean_dep("//tensorflow:tf_exported_symbols.lds")
+ "%s.lds"%vscriptname,
],
clean_dep("//tensorflow:windows"): [],
clean_dep("//tensorflow:windows_msvc"): [],
"//conditions:default": [
"-Wl,--version-script",
- clean_dep("//tensorflow:tf_version_script.lds")
+ "%s.lds"%vscriptname,
]
})
extra_deps += select({
"@local_config_cuda//cuda:darwin": [
- clean_dep("//tensorflow:tf_exported_symbols.lds")
+ "%s.lds"%vscriptname,
],
clean_dep("//tensorflow:windows"): [],
clean_dep("//tensorflow:windows_msvc"): [],
"//conditions:default": [
- clean_dep("//tensorflow:tf_version_script.lds")
+ "%s.lds"%vscriptname,
]
})