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

    <tr>
        <th>Summary</th>
        <td>
            [libcxx] does not compile with -DLIBCXX_ENABLE_THREADS=OFF
        </td>
    </tr>

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

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

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

<pre>
    I'm doing some measurements of various configs disabled for libcxx, and turning off various configs.  While most configs build, setting -DLIBCXX_ENABLE_THREADS=OFF seems to result in a few compile time errors.

My full cmake command is simply:
```
$ cmake ../runtimes -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -G Ninja -DLLVM_ENABLE_LLD=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DLIBCXX_ENABLE_THREADS=OFF
```

Some of the errors I observe are:
```

/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:291:8: error: no type named '__libcpp_mutex_t' in namespace 'std'
  291 | std::__libcpp_mutex_t mutex = _LIBCPP_MUTEX_INITIALIZER;
      | ~~~~~^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:286:29: error: no member named '__libcpp_mutex_lock' in namespace 'std'
  286 | bool lock() { return std::__libcpp_mutex_lock(&mutex); }
      | ~~~~~^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:287:31: error: no member named '__libcpp_mutex_unlock' in namespace 'std'
  287 | bool unlock() { return std::__libcpp_mutex_unlock(&mutex); }
      | ~~~~~^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:303:8: error: no type named '__libcpp_condvar_t' in namespace 'std'
  303 | std::__libcpp_condvar_t cond = _LIBCPP_CONDVAR_INITIALIZER;
      | ~~~~~^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:299:45: error: no member named '__libcpp_condvar_wait' in namespace 'std'
  299 | bool wait(LibcppMutex& mut) { return std::__libcpp_condvar_wait(&cond, &mut.mutex); }
      | ~~~~~^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:300:34: error: no member named '__libcpp_condvar_broadcast' in namespace 'std'
 300 |   bool broadcast() { return std::__libcpp_condvar_broadcast(&cond); }
      | ~~~~~^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:626:38: error: variable does not have a constant initializer
  626 | _LIBCPP_CONSTINIT T GlobalStatic<T>::instance = {};
      | ^ ~~
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:640:88: note: in instantiation of static data member '__cxxabiv1::(anonymous namespace)::GlobalStatic<__cxxabiv1::(anonymous namespace)::LibcppMutex>::instance' requested here
  640 |   using type = GlobalMutexGuard<LibcppMutex, LibcppCondVar, GlobalStatic<LibcppMutex>::instance,
      | ^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:626:1: note: required by 'constinit' specifier here
  626 | _LIBCPP_CONSTINIT T GlobalStatic<T>::instance = {};
      | ^~~~~~~~~~~~~~~~~
/android0/llvm-project/build_libcxx/include/c++/v1/__config:1198:31: note: expanded from macro '_LIBCPP_CONSTINIT'
 1198 | #    define _LIBCPP_CONSTINIT constinit
      | ^~~~~~~~~
In file included from /android0/llvm-project/libcxxabi/src/cxa_guard.cpp:15:
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:626:38: error: variable does not have a constant initializer
  626 | _LIBCPP_CONSTINIT T GlobalStatic<T>::instance = {};
      | ^ ~~
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:641:62: note: in instantiation of static data member '__cxxabiv1::(anonymous namespace)::GlobalStatic<__cxxabiv1::(anonymous namespace)::LibcppCondVar>::instance' requested here
  641 | GlobalStatic<LibcppCondVar>::instance, PlatformThreadID>;
      | ^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:626:1: note: required by 'constinit' specifier here
  626 | _LIBCPP_CONSTINIT T GlobalStatic<T>::instance = {};
      | ^~~~~~~~~~~~~~~~~
/android0/llvm-project/build_libcxx/include/c++/v1/__config:1198:31: note: expanded from macro '_LIBCPP_CONSTINIT'
 1198 | #    define _LIBCPP_CONSTINIT constinit
      | ^~~~~~~~~
In file included from /android0/llvm-project/libcxxabi/src/cxa_guard.cpp:15:
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:291:25: warning: private field 'mutex' is not used [-Wunused-private-field]
  291 |   std::__libcpp_mutex_t mutex = _LIBCPP_MUTEX_INITIALIZER;
      | ^
/android0/llvm-project/libcxxabi/src/cxa_guard_impl.h:303:27: warning: private field 'cond' is not used [-Wunused-private-field]
  303 | std::__libcpp_condvar_t cond = _LIBCPP_CONDVAR_INITIALIZER;
      | ^
2 warnings and 8 errors generated.
```

I don't have a strong need for this particular config, more of "if you see something say something."  If the config is no longer supported, consider removing it.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWN1y2koSfprhpsuUGAGCCy4AQZZa7LgckpPdG2qkaWBOpBl2ZmSbvcizb_WIH5vYiX3KSe2pCuWS9TPd6v7661ZPC-fUWiMOWGfEOmlDVH5j7ECr_ItEJ6pCK7SukRm5G8wYT0qQRuk1OFMilChcZbFE7R2YFdwKq0zlIDd6pdYOpHIiK1DCylgoVJbf3zM-BqEl-Mpq0mNW34g1Af7YqAKhNM4fdWWVKiRJO_SeJC_S-Ww0_vx5ObkajuaT5eIfN5Nh-oHF6fvpFBxi6cAbsOiqwoPSIGCFd5CbckvKvSoR0FpjXZNFKYuG9fFyB6uqKCAvxRek1SWZqxw4VW6LHYv361g32v_Vl7y9F2k2GZ_aStMLHFyk48vhPydLMnT8_vJ6Np_csDjNC6HXjI8YH52WfLMALt7BldJ_CnJ2_uny4Op8npKbV0fR0cfZPF0u_nU9YXF6gwUKh2cyNx-vFrPLCeHDON8HIx7VJyJT9Xml75SWjPPvw_s0BOH4gYhhVuA3B3hhBiZzaG8RhMVnAdzDOBV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