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

    <tr>
        <th>Summary</th>
        <td>
            failed to build libcxx with LIBCXX_ENABLE_PARALLEL_ALGORITHMS=ON in release/15.x and main branch
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    cmake:
```shell
cd "<llvm-project>"
mkdir .build
cd .build
cmake \
    -DLLVM_ENABLE_RUNTIMES='pstl;libcxxabi;libcxx' \
    -DLIBCXX_ENABLE_PARALLEL_ALGORITHMS=ON \
    -DCMAKE_BUILD_TYPE=Release \
    ../
```

error message (gcc 12.2.0):
```
In file included from <llvm-project>/pstl/include/__pstl_algorithm:13,
                 from <llvm-project>/.build/include/c++/v1/algorithm:1911,
                 from <llvm-project>/.build/include/c++/v1/array:536,
                 from <llvm-project>/.build/include/c++/v1/__functional/boyer_moore_searcher.h:24,
                 from <llvm-project>/.build/include/c++/v1/functional:515,
                 from <llvm-project>/libcxx/src/atomic.cpp:14:
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h: In function ‘__pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, bool> std::all_of(_ExecutionPolicy&&,
_ForwardIterator, _ForwardIterator, _Pred)’:
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:47:87: error: ‘not_fn’ is not a member of ‘std’
   47 |     return !std::any_of(std::forward<_ExecutionPolicy>(__exec), __first, __last, std::not_fn(__pred));
      |                                                                                       ^~~~~~
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:23:1: note: ‘std::not_fn’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’?
   22 | #include "execution_impl.h"
  +++ |+#include <functional>
   23 |
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h: In function ‘__pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find_if_not(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate)’:
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:96:87: error: ‘not_fn’ is not a member of ‘std’
   96 |     return std::find_if(std::forward<_ExecutionPolicy>(__exec), __first, __last, std::not_fn(__pred));
      |                                                                                       ^~~~~~
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:96:87: note: ‘std::not_fn’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’?
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h: In function ‘__pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::remove_copy_if(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Predicate)’:
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:444:97: error: ‘not_fn’ is not a member of ‘std’
  444 |     return std::copy_if(std::forward<_ExecutionPolicy>(__exec), __first, __last, __result, std::not_fn(__pred));
      |                                                                                                 ^~~~~~
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:444:97: note: ‘std::not_fn’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’?
make[2]: *** [libcxx/src/CMakeFiles/cxx_shared.dir/build.make:104: libcxx/src/CMakeFiles/cxx_shared.dir/atomic.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2616: libcxx/src/CMakeFiles/cxx_shared.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
```

error message (clang 15.0.1)
```
In file included from <llvm-project>/libcxx/src/atomic.cpp:14:
In file included from <llvm-project>/.build/include/c++/v1/functional:515:
In file included from <llvm-project>/.build/include/c++/v1/__functional/boyer_moore_searcher.h:24:
In file included from <llvm-project>/.build/include/c++/v1/array:536:
In file included from <llvm-project>/.build/include/c++/v1/algorithm:1911:
In file included from <llvm-project>/pstl/include/__pstl_algorithm:13:
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:47:87: error: no member named 'not_fn' in namespace 'std'
    return !std::any_of(std::forward<_ExecutionPolicy>(__exec), __first, __last, std::not_fn(__pred));
                                                                                 ~~~~~^
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:96:87: error: no member named 'not_fn' in namespace 'std'
    return std::find_if(std::forward<_ExecutionPolicy>(__exec), __first, __last, std::not_fn(__pred));
                                                                                 ~~~~~^
<llvm-project>/pstl/include/pstl/internal/glue_algorithm_impl.h:444:97: error: no member named 'not_fn' in namespace 'std'
    return std::copy_if(std::forward<_ExecutionPolicy>(__exec), __first, __last, __result, std::not_fn(__pred));
                                                                                           ~~~~~^
3 errors generated.
make[2]: *** [libcxx/src/CMakeFiles/cxx_shared.dir/build.make:104: libcxx/src/CMakeFiles/cxx_shared.dir/atomic.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2616: libcxx/src/CMakeFiles/cxx_shared.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
```

no error in building release/14.x

system: Linux 5.19.0-2-amd64
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWVFzmzgQ_jX4RRMGBNjmwQ-2g-8y57SZtL3pPWkEyLauAnkkaOx_3xVgjB2n4_TiNrkpw2AhpN3Vt6tPWjmW6XaUZPQLs7yx5VxbztjqO_WtV0yIui5JkYWx5U2F-JpdrZX8lyWF5UWmsmqQfUm5QnZccpG2XQ5ejQ5kBdP6FcF1dT2f_31LonfjyTwi95_efby5jT5Y3rWFB2tdCMubCB4nmw2NeVuGb4-k3Eymnz_v5NyN78fzeTQn4_kf7-9vPv55a0S-f3fca3o7_isik08382vy8Z-7CBrdM8GoPrLSti08O0Kmea2eTCmpUMa0pkvoiofLJEEutrHtWDh8jGr9epOjBRcM8TwRZcpStFAyQ6cAnlVQ4FnTEkqEmCpCxVIqXqwy0OF6Fu7YfHA9LbnxT1d2YuFJdc--uvA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