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

    <tr>
        <th>Summary</th>
        <td>
            [libc++] ctime std module on windows with ucrt
        </td>
    </tr>

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

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

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

<pre>
    Hello, i tried to build std module on windows but it seems some of the ctime functions are marked static in ucrt so clang fail to export them

e.g
```
stdmodules/std/ctime.inc:20:14: error: using declaration referring to 'ctime' with internal linkage cannot be exported
   20 |   using std::ctime;
      | ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\time.h:501:41: note: target of using declaration
  501 |         static __inline char* __CRTDECL ctime(
 ```
  
  i got the module to build successfully with patching `std/ctime.inc` like this
  
  ```cpp
  export namespace std {
 using std::clock_t;
  using std::size_t;
  using std::time_t;

 using std::timespec;
  using std::tm;

  using std::asctime;
 using std::clock;

#ifdef _UCRT
  inline char* __CRTDECL ctime(_In_ time_t const* const _Time) {
    return _ctime64(_Time);
  }

 inline double __CRTDECL difftime(_In_ time_t const _Time1, _In_ time_t const _Time2) {
    return _difftime64(_Time1, _Time2);
  }

  inline struct tm* __CRTDECL gmtime(_In_ time_t const* const _Time) {
    return _gmtime64(_Time);
  }

  inline struct tm* __CRTDECL localtime(_In_ time_t const* const _Time) {
    return _localtime64(_Time);
 }

  inline time_t __CRTDECL mktime(_Inout_ struct tm* const _Tm) {
 return _mktime64(_Tm);
  }
#else
  using std::ctime;
  using std::difftime;
  using std::gmtime;
  using std::localtime;
  using std::mktime;
#endif

  using std::strftime;
#ifdef _UCRT
 inline time_t __CRTDECL time(_Out_opt_ time_t* const _Time) {
    return _time64(_Time);
  }

  inline int __CRTDECL timespec_get(_Out_ struct timespec* const _Ts, _In_ int const _Base) {
    return _timespec64_get((struct _timespec64*)_Ts, _Base);
  }
#else
  using std::time;
  using std::timespec_get;
#endif
} // namespace std
```

here a self contained reproducer with full logs: https://github.com/Arthapz/libcpp-stdmodule-ctime-errors
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVtuO2zYQ_Rr6ZbCGRN3sBz94vTEatECLYIs-ChQ1ktilSIGkukm-vqAuXltZOWljGLrN8MzhmSE5zFpRK8QDSR5J8rRhvWu0ORyNa1j3dVPo8svhF5RSE3oCAc4ILMFpKHohS7CuhFaXvUTQCl6FKvWrhaJ3IBxYxNaC1S2CrsA1CNyJFqHqFXdCKwvMILTMvKBHYk5wEAp6bhxYDVwyVUPFhPTx8HOnjfMoLQmeSHAcr7itp9c0mP7Dq3XlyMsSerauJPQ8BN8KxUl0pAGJjmFMoiOgMdr4h94KVUOJXDLDPD8wWKEx_qvTQGg2IBCawatwDQjl0CgmQQr1wmoEzpTSDgqcyGI5cgEAGgDJTgBTEE8oOpLoOCJGjxdHgMGRJB_GTyfvl5z-MLo2rIWzkGiB0N3nXUroniSnvybNfxXOkuQUBiQ5fVRc9iUOr9tgS2lKw603eGlJchqEaEh0TIKQRMfYX0Bph_7umKnR-Yx9I8jMMgnCaTrjb8pdngslhULgDTOEHiHPT5-enz6cfoNJud2EsEgWwHwXUOshyXNVvVVazzlaW_VSfhn175jjjWdI0mCZ4TQAKV4QXCPsMsYlOO-6-dtUXYq1aDvGcShsks15WWZNav6Su6u8LRys-Ir37J7nlf39KN7JdsjvwLRLiKUHs4sKe28mCxBCI1GVWEH-5-nT8yUz30tt_lHlME4MuFbWebfhAfLnwWV_pSgAGHS9UZAPAGnsISa_qxmT7OlmghONUveFxCsWpaiqNSJj_NBvYCs2ukpuxn3jN-LMo-5QnblaZ3ruwLW3utXtzwo3Ivyoct-hIzVn8mcZXUBWSK1xmmK9sWlf3qjo3uW3rGcq7S2RmcU4eKLQrqlCI5QWV9bNcl9emC_VtuoxZXfV_ib3qsukwWVx0ghVKaq76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