Compile PyTorch with additional linker options
I have a modified version of the gloo library. I am able to compile and run programs that use this library (similar to what you can find in gloo/gloo/examples).

Now, I want to build pytorch with my library.
I replaced the third_party/gloo folder in PyTorch with my version of gloo and I am trying to compile it.

However, my version of gloo requires some additional libraries and special linker options. Where should these linker options be added in the pytorch build system?

Without these linker options, my compilation stops with the linker error:

/pytorch/build/lib/libcaffe2_gpu.so: undefined reference to &lt;my code&gt;
/pytorch/build/lib/libcaffe2.so: undefined reference to &lt;my code&gt;


The additional linker options should be added to:


the Caffe2_DEPENDENCY_LIBS variable in pytorch/caffe2/CMakeLists.txt with the command:
list(APPEND Caffe2_DEPENDENCY_LIBS &lt;linker_options&gt;)
the C10D_LIBS variable in pytorch/torch/lib/c10d/CMakeLists.txt with the command:
list(APPEND C10D_LIBS &lt;linker_options&gt;)


The additional libraries should have Position Independent Code (they must be compiled with the -fPIC flag).
