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

    <tr>
        <th>Summary</th>
        <td>
            Regression: <chrono> does not compile on macOS with `_XOPEN_SOURCE` defined
        </td>
    </tr>

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

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

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

<pre>
    Repro (minified from absl's time_zone_format.cc):

```
% cat chrono.cc 
#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
#define _XOPEN_SOURCE 500 // Exposes definitions for SUSv2 (UNIX 98).
#endif

#include <chrono>
```

```
% clang++ -I../../buildtools/third_party/libc++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -nostdinc++ -isystem../../third_party/libc++/src/include  -c chrono.cc  -std=c++20
In file included from chrono.cc:5:
In file included from ../../third_party/libc++/src/include/chrono:969:
In file included from ../../third_party/libc++/src/include/__chrono/formatter.h:29:
In file included from ../../third_party/libc++/src/include/__chrono/ostream.h:36:
In file included from ../../third_party/libc++/src/include/__format/format_functions.h:21:
In file included from ../../third_party/libc++/src/include/__format/format_context.h:28:
In file included from ../../third_party/libc++/src/include/__locale:14:
In file included from ../../third_party/libc++/src/include/__locale_dir/locale_base_api.h:98:
In file included from ../../third_party/libc++/src/include/__locale_dir/support/apple.h:18:
../../third_party/libc++/src/include/__locale_dir/support/bsd_like.h:149:10: error: no member named 'wcsnrtombs_l' in the global namespace; did you mean '__wcsnrtombs'?
  149 |   return ::wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __loc);
      | ^~
../../third_party/libc++/src/include/__locale_dir/support/bsd_like.h:148:1: note: '__wcsnrtombs' declared here
  148 | __wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) {
      | ^
../../third_party/libc++/src/include/__locale_dir/support/bsd_like.h:158:10: error: no member named 'mbsnrtowcs_l' in the global namespace; did you mean '__mbsnrtowcs'?
  158 |   return ::mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __loc);
      | ^~
../../third_party/libc++/src/include/__locale_dir/support/bsd_like.h:157:1: note: '__mbsnrtowcs' declared here
  157 | __mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) {
      | ^
```

(We might be able to work around this by defining `_XOPEN_SOURCE` with a `-D` flag while compiling that file, haven't tried that yet.)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMV81u4zYXfRp6c2FDoixLWnhhx_b3BWiTQdJpZ0dQ1LXFDkUKJBVPZtFnLygpcTzjAG0xLhoYMeX7c3iOjqQr7pw8aMQlSdck3Ux452tjl1oKMylN9bx8wNYaIDRvpJZ7iRXsrWmAl04RmjnwskH21Whke2Mb7mdCEFqQZEWi_rOIxk-0IjQFwT2I2hptZkJA_2Mi90BoXOFeaqwIzdmn-w_bO_Z4__HhZktoAYQuCF18k8R2FnH9uGHs_ZT7FvVLyoA1ROEMAtIoAkJ3hO5g-6U1Dh30edJLox3sjYXHj49PNMjw8e72ExQ5ocVs6Ii6kvuRLE2kFqqrEEhyM9AkyfZbGS6oorg-ELomdA3T29mM0F3_r-ykqrwxyhG687W0FWu59c-E7pQsxUvFhv10u7758IH9f_Ww2d7d3v2P_Xy_2ZLknQDbfvple_d4--sWpto4X0n92ku6Z-exOe3hPVhCd84KQncvlGEq3pxamDpfkWQzZtNA9VbDXiqEsWK00msNSVbpYJzLiX9_T4TuXs7CqlgUP7w5Y2N7uhvc79HOapKs6FWxjPMWedMjJYsrIA1kXlmxfadFfy0M5OJ_AVIY7fGLHwDzKwAqI7hCkqzi-dW6s0rakDsclNwh463sORXX4zSiuq5tjQ2S8rZV2KPGI-qP7V-6iin5eYSYB-_HEUlWg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