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

    <tr>
        <th>Summary</th>
        <td>
            Failed to build clang 15.0.1 with openmp
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          JaySon-Huang
      </td>
    </tr>
</table>

<pre>
    Kind of similar to https://github.com/llvm/llvm-project/issues/57922
I can build successfully with `LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"`, but if I add `openmp` into `LLVM_ENABLE_RUNTIMES`, it throws an error
```
cmake -DCMAKE_BUILD_TYPE=Release \
        -GNinja \
        -DLLVM_ENABLE_PROJECTS="clang;lld;polly;clang-tools-extra;bolt" \
        -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;openmp" \
        -DLLVM_TARGETS_TO_BUILD=Native \
        -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \
        -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
        -DCLANG_DEFAULT_LINKER=lld \
        -DCLANG_DEFAULT_CXX_STDLIB=libc++ \
        -DCMAKE_CXX_COMPILER=clang++ \
        -DCMAKE_C_COMPILER=clang \
        -DLLVM_ENABLE_LIBCXX=ON \
        -DLLVM_ENABLE_LLD=ON \
        -DLIBOMP_LIBFLAGS="-lm" \
        -DCMAKE_INSTALL_PREFIX="/data3/jaysonhuang/tools/llvm" \
        -DCMAKE_INSTALL_RPATH="\$ORIGIN/../lib/;\$ORIGIN/../lib/$(uname -m)-unknown-linux-gnu/" \
        ../llvm
ninja -j6
...
[119/131] Linking C shared library openmp/runtime/src/libomp.so
[120/131] Linking CXX shared library openmp/libompd/src/libompd.so
FAILED: openmp/libompd/src/libompd.so
: && /data3/jaysonhuang/my/llvm-project/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wcast-qual -Wformat-pedantic -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -std=c++14 -std=c++11 -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics -shared -Wl,-soname,libompd.so -o openmp/libompd/src/libompd.so openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o openmp/libompd/src/CMakeFiles/ompd.dir/omp-debug.cpp.o openmp/libompd/src/CMakeFiles/ompd.dir/omp-state.cpp.o openmp/libompd/src/CMakeFiles/ompd.dir/omp-icv.cpp.o  -Wl,-rpath,/data3/jaysonhuang/my/llvm-project/build/runtimes/runtimes-bins/openmp/runtime/src:  openmp/runtime/src/libomp.so  -lpthread  -lrt  -lm  -ldl && :
ld.lld: error: undefined symbol: std::_LIBCPP_ABI_NAMESPACE::ios_base::init(void*)
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getSize(unsigned long*))
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getBitfieldMask(char const*, unsigned long*))
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getElementOffset(char const*, unsigned long*))
>>> referenced 1 more times

ld.lld: error: undefined symbol: std::_LIBCPP_ABI_NAMESPACE::basic_streambuf<char, std::_LIBCPP_ABI_NAMESPACE::char_traits<char>>::basic_streambuf()
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getSize(unsigned long*))
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getBitfieldMask(char const*, unsigned long*))
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getElementOffset(char const*, unsigned long*))
>>> referenced 1 more times

ld.lld: error: undefined symbol: std::_LIBCPP_ABI_NAMESPACE::basic_ostream<char, std::_LIBCPP_ABI_NAMESPACE::char_traits<char>>::operator<<(int)
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getSize(unsigned long*))
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getSize(unsigned long*))
>>> referenced by TargetValue.cpp
>>>               openmp/libompd/src/CMakeFiles/ompd.dir/TargetValue.cpp.o:(TType::getSize(unsigned long*))
>>> referenced 57 more times
```

The full compile log is attached here: 
[openmp_error.log](https://github.com/llvm/llvm-project/files/9630941/openmp_error.log)


```bash
>  ninja --version
1.10.2
>  cmake --version
cmake version 3.22.1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWEtz2zYQ_jXyBQOOSEqyddCBerlqZNkjy6174kAkKCEhCZUAbSu_vh8AylEcO3abHOppNRwIj93Ft7vYxWMt0_3ggyhTIjOiRCFyVhEtyVbrnWqFUSuY4tsIva3XXiILNPL87vBHd5X8yBONplCq5gqV7mk_CFrtcasdzUjCSrKuRZ4SVScJVyqr83xP7iGPtHrt-fy3i3iyiIbzSby8WaxmF5PrVjhuBUEu1snDQyscugpbC1evy3uABQG4W8EIwjURGZkRlqZGotzxstihQkQJNV6awzELTfS2kveKACavKlk53GbYfbaZFOwTJ3Q8uog-TOLhzWw-jld_XE2AdMlzzhQnre7I0ZLmR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