Repository: pytorch
Issue: Compile with USE_CPP_CODE_COVERAGE=ON throw erros
Labels: module: build,triaged,actionable

### 🐛 Describe the bug

when I use ` USE_CPP_CODE_COVERAGE=ON BUILD_TEST=ON CMAKE_BUILD_TYPE=Debug  CMAKE_RULE_MESSAGES=ON CC=clang CXX=clang++ python setup.py develop` to compile pytorch, I couldn't success and I have those error printed:
```
[7/2051] Linking CXX executable bin/c10_cuda_CUDAAssertionsTest_multiple_writes_from_same_block
FAILED: bin/c10_cuda_CUDAAssertionsTest_multiple_writes_from_same_block 
: && /home/iris/tool_bins/llvm_release_17/bin/clang++ -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DLIBKINETO_NOXPUPTI=ON -DUSE_FBGEMM -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=braced-scalar-init -Werror=range-loop-construct -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-strict-overflow -Wno-strict-aliasing -Wvla-extension -Wsuggest-override -Wnewline-eof -Winconsistent-missing-override -Winconsistent-missing-destructor-override -Wno-pass-failed -Wno-error=old-style-cast -Wconstant-conversion -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -faligned-new -Wno-unused-but-set-variable -fno-math-errno -fno-trapping-math -Werror=format   -fprofile-instr-generate -fcoverage-mapping -g -fstandalone-debug -fno-omit-frame-pointer -O0 -rdynamic     -W123 -Xlinker --no-as-needed c10/cuda/test/CMakeFiles/c10_cuda_CUDAAssertionsTest_multiple_writes_from_same_block.dir/impl/CUDAAssertionsTest_multiple_writes_from_same_block.cu.o -o bin/c10_cuda_CUDAAssertionsTest_multiple_writes_from_same_block -L/usr/local/cuda-12.4/targets/x86_64-linux/lib/stubs   -L/usr/local/cuda-12.4/targets/x86_64-linux/lib -Wl,-rpath,/home/iris/CDeepFuzz/pytorch/build/lib:/usr/local/cuda-12.4/lib64:  lib/libc10_cuda.so  lib/libc10.so  lib/libgtest_maind.a  /usr/local/cuda-12.4/lib64/libcudart.so  lib/libgtestd.a  -lcudadevrt  -lcudart_static  -lrt  -lpthread  -ldl && /home/iris/miniconda3/envs/pytorch_2_4_1/bin/cmake -E __run_co_compile --lwyu="ldd;-u;-r" --source=bin/c10_cuda_CUDAAssertionsTest_multiple_writes_from_same_block && :
/usr/bin/ld: /home/iris/tool_bins/llvm_release_17/lib/clang/17/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingPlatformLinux.c.o): in function `__llvm_profile_begin_data':
InstrProfilingPlatformLinux.c:(.text.__llvm_profile_begin_data+0x3): undefined reference to `__start___llvm_prf_data'
/usr/bin/ld: /home/iris/tool_bins/llvm_release_17/lib/clang/17/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingPlatformLinux.c.o): in function `__llvm_profile_end_data':
InstrProfilingPlatformLinux.c:(.text.__llvm_profile_end_data+0x3): undefined reference to `__stop___llvm_prf_data'
/usr/bin/ld: /home/iris/tool_bins/llvm_release_17/lib/clang/17/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingPlatformLinux.c.o): in function `__llvm_profile_begin_names':
InstrProfilingPlatformLinux.c:(.text.__llvm_profile_begin_names+0x3): undefined reference to `__start___llvm_prf_names'
/usr/bin/ld: /home/iris/tool_bins/llvm_release_17/lib/clang/17/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingPlatformLinux.c.o): in function `__llvm_profile_end_names':
InstrProfilingPlatformLinux.c:(.text.__llvm_profile_end_names+0x3): undefined reference to `__stop___llvm_prf_names'
/usr/bin/ld: /home/iris/tool_bins/llvm_release_17/lib/clang/17/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingPlatformLinux.c.o): in function `__llvm_profile_begin_counters':
InstrProfilingPlatformLinux.c:(.text.__llvm_profile_begin_counters+0x3): undefined reference to `__start___llvm_prf_cnts'
/usr/bin/ld: /home/iris/tool_bins/llvm_release_17/lib/clang/17/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingPlatformLinux.c.o): in function `__llvm_profile_end_counters':
InstrProfilingPlatformLinux.c:(.text.__llvm_profile_end_counters+0x3): undefined reference to `__stop___llvm_prf_cnts'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```
I am using the llvm tag 17.0.6. I have rebuilt all related libraries multiple times and I can successfully build pytorch without `USE_CPP_CODE_COVERAGE=ON`

### Versions

```
Collecting environment information...
PyTorch version: 2.5.0a0+gitc0436c5
Is debug build: True
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.5 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 17.0.6 (https://github.com/llvm/llvm-project.git 6009708b4367171ccdbf4b5905cb6a803753fe18)
CMake version: version 3.26.4
Libc version: glibc-2.35

Python version: 3.10.14 (main, May  6 2024, 19:42:50) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.8.0-40-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.4.131
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090
Nvidia driver version: 560.35.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.4.0
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
Address sizes:                        39 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               32
On-line CPU(s) list:                  0-31
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Core(TM) i9-14900KF
CPU family:                           6
Model:                                183
Thread(s) per core:                   2
Core(s) per socket:                   24
Socket(s):                            1
Stepping:                             1
CPU max MHz:                          6000.0000
CPU min MHz:                          800.0000
BogoMIPS:                             6374.40
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            896 KiB (24 instances)
L1i cache:                            1.3 MiB (24 instances)
L2 cache:                             32 MiB (12 instances)
L3 cache:                             36 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-31
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Not affected
Vulnerability Reg file data sampling: Mitigation; Clear Register File
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] numpy==2.1.1
[pip3] optree==0.12.1
[pip3] pytorch-triton==3.0.0
[pip3] torch==2.4.0a0+gitee1b680
[pip3] torchaudio==2.4.1+e8cbe17
[pip3] torchvision==0.19.1a0+6194369
[conda] magma-cuda124             2.6.1                         1    pytorch
[conda] mkl-include               2024.2.1                 pypi_0    pypi
[conda] mkl-static                2024.2.1                 pypi_0    pypi
[conda] numpy                     2.1.1                    pypi_0    pypi
[conda] optree                    0.12.1                   pypi_0    pypi
[conda] pytorch-triton            3.0.0                    pypi_0    pypi
[conda] torch                     2.5.0a0+gitc0436c5           dev_0    <develop>
[conda] torchaudio                2.4.1+e8cbe17            pypi_0    pypi
[conda] torchvision               0.19.1a0+6194369          pypi_0    pypi
```

cc @malfet @seemethere