https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84833
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Martin Liška from comment #5) > (In reply to Jakub Jelinek from comment #2) > > Just a note, as can be seen e.g. on > > static volatile int a; > > static int my_foo1 (void) { return 1; } > > static int my_foo2 (void) { return 2; } > > typedef int (*F) (void); > > static F resolve_foo (void) { if (a) return my_foo1; else return my_foo2; } > > static int foo (void) __attribute__ ((ifunc ("resolve_foo"))); > > > > int > > main () > > { > > if (foo () != 2) > > __builtin_abort (); > > } > > there is no reason why any of the target clones, resolver or the ifunc > > function should be .globl, they can all be local to the TU, IFUNC work just > > fine that way too. So, if the function with target_clones attribute is not > > TREE_PUBLIC, neither should be any of the multiple_targets.c created > > symbols. > > If I see correctly, we do not make these global: > > nm pr84833-2.o > 0000000000000000 b a > U abort > 000000000000000c i foo > 0000000000000022 T main > 0000000000000000 t my_foo1 > 0000000000000006 t my_foo2 > 000000000000000c t resolve_foo > > Note that it was subject of PR81213. nm is not really usable to determine if an IFUNC symbol is global or local, i is printed regardless if it is global or local. $ nm pr84833 | grep foo; readelf -Ws pr84833 | grep foo 0000000000400560 i foo 0000000000400540 t my_foo1 0000000000400550 t my_foo2 0000000000400560 t resolve_foo 27: 0000000000400540 6 FUNC LOCAL DEFAULT 13 my_foo1 28: 0000000000400550 6 FUNC LOCAL DEFAULT 13 my_foo2 29: 0000000000400560 23 FUNC LOCAL DEFAULT 13 resolve_foo 31: 0000000000400560 23 IFUNC LOCAL DEFAULT 13 foo $ nm pr84833-2 | grep foo; readelf -Ws pr84833-2 | grep foo 0000000000400560 i foo 0000000000400540 t my_foo1 0000000000400550 t my_foo2 0000000000400560 t resolve_foo 27: 0000000000400540 6 FUNC LOCAL DEFAULT 13 my_foo1 28: 0000000000400550 6 FUNC LOCAL DEFAULT 13 my_foo2 29: 0000000000400560 23 FUNC LOCAL DEFAULT 13 resolve_foo 59: 0000000000400560 23 IFUNC GLOBAL DEFAULT 13 foo Where pr84833.c is the above #c2 testcase and pr84833-2.c is that without static keyword on foo. These testcases are compiled fine, what I was trying to make sure is that if the target_clones function is static, it is not exported outside of the TU.