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

    <tr>
        <th>Summary</th>
        <td>
            [OpenMP] [runtime] Broken MacOS build in 21.1.0+ if hwloc is turned on
        </td>
    </tr>

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

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

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

<pre>
    We are seeing new build failures on MacOS while trying to [package LLVM 21.1.0 for Spack](https://github.com/spack/spack-packages/pull/1212#issuecomment-3248022549) compare to `20.1.8`.

```
kmp_alloc.cpp:1549:46: error: unknown type name 'hwloc_membind_policy_t'
 1549 | static bool __kmp_is_hwloc_membind_supported(hwloc_membind_policy_t policy) {
```

My initial diagnosis is that recent code changes in `openmp/runtime` introduced this bug due to the following:
- The `hwloc.h` is only included on systems with [`KMP_AFFINITY_SUPPORTED`](https://github.com/llvm/llvm-project/blob/3623fe661ae35c6c80ac221f14d85be76aa870f1/openmp/runtime/src/kmp.h#L107-L108), which is not the case for [Darwin](https://github.com/llvm/llvm-project/blob/3623fe661ae35c6c80ac221f14d85be76aa870f1/openmp/runtime/src/kmp_os.h#L78-L90).
- `kmp_alloc.cpp` has now has code parts that use the hwloc API but only guards them with [`KMP_USE_HWLOC`](https://github.com/llvm/llvm-project/blob/llvmorg-21.1.0/openmp/runtime/src/kmp_alloc.cpp#L1548-L1549) instead of `KMP_USE_HWLOC && KMP_AFFINITY_SUPPORTED`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVE-P4yYU_zTk8hQL44DtQw7JZK2OmumMOrNd9RRh_GLTwWAB3ijfvsKT0WqnrVZVL5WQQIG8_P7lJ0PQvUXcEr4n_LCScxyc3_q2Rd-jX7Wuu26_IEiPEBC17cHiBdpZmw7OUpvZYwBn4UGqx2e4DNogRH9ND6MDw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