aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorflow.bzl
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-03-15 15:16:38 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-15 15:21:10 -0700
commit239eb8b652f94b43d51f7c7ffdbbfc02ad094a9c (patch)
treecc8a61338f33afaf556b9ae2cf49f40947616142 /tensorflow/tensorflow.bzl
parent67fd87c5812f227193145d8436e4bdf9b315dfb7 (diff)
PIE binaries that depends on static libraries usually have text relocations in the final executable, which causes link warnings/errors (different linker behaves differently). The optimal way to fix this is to link the binary with shared library, however, the libraries are NVIDIA-proprietary, not all of them have shared version (for example: cuda_9_0/lib64/libculibos.a)
PiperOrigin-RevId: 189254317
Diffstat (limited to 'tensorflow/tensorflow.bzl')
-rw-r--r--tensorflow/tensorflow.bzl8
1 files changed, 8 insertions, 0 deletions
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index a0ec1708d5..bab1e82c86 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -905,6 +905,14 @@ def tf_cuda_library(deps=None, cuda_deps=None, copts=tf_copts(), **kwargs):
if not cuda_deps:
cuda_deps = []
+ if 'linkstatic' not in kwargs or kwargs['linkstatic'] != 1:
+ enable_text_relocation_linkopt = select({
+ clean_dep("//tensorflow:darwin"): [],
+ "//conditions:default": ['-Wl,-z,notext'],})
+ if 'linkopts' in kwargs:
+ kwargs['linkopts'] += enable_text_relocation_linkopt
+ else:
+ kwargs['linkopts'] = enable_text_relocation_linkopt
native.cc_library(
deps=deps + if_cuda(cuda_deps + [
clean_dep("//tensorflow/core:cuda"),