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

    <tr>
        <th>Summary</th>
        <td>
            [libc++] Decouple the notion of providing a threading API and having multiple threads of execution
        </td>
    </tr>

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

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

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

<pre>
    Today, `LIBCXX_ENABLE_THREADS` controls both:
- whether libc++ provides a threading API, and
- whether libc++ assumes the platform to allow multiple threads of execution

However, some systems exist where we can't (or don't want to) provide the libc++ threading API, yet the platform does support multiple threads of executions. In the current model, we are forced to pick between:
- `LIBCXX_ENABLE_THREADS=ON`, which causes libc++ to attempt to provide a threading API and fails to build
- `LIBCXX_ENABLE_THREADS=OFF`, which causes libc++ to assume that there can't be multiple threads of executions, and results in the code not using synchronization primitives, atomics and other thread-safe things. This can result in race conditions on such platforms.

Both options are clearly bad, and we should fix that.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVEuP2zYQ_jXUZbCGRPmlgw52vEYWCNKi3UNuAUWOTLYUR-BQ9rq_vqDs7SZt8zgJBDjfY75PVMzuFBBbsdqL1aFQU7IUW28chYBFR-baPpNRVyHfgViXH5727z59-vz4cbf_8Pj5-f1vj7vD72JdgqaQInmGjpIV9U6Uuwe4WEwWI3jXaSH3Qu5hjHR2BhkUJBtRGRdOsPv1KeOrYL41ppinARmSRRi9Sj3FARKB8p4uMEw-udHjHZKBesAX1FNyFESZxbynC54xZhqmAYGvnHBgwBfHKTNGhAuCVkHITQIhtxTB0O10USFBIiGbV_2zkC_0_cfLFdPXYg0hA0_jSDF9XzAv4CnMw3qKEUOCgQz6jHpBUBGhp6jRZP-j039Ch-mCGF63_s2Y6sMvH8W6nIGs0xa0mhj5Kx8EKiUcxjSj383-K6scFPTKec6Xusl580Pi4_EnmOeQIVk17y6-xdHhD1Z2rw9E5MknBndfIBmEQAkmztr5GrSNFNxfKk_BGN3gkjvjbT7R4DTPODQX8Eb1wKrPtC6ceAHP1nHWdafKTFHpTBWMm7UABeBJ23-y58Wtg3tKFmi8Xco5ao8q-it0yrwauCCwpckb6N3LvIpFYdraNHWjCmyrzbJqNvVaVoVtV1irbdc0Va1ws6kbs9kum6bqt6oqVw12hWtlKVdlXS2rTV0vq8UWuwZVt-z7WjfLqhPLEgfl_ML787CgeCoc84RtVVf1elV41aHn-W2Q8i0rIWV-K2Kbpx666cRiWXrHid9wkkt-flW-GFsd4ICapluKczA5BervRcsR_V_VrDrn43cbUEzRtzalkfNvII9CHk8u2albaBqEPGZh98_DGOkP1EnI4-yWhTzeDZ9b-XcAAAD__x0jsnI">