<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64631>64631</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] __attribute__((target_clones)) is accepted even when not supported by the platform (linux-musl)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nekopsykose
</td>
</tr>
</table>
<pre>
doing
```console
/ # cat main.cc
static int __attribute__((target_clones("default,avx")))
has_target_clones(void) {
return 0;
}
int main(void) {
return has_target_clones();
}
/ # clang++ main.cc -o x
/ # echo $?
0
```
successfully compiles, but then
```console
/ # ldd x
/lib/ld-musl-x86_64.so.1 (0x7fbb9a2ee000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7fbb9a2ee000)
Error relocating x: unsupported relocation type 37
```
by contrast, gcc
```console
/ # g++ main.cc -o x
main.cc:2:1: error: the call requires 'ifunc', which is not supported by this target
2 | has_target_clones(void) {
| ^~~~~~~~~~~~~~~~~
```
this is because musl does not support ifunc.
i can perhaps imagine some rationale for why it would successfully compile anyway (despite the musl target not supporting it ever), but this breaks configure tests that [check if it's supported](https://github.com/libvips/libvips/blob/8d5f33174c956623c1b7eb82c43c828c0511cc22/meson.build#L149) (it detects as valid and uses it, generating a broken exe). a compile+executable test would catch it instead, but that is less feasible when cross compiling.
perhaps clang should follow what gcc does?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVcuO8ygTfRqyKXVkg6-LLLo7X1b_O0QYl23-JuChIJfNPPsIO339Wt-0JrIcC6ji1DmHQhLp0SLuWPnEyv1GxjA5v7P44ma6vTjCTef626532o4s27Ps8f6usvVRzpIzeB_lB2BcgJIBTlLbrVKwzlCQQSvQNsDxKEPwuosBj0fGG8abIP2I4aiMs0jLEO9xkNEExp_l-co4Z7y9P0u-SdLxa9TZ6Z7xFlj9tC4CAPA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