[Bug c/91664] Undefined reference linker errors when static linking archive with gcc target_clones function multi-versioning

element at elementsofsound dot org gcc-bugzilla@gcc.gnu.org
Thu Sep 5 06:55:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91664

--- Comment #6 from element at elementsofsound dot org <element at elementsofsound dot org> ---
I removed the internal_func() with the target_clones attribute, which caused
the last number digit of the symbols for fmv_test clones to match up between
object files, but errors still occur. I ran nm on the resulting archive and got
the below output, which may provide a clue. Note that the fmv_test target clone
functions have lower case 't' for local Text and don't end up in the archive
index. I removed the target_clones attribute and fmv_test ends up being a
global Text symbol (also pasted below), which builds fine:

nm -s fmv-test.a
Archive index:
main in main.o
fmv_test in main.o
fmv_test.resolver in main.o
fmv_normal_function in fmv-test.o
fmv_test.resolver in fmv-test.o
fmv_test in fmv-test.o

main.o:
                 U __cpu_indicator_init
                 U __cpu_model
0000000000000000 i fmv_test
                 U fmv_test.avx.1
                 U fmv_test.avx2.0
                 U fmv_test.default.4
0000000000000000 W fmv_test.resolver
                 U fmv_test.sse2.3
                 U fmv_test.sse4_1.2
                 U _GLOBAL_OFFSET_TABLE_
0000000000000000 T main
                 U malloc
                 U memset

fmv-test.o:
                 U __cpu_indicator_init
                 U __cpu_model
000000000000004d T fmv_normal_function
0000000000000000 i fmv_test
00000000000000a8 t fmv_test.avx.1
000000000000005b t fmv_test.avx2.0
0000000000000000 t fmv_test.default.4
0000000000000000 W fmv_test.resolver
0000000000000142 t fmv_test.sse2.3
00000000000000f5 t fmv_test.sse4_1.2
                 U _GLOBAL_OFFSET_TABLE_




This is when fmv_test is defined without target_clones attribute:
Archive index:
main in main.o
fmv_test in fmv-test.o
fmv_normal_function in fmv-test.o

main.o:
                 U fmv_test
                 U _GLOBAL_OFFSET_TABLE_
0000000000000000 T main
                 U malloc
                 U memset

fmv-test.o:
000000000000004d T fmv_normal_function
0000000000000000 T fmv_test


More information about the Gcc-bugs mailing list