<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJy1VMGOmzAQ_Rq4jEAEkkAOHHYb7Wl72qrXypghuDE28phE-fuOIc1G3W2rqq1kwXjGvHl-zExj20v9wQ6j0socoLMOhBtO5ZAYazBB0SiI8iq4zQWs79FBIxwO6IUOR8ELd0Af5Ts4K9-D9hYIcSBgo0EYLZFqNII1-gLnHg3IWzphWmDjONsOoeWcoAz4cwAZhRMew_GBD1IKDzAoowZO7JE8SEEYFQ9Rto-y6zP4U_nq3GbLksv-ZFULX4gpM-Eq7ALvqHxcwgAO_eRMVFwdUbn_Aeg-2atsWh0RfK8IztYd6W3-RlC_uKQW_EGyqPZW62TotBU-YTsq9mQ7Dxwl32rVQNIFdRMJyzUhsYtl_xl0NxEmuuW41u0V_JYGdfeHanRC6f-txjuU5W8pz6VqJz9O_i29O2rJquA4oHPWBSPKy3uSkzkaezYzWQ6FE5MRodqZ2SiI4Pn580dolE-kbRE6pXFujFD06H6h5qcgHy8Bo7MMODCc80pOWjjuI1JGIgxI1gAJo_wFZI_yyOA9XhssdOrlJ8020ewJOAd9a7E0buui3RU7EYvJ99bVLx5PaE7ti-yt9fHkdN17P87_NH_idWAhpyZlAN5offr-Spj2V5TcZk-KaEJiY5NXWRn3tdy2ZbOqMtlsOyGzQnRVVbXdRmb5qiu3u1iLBjXV0eYxynODZ5gh2I42-_jvGag650yrPM9W5WqdrdNsuxbNRmzWu5WQxXYbrTMcuHTTgJNad4hdPUM204E4qBV5eg3yf1YHgzgTZoZeeY13Q_VeeB5uYcaRx3HpjmUkLv-Da2Auan7PH837-_IOgTCi35vAlMbzPev5kt8A7J7ilg>52807</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Compiling and linking in one step fails when using `-flto` and `-fuse-ld=lld` for baremetal arm targets.
        </td>
    </tr>

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

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

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

<pre>
    Compiling for armv7m-none-eabi (or any other baremetal arm target) with lto seems to be possible only when compiling and linking are done in two separate commands. A minimal test case:

test.c:
```c
void _start(void) {
  return;
}
```

Compiling like this works:
```bash
clang -target armv7m-none-eabi -mfloat-abi=soft -nostdlib -flto -c test.c -o test.o
clang -target armv7m-none-eabi -mfloat-abi=soft -nostdlib -flto -fuse-ld=lld test.o -o test.elf
```

Compiling like this fails:
```bash
clang -target armv7m-none-eabi -mfloat-abi=soft -nostdlib -flto -fuse-ld=lld test.c -o test.elf
```
with output:
```
clang-13: error: 'armv7m-none-unknown-eabi': unable to pass LLVM bit-code files to linker
```

This is a problem particularly since meson sanity checks the compiler by compiling and linking using a single command.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VE2PmzAQ_TVwGYEIHyE5cNhttKftaateK9sM4MbYyDaJ8u87hjQbdXdbVWolC8Yz9ps3Yz9z016aT2acpJK6h85YYHY81WOijcYEGZcQ5bvg1hcwfkALnFkc0TMVloJntkcf5Xs4Sz-A8gYc4uiADI4wGeckVwhGqwucB9QgbumYboGM42JbhJZygtTgzwFkYpZ5DMtHWuhSeIBRajlSYo_Og2AOo-Ihyg5Rdv0GfypendtsHWKdn4xs4ZsjykR4F2aBd1Q_rmEAi362Oiqujqg-_AJ0n-y1bUoeEfwgHZyNPbq3-Tlzw-oSitGGZO3a214nY6cM8wnZUXFwpvNAUedbJTkkXehuImAtExKzWuafQXezw0S1FFeqvYLf0qDq_rIbHZPqf3fjHcrij5SXq2pmP83-Lb07asmmoDigtcYGI8rre5KzPmpz1gtZCoUVs2bhthOziTkHz89fPwOXPhGmReikwkUY4dKj_U03v4T20WAwWUOAI8FZL8WsmCUdOakFwojOaHBMS38BMaA4EviAV4EFpV4-ENvsFk_A6dVNYmncNkW7L_Ys9tIrvHsY7jeTQINOncdpPeFV1ism1bEcDP2XTcv8_ohCIDwz770iLo1nq5rB-2m5NvkTjZ7OauYpcaSJUqefv4Q68x0FKflJOjejI6PKd1kdD0293_OKSqnKGitRYttu-V7wXVZ2xabKqlgxjso1UfUY5bnGMywQZEfVIZZNnuWbTZ5nm3pTZmWabUvGK1aV-w0TxXYblRmOVHkaeKTG9rFtFkp87h0FlXRUyy1IF0H2GnFJR_hs9oOxzYvHE-pT-yIGY3y8MGiWCn4As-rMng">