pytorch
e5b6a766 - [torch deploy] Re-define D_GLIBCXX_USE_CXX11_ABI in deploy CMakeLists.txt

Commit
2 years ago
[torch deploy] Re-define D_GLIBCXX_USE_CXX11_ABI in deploy CMakeLists.txt Summary: **context** GLIBCXX_USE_CXX11_ABI dictates whether the compiler uses the new (1) or old (0) ABI. The new abi defines strings as: `std::__cxx11::string` The old abi defines strings as: `std::string` Usually `GLIBCXX_USE_CXX11_ABI` defaults to 1 on most systems. **the problem** When I build pytorch from source, grpc, glog and my server example, since my system's default `GLIBCXX_USE_CXX11_ABI` is 1, they are built with an ABI of 1 ( they look for `std::__cxx11::string`). `pytorch` uses the `TORCH_CXX_FLAGS` variable to dictate the value of `GLIBCXX_USE_CXX11_ABI`. (https://www.internalfb.com/code/aros/[64134af5d4c7]/xros/third-party/caffe2/caffe2/cmake/TorchConfig.cmake.in?lines=167). **Allthough `TORCH_CXX_FLAGS` would get set to `GLIBCXX_USE_CXX11_ABI=1`, when building torch deploy, the variable would be unset, and this would cause torch deploy to be built with `GLIBCXX_USE_CXX11_ABI=0` no matter what.** This leads to `undefined symbol` errors because the server example (built with abi 1) will look for strings in torch::deploy as `std::__cxx11::string`, and these will be non existent since all strings in torch::deploy are defined as `std::string`. **solution** Re-define this variables `CMAKE_CXX_FLAGS` and `TORCH_CXX_FLAGS` inside torch deploy's build to match that of pytorch's. Test Plan: Tested build in OSS and it works. No more undefined symbol errors due to `std::__cxx11::string`. Reviewed By: PaliC Differential Revision: D35694220 fbshipit-source-id: 678a9487a65dbc06b8b5b308d0e3714a85d84547 (cherry picked from commit 7f53b34b3cd479a209161e47187d4bf0507e6747)
Author
Committer
Parents
Loading