pytorch/cmake
Jing Xu 8b37eff69f remove abi uncertainty and potential abi conflict (#94306)
Currently there is a potential conflict for `GLIBCXX_USE_CXX11_ABI` configuration if users don't explicitly set this variable.
In `caffe2/CMakeLists.txt`, if the variable is not set, an `abi checker` will be used to retrieve the ABI configuration from compiler.
https://github.com/pytorch/pytorch/blob/master/caffe2/CMakeLists.txt#L1165-L1183
However, in 'torch/csrc/Module.cpp`, if the variable is not set, it will be set to `0`. The conflict happens when the default ABI of the compiler is `1`.
https://github.com/pytorch/pytorch/blob/master/torch/csrc/Module.cpp#L1612

This PR eliminate this uncertainty and potential conflict.
The ABI will be checked and set in `CMakeLists.txt`, and pass the value to `caffe2/CMakeLists.txt`. Meanwhile, in case the `caffe2/CMakeLists.txt` is directly invoked from a `cmake` command, The original GLIBC check logic is kept in this file.
If users doesn't explicitly assign a value to `GLIBCXX_USE_CXX11_ABI`, the `abi checker` will be executed and set the value accordingly. If the `abi checker` failed to compile or execute, the value will be set to `0`. If users explicitly assigned a value, then the provided value will be used.

Moreover, if `GLIBCXX_USE_CXX11_ABI` is set to `0`, the '-DGLIBCXX_USE_CXX11_ABI=0' flag won't be appended to `CMAKE_CXX_FLAGS`. Thus, whether to use ABI=0 or ABI=1 fully depends on compiler's default configuration. It could cause an issue that even users explicitly set `GLIBCXX_USE_CXX11_ABI` to `0`, the compiler still builds the binaries with ABI=1.
https://github.com/pytorch/pytorch/blob/master/CMakeLists.txt#L44-L51
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94306
Approved by: https://github.com/malfet
2023-02-09 09:54:04 +00:00
..
External Set make max load when building libtorch (#89237) 2022-11-18 18:55:33 +00:00
Modules Simplify OpenMP detection in CMake (#91576) 2023-02-04 11:50:06 +00:00
Modules_CUDA_fix Simplify CMake CUDNN code (#91676) 2023-02-08 01:06:10 +00:00
public Simplify CMake CUDNN code (#91676) 2023-02-08 01:06:10 +00:00
Allowlist.cmake
BuildVariables.cmake
Caffe2Config.cmake.in Simplify CMake CUDNN code (#91676) 2023-02-08 01:06:10 +00:00
Caffe2ConfigVersion.cmake.in
CheckAbi.cmake remove abi uncertainty and potential abi conflict (#94306) 2023-02-09 09:54:04 +00:00
cmake_uninstall.cmake.in
Codegen.cmake
DebugHelper.cmake
Dependencies.cmake Simplify CMake CUDNN code (#91676) 2023-02-08 01:06:10 +00:00
FlatBuffers.cmake
GoogleTestPatch.cmake Simplify cmake code (#91546) 2023-02-08 01:05:19 +00:00
IncludeSource.cpp.in
iOS.cmake
Metal.cmake
MiscCheck.cmake Simplify cmake code (#91546) 2023-02-08 01:05:19 +00:00
ProtoBuf.cmake
ProtoBufPatch.cmake Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
Summary.cmake Simplify CMake CUDNN code (#91676) 2023-02-08 01:06:10 +00:00
TorchConfig.cmake.in Some CMake and CUDA cleanup given recent update to C++17 (#90599) 2022-12-30 11:19:26 +00:00
TorchConfigVersion.cmake.in
VulkanCodegen.cmake [Vulkan] Remove GLSL Code Gen (#91912) 2023-01-10 20:29:47 +00:00
VulkanDependencies.cmake [Vulkan] Remove GLSL Code Gen (#91912) 2023-01-10 20:29:47 +00:00