Repository: pytorch
Issue: Looking for valid compiling option for extension based on torch-2.1.0+cpu.cxx11.abi
Labels: high priority,needs reproduction,module: crash,module: build,module: cpp-extensions,triaged

### 🐛 Describe the bug

Try to compile extension based on [torch-2.1.0+cpu.cxx11.abi](https://download.pytorch.org/whl/cpu-cxx11-abi/torch-2.1.0%2Bcpu.cxx11.abi-cp39-cp39-linux_x86_64.whl#sha256=f100b87d0e307dcac6321dd8f4895f14f6fa6974a921e9e7369bd9c7be4f0d5d) and set D_GLIBCXX_USE_CXX11_ABI=1.

env info:
```
Arch: x86_64
GCC version: (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)
CMake version: version 3.18.4
Libc version: glibc-2.28
```

An segmentation fault occurs during pybind11 initialization when import the extension which inherits the torch._C._distributed_c10d.Backend. Tried the following options but none of them solved the problem:

1. set(CXX_STANDARD_REQUIRED ON)
2. string(APPEND CMAKE_CXX_FLAGS " -fabi-version=11")

Only using self-compiled torch package in same environment can fix the problem, and it seems that some _**static_strings**_ are missing in [torch-2.1.0+cpu.cxx11.abi](https://download.pytorch.org/whl/cpu-cxx11-abi/torch-2.1.0%2Bcpu.cxx11.abi-cp39-cp39-linux_x86_64.whl#sha256=f100b87d0e307dcac6321dd8f4895f14f6fa6974a921e9e7369bd9c7be4f0d5d) by tracing _**internals_pp**_ in torch/inculde/pybind11/detail/internals.h.
```
inline internals **&get_internals_pp() {
    static internals **internals_pp = nullptr;
    return internals_pp;
}
```
missing static_strings
```
...
[38] = "torch._C._distributed_c10d._ProcessGroupWrapper",
[39] = "torch._C._distributed_c10d._Options",
[40] = "torch._C._distributed_c10d.Device",
[41] = "torch._C._distributed_c10d.ProcessGroupGloo",
[42] = "torch._C._distributed_c10d.Backend",
[43] = "torch._C._distributed_c10d.Options", 
[44] = "torch._C._distributed_c10d.BackendType",
[45] = "torch._C._distributed_c10d.ProcessGroup",
...
```

**Is there any pybind11 requirements are missing?**

### Versions

PyTorch version: 2.1.0+cpu-cxx11-abi
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: AlmaLinux 8.10 (Cerulean Leopard) (x86_64)
GCC version: (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)
Clang version: Could not collect
CMake version: version 3.18.4
Libc version: glibc-2.28

Python version: 3.9.21 (main, Dec 17 2024, 07:34:47)  [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)] (64-bit runtime)
Python platform: Linux-3.10.0-1160.119.1.el7.x86_64-x86_64-with-glibc2.28
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              32
On-line CPU(s) list: 0-31
Thread(s) per core:  2
Core(s) per socket:  16
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               85
Model name:          Intel(R) Xeon(R) Gold 6266C CPU @ 3.00GHz
Stepping:            7
CPU MHz:             3000.000
BogoMIPS:            6000.00
Hypervisor vendor:   KVM
Virtualization type: full
L1d cache:           32K
L1i cache:           32K
L2 cache:            1024K
L3 cache:            30976K
NUMA node0 CPU(s):   0-31
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat avx512_vnni md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.21.3
[pip3] torch==2.1.0+cpu.cxx11.abi
[conda] numpy                     1.24.4                   pypi_0    pypi

cc @ezyang @gchanan @zou3519 @kadeng @msaroufim @malfet @seemethere @xmfan