@@ -689,15 +689,6 @@ def build_extensions(self) -> None:
689689 # min supported CPython version.
690690 # See https://docs.python.org/3/c-api/stable.html#c.Py_LIMITED_API
691691 self ._add_compile_flag (extension , f'-DPy_LIMITED_API={ min_supported_cpython } ' )
692- else :
693- # pybind11 is not CPython API stable so don't add these flags used when
694- # compiling pybind11 when pybind11 is not even used. otherwise, the build
695- # logs are confusing.
696- # See note [Pybind11 ABI constants]
697- for name in ["COMPILER_TYPE" , "STDLIB" , "BUILD_ABI" ]:
698- val = getattr (torch ._C , f"_PYBIND11_{ name } " )
699- if val is not None and not IS_WINDOWS :
700- self ._add_compile_flag (extension , f'-DPYBIND11_{ name } ="{ val } "' )
701692 self ._define_torch_extension_name (extension )
702693
703694 if 'nvcc_dlink' in extension .extra_compile_args :
@@ -1714,25 +1705,6 @@ def load(name,
17141705 is_standalone ,
17151706 keep_intermediates = keep_intermediates )
17161707
1717- def _get_pybind11_abi_build_flags ():
1718- # Note [Pybind11 ABI constants]
1719- #
1720- # Pybind11 before 2.4 used to build an ABI strings using the following pattern:
1721- # f"__pybind11_internals_v{PYBIND11_INTERNALS_VERSION}{PYBIND11_INTERNALS_KIND}{PYBIND11_BUILD_TYPE}__"
1722- # Since 2.4 compier type, stdlib and build abi parameters are also encoded like this:
1723- # f"__pybind11_internals_v{PYBIND11_INTERNALS_VERSION}{PYBIND11_INTERNALS_KIND}{PYBIND11_COMPILER_TYPE}{PYBIND11_STDLIB}{PYBIND11_BUILD_ABI}{PYBIND11_BUILD_TYPE}__"
1724- #
1725- # This was done in order to further narrow down the chances of compiler ABI incompatibility
1726- # that can cause a hard to debug segfaults.
1727- # For PyTorch extensions we want to relax those restrictions and pass compiler, stdlib and abi properties
1728- # captured during PyTorch native library compilation in torch/csrc/Module.cpp
1729-
1730- abi_cflags = []
1731- for pname in ["COMPILER_TYPE" , "STDLIB" , "BUILD_ABI" ]:
1732- pval = getattr (torch ._C , f"_PYBIND11_{ pname } " )
1733- if pval is not None and not IS_WINDOWS :
1734- abi_cflags .append (f'-DPYBIND11_{ pname } =\\ "{ pval } \\ "' )
1735- return abi_cflags
17361708
17371709def check_compiler_is_gcc (compiler ):
17381710 if not IS_LINUX :
@@ -1863,7 +1835,6 @@ def build_precompile_header(pch_cmd):
18631835 common_cflags += ['-DTORCH_API_INCLUDE_EXTENSION_H' ]
18641836
18651837 common_cflags += ['-std=c++17' , '-fPIC' ]
1866- common_cflags += [f"{ x } " for x in _get_pybind11_abi_build_flags ()]
18671838 common_cflags_str = listToString (common_cflags )
18681839
18691840 pch_cmd = format_precompiler_header_cmd (compiler , head_file , head_file_pch , common_cflags_str , torch_include_dirs_str , extra_cflags_str , extra_include_paths_str )
@@ -2698,8 +2669,6 @@ def _write_ninja_file_to_build_library(path,
26982669 common_cflags .append (f'-DTORCH_EXTENSION_NAME={ name } ' )
26992670 common_cflags .append ('-DTORCH_API_INCLUDE_EXTENSION_H' )
27002671
2701- common_cflags += [f"{ x } " for x in _get_pybind11_abi_build_flags ()]
2702-
27032672 # Windows does not understand `-isystem` and quotes flags later.
27042673 if IS_WINDOWS :
27052674 common_cflags += [f'-I{ include } ' for include in user_includes + system_includes ]
0 commit comments