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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Enable `-fdata-sections` and `-ffunction-sections` in `-O3` /`-Ofast` optimizations automatically
        </td>
    </tr>

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

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

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

<pre>
    Is it possible to turn on `-fdata-sections` and `-ffunction-sections` automatically if I enable `-O3`/`-Ofast` in Clang? And is it possible to turn on `--gc-sections` in LLD? Up to now, these flags must be given manually.
For example,
```bash
clang -c -fdata-sections -ffunction-sections -O3 example.c -o example.o
```
should be the same as
```bash
clang -c -O3 example.c -o example.o
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUkt2OmzAQhZ_G3IxA_iEkXHCRJkVaaaW96gMYbMCVsRFj73b79JWhbZSoqnYlJPAM58xh-CSiGZ3WDTl8IYdrJmOY_NoIxmpR1RWrss6r9-YJwQRYPKLprIbgIcTVgXdAKpoPSgaZo-6D8Q5JRUE6tXeG6LbqfTcGP8tgemntO5gBnkA7mYyT5kWQihLebs-DxJAkxsHFSjcS0cLZKTD_DZSP_d1A4-D5-Zq035b0rvNvhF8gTBo1DFaOCHPEAJ2G0bxqB7N0MYUrCL0Sem79CvqHnBerCb_stRRyuzqJ017qU0LIe3jYCPxjD5C_iD-eRQ-5_3vwD_77EScfrUoJw6QB5axB4geSfHRKphqhalHLTDesOpYnVh5PLJuamh5PA1d8qDhlvGacH8qq1orSQVEqVGYaTrmgjB8ZZXXJCllqJXinqxPt-_7ISUn1LI0trH2dC7-OmUGMuqmoECyzstMWN_44d_oNtibhPOG4NkmTd3FEUlJrMODNJZhgN3B3Mg5X-Hqj6LNMGneDDx7p80sws_kp9z93h28WV9tMISxIxDnpeDuaMMWu6P1MeJvS_r7ly-q_6z4Q3m7fiIS32w5-BQAA__9XdBir">