<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/72200>72200</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [compiler-rt] build compiler-rt asan lit test case with libc++
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          PikachuHyA
      </td>
    </tr>
</table>

<pre>
    As mentioned in https://github.com/llvm/llvm-project/issues/72108.
after we build compiler-rt test success with libc++ and patch https://github.com/llvm/llvm-project/pull/72111
we got another error about compiler-rt asan lit test cases ( e.g.`contiguous_container.cpp`)

```
FAIL: AddressSanitizer-x86_64-linux :: TestCases/contiguous_container.cpp (746 of 5776)
******************** TEST 'AddressSanitizer-x86_64-linux :: TestCases/contiguous_container.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /llvm/build_compiler_rt_test_with_libcxx/./bin/clang  --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -fexceptions -O /llvm/compiler-rt/test/asan/TestCases/contiguous_container.cpp -o /llvm/build_compiler_rt_test_with_libcxx/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/contiguous_container.cpp.tmp && env ASAN_OPTIONS=detect_stack_use_after_return=0 /llvm/build_compiler_rt_test_with_libcxx/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/contiguous_container.cpp.tmp
+ /llvm/build_compiler_rt_test_with_libcxx/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -fexceptions -O /llvm/compiler-rt/test/asan/TestCases/contiguous_container.cpp -o /llvm/build_compiler_rt_test_with_libcxx/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/contiguous_container.cpp.tmp
In file included from /llvm/compiler-rt/test/asan/TestCases/contiguous_container.cpp:5:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/algorithm:61:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_algobase.h:1206:42: error: type '__gnu_cxx::__normal_iterator<const int *, std::vector<int>>' does not provide a call operator
 1206 |       while (__first1 != __last1 && bool(__binary_pred(*__first1, *__first2)))
      | ^~~~~~~~~~~~~
/llvm/compiler-rt/test/asan/TestCases/contiguous_container.cpp:39:24: note: in instantiation of function template specialization 'std::mismatch<__gnu_cxx::__normal_iterator<const int *, std::vector<int>>, __gnu_cxx::__normal_iterator<const int *, std::vector<int>>, __gnu_cxx::__normal_iterator<const int *, std::vector<int>>>' requested here
   39 |   auto mismatch = std::mismatch(a.begin(), a.end(), b.begin(), b.end());
      |                        ^
1 error generated.

--
```

```
********************
FAIL: HWAddressSanitizer-x86_64 :: TestCases/new-test.cpp (1527 of 5776)
******************** TEST 'HWAddressSanitizer-x86_64 :: TestCases/new-test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /llvm/build_compiler_rt_test_with_libcxx/./bin/clang  --driver-mode=g++ -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -mllvm -hwasan-generate-tags-with-calls=1 -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -std=c++17 /llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp -o /llvm/build_compiler_rt_test_with_libcxx/runtimes/runtimes-bins/compiler-rt/test/hwasan/X86_64/TestCases/Output/new-test.cpp.tmp -fsized-deallocation
+ /llvm/build_compiler_rt_test_with_libcxx/./bin/clang --driver-mode=g++ -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -mllvm -hwasan-generate-tags-with-calls=1 -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -std=c++17 /llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp -o /llvm/build_compiler_rt_test_with_libcxx/runtimes/runtimes-bins/compiler-rt/test/hwasan/X86_64/TestCases/Output/new-test.cpp.tmp -fsized-deallocation
/llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp:36:44: error: no type named 'align_val_t' in namespace 'std'
   36 | void operator_new_delete(size_t size, std::align_val_t align) {
      | ~~~~~^
/llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp:50:50: error: no type named 'align_val_t' in namespace 'std'
   50 | void operator_new_delete_array(size_t size, std::align_val_t align) {
      | ~~~~~^
/llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp:78:44: error: no type named 'align_val_t' in namespace 'std'
   78 | void operator_new_delete(size_t size, std::align_val_t align, const std::nothrow_t &tag) {
      | ~~~~~^
/llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp:86:50: error: no type named 'align_val_t' in namespace 'std'
   86 | void operator_new_delete_array(size_t size, std::align_val_t align, const std::nothrow_t &tag) {
      | ~~~~~^
4 errors generated.

--
```

The reason is that the gcc and libstdc++ versions are too old.

We tried to find relevant options to compile the lit test case using libc++, but failed.

## Environment
centos 7

the latest LLVM cannot be built with gcc 4.8 on CentOS 7, then we use a prebuilt LLVM 17 with custom path (/opt/prebuilt_llvm).


## reproducer

- centos 7
```
docker pull centos:7
```
- prebuilt llvm 17
assume put in `/opt/prebuilt_llvm`
- llvm latest code (main branch)
assume put in `/llvm`

set up build prerequisite
```
yum -y install gcc g++ gcc-c++ libatomic libstdc++-devel libstdc++-static binutils binutils-devel glibc glibc-static coreutils bash
yum -y install make dos2unix git chrpath perl-generators perl-Digest-MD5 libxml2-devel libffi-devel zlib-devel ncurses-devel libedit-devel perl-Sys-Syslog aone-yumtools perl-Data-Dumper perl-Encode elfutils-libelf-devel
yum -y install  python3 python3-pip python3-devel
yum -y install openssl-devel.x86_64

```

create build directory

```
cd /llvm
mkdir build_compiler_rt_test_with_libcxx
cd build_compiler_rt_test_with_libcxx
```
configure
```
LDFLAGS="-fuse-ld=lld -Wl,-q -Wl,-znow -Wl,-build-id=sha1" cmake -G Ninja \
 -DCMAKE_BUILD_TYPE="Release" \
 -DCMAKE_C_FLAGS="-Wno-backend-plugin" \
 -DCMAKE_CXX_FLAGS="-Wno-backend-plugin" \
 -DCMAKE_C_COMPILER="/opt/prebuilt_llvm/bin/clang" \
 -DCMAKE_CXX_COMPILER="/opt/prebuilt_llvm/bin/clang++" \
 -DLLVM_ENABLE_CLASSIC_FLANG=ON \
 -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;openmp" \
 -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi" \
 -DLLVM_LIBDIR_SUFFIX=64 \
    -DLLVM_USE_LINKER=lld \
 -DLLVM_PARALLEL_COMPILE_JOBS="96" \
    -DLLVM_PARALLEL_LINK_JOBS=96 \
    -DLLVM_ENABLE_NEW_PASS_MANAGER=ON \
 -DLLVM_TARGETS_TO_BUILD="X86;BPF;WebAssembly" \
 -DLLVM_ENABLE_LIBCXX=ON \
    -DLLVM_STATIC_LINK_CXX_STDLIB=ON \
 -DLLVM_BINUTILS_INCDIR="/usr/include" \
    -DLLVM_ENABLE_TERMINFO=OFF \
    -DLLVM_ENABLE_LIBXML2=OFF \
    -DLLVM_ENABLE_LIBEDIT=OFF \
    -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
 -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
    -DCOMPILER_RT_BUILD_XRAY=OFF \
    -DCOMPILER_RT_BUILD_ORC=OFF \
 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
 -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=OFF \
 -DOPENMP_ENABLE_LIBOMPTARGET=OFF \
    -DOPENMP_ENABLE_OMPT_TOOLS=OFF \
    -DOPENMP_ENABLE_TESTING=OFF \
 -DCOMPILER_RT_LIT_USE_LIBCXX=ON \
    -DCOMPILER_RT_CXX_LIBRARY=libcxx \
    -DSANITIZER_CXX_ABI=libc++ \
    -DSANITIZER_CXX_ABI_INTREE=ON \
    -DSANITIZER_USE_STATIC_CXX_ABI=ON \
 -DSANITIZER_TEST_CXX=libc++ \
    -DSANITIZER_TEST_CXX_INTREE=ON \
 -DSANITIZER_USE_STATIC_TEST_CXX=OFF \
    ../llvm
```

build 

```
ninja
ninja check-compiler-rt
```

and errors occurred.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z4jjW_jXKjUoU2HzlIhfmq9e7BFJA3s7MjUu2D6BtWfJKchL64v3tW5JtvgLp3u701EzVpAjI8EjnOUdH0iPLVGu2EQB3qDNAndENLcxWqrsH9oUm2-Ifu-AmlunuLtA4A2GYFJBiJvDWmFwjP0DeBHmTDTPbIm4kMkPehPPn-oPkSv4bEoO8CdO6AI28Sc9rNfsN1ByhZkDXBhR-ARwXjKc4kVnOOCiiDDagDdZFkoDW-IWZLeYsTpA3QN4AU5HinJpk-7_zyAvOSxatVkniBfBGGkyFNFtQGJSSCtNYFuaEENVUYM4qZgnVoDHy-hgamwbqNhMpDNsUstCRLVImQDWSPEfdJvJuS0vVe7dZvdzlJAinyA9wkKYKtF5SwQz7Coq89rtRt004E8Urti76AV6BNkNrGnmTaxYtq167i-Uad3q97sG69-MvvBovVxh5vQ9jibwetq6PR_hniJWujV-ZwUOZgrXeOg72UGaZzZZ5YfLC2NBok4JSNip-hSGk_Fw8zmx9ajBnAnDLXhzyyKVoVGdEp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