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

    <tr>
        <th>Summary</th>
        <td>
            [libc] lib-hdrgen cannot correctly handle CRLF EOL on WIndows when generating libc header files.
        </td>
    </tr>

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

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

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

<pre>
    When building LLVM libc (along side with armv6m runtime), libc-hdrgen will fail on Windows when the EOL of the header `.def` is CRLF. libc will be built correctly if the file uses LF as EOL symbol.

Error messages from failed build:

```
[83/397] Generating C:/src/llvm-project-crlf/build/include/armv6m-unknown-eabi/ctype.h
FAILED: C:/src/llvm-project-crlf/build/include/armv6m-unknown-eabi/ctype.h
libc\include\CMakeFiles\ctype.h-70fb469.bat 8f95c5ccac8d093e
C:/src/llvm-project-crlf/libc/include/ctype.h.def:14:14: error: Command argument list should begin with '(' and end with ')'.
%%public_api()
             ^
Batch file failed at line 3 with errorcode 1
```

If re-checkout the llvm-project with git autocrlf conversion disabled, the build will succeed.

A small reproducer to demo this issue:
[libc_hdrgen_repro.zip](https://github.com/llvm/llvm-project/files/14673221/libc_hdrgen_repro.zip)

 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VM1u8ygUfRqyuYrl4OCfhRdpUo8q5dNIs5guKwzXNlMMEeBG7dOPDIma-ZFGs_iiCCU293DvOYfDvVejQWwJeyLstOFLmKxrv9BZO-PIN72Vn-3rhAb6RWmpzAjn8-8_QKteAKE119aM4JVEuKowAXfzRzmDW0xQMxLaEHqMm7eTdCMauCqtYeBKgzXwqoy0Vw_X9YAwITz_egY7xJ8TcokOSJlnEgdS5qA8HH87d1k6PAL1GPsKIKxzKIL-BJXKB6URFo8ezh1wH5H959xbnZH8RPJDWp-dsw5m9J6P6GFwdo7doUwDk-LwuJ2U-e2b_rKnuiC0K5qKsBP8ggYdDytJx7WQdt4JQjutP-btxdk_UIStcHogtEvotFNG6EUioV2ibruYd2OvZou8V4R2InxeMJvSed3h5fx8IsXhJ-GvxBJ2vNew4_EHf8dOafSEHW9bt1U-9PuyyXoeoB4aJpgQXNQybwpMOP_ZXTzosbkbdpS6OOz29wVwFShObOeZGwncjcuMJoBWPoCf7KIl9DgqkxxIaEVoTWgF62408uFxQ2h1l58yQtll6bUSb_yiYk2T3sHjh7Dn9PSJBzElX90cwtcmDEKRjoitCisRdv_ulri-DOBwKyYU73YJ0auPDCWoUQXgS7ArXSCs-UDnlTUglee9RrneqrUyqpyugl-EQJR_cfcB_My1BocXZ-Ui0EGwIHG2ECblQXm_4LfF2dOqy1u6qW-xKPtSF8JOhNZTCBefdCW0G1WYlj4Tdr4p_DehCe2GaBva7fZlVVC6u8n-T_g77TfyN7ItZFM0fIPtrtrlTVU0FdtMrcibvizKuqx2-6quGOdFI1iJstqxHhu6US3N6T4vaE5pQRnLCtkMFWP9UDZNvcsp2ec4c6WztdXMunETGWjrMqfFRvMetY9RSGlyKF1D0bVxsn4ZPdnnq-38N0BQQcf4THfntIbTPesEN8Y-ZtPEjdQYUyxFnYHXl4cIHL8DJGbcLQMjk9lmcbr93yrEAVcZ4ox_BgAA__9RZOOw">