https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101726
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
So the solution won't be so easy. We generally face the problem that:
void foo (void) __attribute__
((target_clones("avx512f,avx2,avx,default")));
is only a declaration. If we consider another TU with:
void
__attribute__ ((target_clones("avx512f,avx2,avx,default")))
foo (void)
{
}
we end up with:
/tmp/cc5grfLD.o:pr101726.c:foo: error: undefined reference to 'foo.avx512f.0'
/tmp/cc5grfLD.o:pr101726.c:foo: error: undefined reference to 'foo.avx2.1'
/tmp/cc5grfLD.o:pr101726.c:foo: error: undefined reference to 'foo.avx.2'
/tmp/cc5grfLD.o:pr101726.c:foo: error: undefined reference to 'foo.default.3'
anyway. That's caused by the fact that target_clones are made local and so the
references are unresolved.
My suggestion would be simply doing a normal declaration:
void foo(void);
and doing target_clone definition in another TU. Doing that works would work.
That said, we should likely forbid target_clone declarations. Or do I miss
something?