build_variables.py: turn on link_whole for _C_impl library. (#18763)
authorMikhail Zolotukhin <mvz@fb.com>
Tue, 2 Apr 2019 22:14:18 +0000 (15:14 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 2 Apr 2019 22:17:13 +0000 (15:17 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18763

Without `link_whole` flag in opt-builds some of the files are not linked into `_C_impl` library, which causes some of static initializers not to run (namely, registering an cutomPythonOperation from python_interpreter.cpp). This diff fixes it.

Differential Revision: D14732471

fbshipit-source-id: 57cff6b4b6d479ad7ab7fd29f677746d91d6ff45

tools/build_variables.py

index cacbfe9..2236172 100644 (file)
@@ -147,6 +147,9 @@ def add_torch_libs():
             "torch/csrc/distributed/**/*.cpp",
             # top-level hook of extension registration lives in a separate file
             "torch/csrc/stub.cpp",
+            # to avoid redefinitions of symbols defined in
+            # dynamic_library_unix.cpp
+            "torch/csrc/jit/fuser/cpu/dynamic_library_win.cpp",
         ],
     ) + [
         "torch/csrc/distributed/Module.cpp",
@@ -249,6 +252,7 @@ def add_torch_libs():
     cpp_library(
         name="_C_impl",
         srcs=libtorch_python_sources,
+        link_whole=True,
         deps=[
             ":libtorch_cuda",
             ":thnn",