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

    <tr>
        <th>Summary</th>
        <td>
            Inconsistent `clang --target` behavior across musl archs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    It appears clang is able to locate the gcc toolchain from triplet without distro name for aarch64, but not armv7:
Setup:
```sh
# aarch64 gcc toolchain
$ ls /crossrootfs/arm64/usr/lib/gcc
aarch64-alpine-linux-musl

# armv7 gcc toolchain
$ ls /crossrootfs/arm/usr/lib/gcc
armv7-alpine-linux-musleabihf
```

Test:
```sh
✅ aarch64-alpine-linux-musl
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm64" --target=aarch64-alpine-linux-musl

✅ aarch64-linux-musl
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm64" --target=aarch64-linux-musl

✅ armv7-alpine-linux-musleabihf
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm" --target=armv7-alpine-linux-musleabihf

❌ armv7-linux-musleabihf
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm" --target=armv7-linux-musleabihf
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/ld: cannot find -lgcc: No such file or directory
/usr/bin/ld: cannot find -lgcc: No such file or directory
clang-18: error: linker command failed with exit code 1 (use -v to see invocation)
```

Other musllibc-based distros use neutral names for gcc toolchain: `${arch}-linux-musl`. Due to this disparity in identifying gcc toolchain, we would need to special case musleabihf for Alpine Linux.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVc2O4zYTfBrq0pAhUbIlHXTw2J-BBT4kh80L8KcldUKRAkl5xm8fUOPZ2Z3F7E4OCRYw4B_RVdXF7moRAo0WsWf7B7Y_Z2KNk_O9mMsyk07f-k8RxLKg8AGUEXYECiCkQYgOjFMiIsQJYVQKonNGTYIsDN7NED0tBiM8UpzcGkFTiN6BFTPC4DwI4dV0qBk_gVwjWBdB-PnasOrIijMrjp8xrsuXb-xQPL_CdP-BVy8Y39K_PK7BBGD8orwLwTsXh8D4Rfg5kV7W4Bm_GJKMX0alnv90x8uFWchibsiuT_m8BnPHfCVOSv8h7bukCet7ShSSpuFN8V_r-AND_IE9_-OsO7F2Dz8riteAanLAOCcbYU618PbqSDPeAWsegDVnxjmw5vTcBHnZQv6kIIc8D7etSFalI--5zSHPo_AjpnMfM_k7-b-M7p8K_sB9_sva3yr_gKLXIs6sPd2L-IXUvyflPlMySbgYzaojKGFTmgxkNSgfJY5kP-9cevSbg7CqCQYyCM6DJo8qOn_7IFxu0tj-h0Av7qWj6L3z6YMh-xd6UG6ehdUwCDKot6AFfKIIymmEEhhv14CQX1NYB0Qge02RTc4y3v0gWX6PE3pIXhuSKpcioL7nd4AEaXGNXpgtzMOW5t9GYXWEBMlr1jykqWHN-euxORQ7OK_bDokThQS9CE_xBmSBNNpIw43s-AaVn-AR4dGtRoNF1FtZCyoSBpQICK_dsWk6bg0P_0_Eu0z3le6qTmTYl01ZVW1b8SqbelkKMez3VSerulVDi6pFWTVCtYofOuwy6nnB66IuG16WvOA7LQ8DamwOcr_nuhlYXeAsyOyMuc4758eMQlixb7uyPmRGSDRhW7Ccb9eZ2n5_znyfzudyHQOrC0MhhleESNFg_8kqZwOFiDYmR59X8JfZOBQgcRJXSut0G6PNAkiWh2z1pp9iXEJaEvySVg7FaZU75dIuSlT3t3zx7k9UkfHLpjzN4Sb-7wAAAP__4IqN8g">