diff options
author | Allen Lavoie <allenl@google.com> | 2017-09-21 11:29:45 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-09-21 11:33:40 -0700 |
commit | 5c7f9e316d8c7735308a217310350d416d7498cc (patch) | |
tree | a3457b97367fe6b1ed4ad47a4284cac88495ae16 /tensorflow/tools/lib_package | |
parent | 054b88233bf6d6bc5b953fca50dbb01d108b2d18 (diff) |
Remove RTLD_GLOBAL when loading pywrap_tensorflow
Splits out a shared object (//tensorflow/libtensorflow_framework.so) with core TensorFlow functionality but neither ops nor kernels. This object does include registries for ops, kernels, filesystems, etc. The expectation is that shared objects containing custom ops will have a runtime dependency on this framework shared object: TensorFlow will load the custom op shared object, and the custom op shared object will use the symbols from the framework shared object to register its ops/kernels/etc. rather than (as before this change) relying on those symbols being in the global symbol table.
In this mode, TensorFlow artifacts (_pywrap_tensorflow.so for Python, libtensorflow.so for the C API; currently excluding Android artifacts) will depend on the framework shared object, which will be packaged with the Python pip package and other language distributions. This means that custom ops targeting the framework shared object will work in any language (C++, Java, Go; previously custom ops in these languages required custom Bazel builds).
Adds a config option which reproduces the old behavior (--config=monolithic), which for Python means building a monolithic pywrap_tensorflow shared object and loading its symbols into the global symbol table (with RTLD_GLOBAL). As before, there will be no extra-Bazel custom op support for other languages when compiling in this mode.
Does not change behavior on Windows; the cmake build is still monolithic.
Requires using tf_cc_binary, tf_cc_test, and (rarely) tf_cc_shared_object rules to link in the framework shared object when adding new TensorFlow build rules.
PiperOrigin-RevId: 169572746
Diffstat (limited to 'tensorflow/tools/lib_package')
-rw-r--r-- | tensorflow/tools/lib_package/BUILD | 9 | ||||
-rwxr-xr-x | tensorflow/tools/lib_package/libtensorflow_test.sh | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/tensorflow/tools/lib_package/BUILD b/tensorflow/tools/lib_package/BUILD index 494ddd2f5d..d522c9d395 100644 --- a/tensorflow/tools/lib_package/BUILD +++ b/tensorflow/tools/lib_package/BUILD @@ -42,6 +42,14 @@ pkg_tar( # are resolved, otherwise these rules break when built # with Python 3. tags = ["manual"], + deps = [":common_deps"], +) + +# Shared objects that all TensorFlow libraries depend on. +pkg_tar( + name = "common_deps", + files = ["//tensorflow:libtensorflow_framework.so"], + tags = ["manual"], ) pkg_tar( @@ -66,6 +74,7 @@ pkg_tar( # are resolved, otherwise these rules break when built # with Python 3. tags = ["manual"], + deps = [":common_deps"], ) pkg_tar( diff --git a/tensorflow/tools/lib_package/libtensorflow_test.sh b/tensorflow/tools/lib_package/libtensorflow_test.sh index 7dfe8eefcc..f0294bc2bd 100755 --- a/tensorflow/tools/lib_package/libtensorflow_test.sh +++ b/tensorflow/tools/lib_package/libtensorflow_test.sh @@ -38,8 +38,9 @@ cd ${TEST_TMPDIR} mkdir tensorflow ${TAR} -xzf ${TARFILE} -Ctensorflow -# Compile the test .c file -${CC} ${CFILE} -Itensorflow/include -Ltensorflow/lib -ltensorflow -oa.out +# Compile the test .c file. Assumes with_framework_lib=True. +${CC} ${CFILE} -Itensorflow/include -Ltensorflow/lib\ + -ltensorflow_framework -ltensorflow -oa.out # Execute it, with the shared library available. # DYLD_LIBRARY_PATH is used on OS X, LD_LIBRARY_PATH on Linux. |