GCC function multi-versioning behaviour on Linux vs. macOS
Kim Walisch
kim.walisch@gmail.com
Mon Feb 27 13:22:00 GMT 2017
Hi,
I have written a simple C++ test program for function multi-versioning:
---------------------------------------------------------
#include <iostream>
__attribute__ ((target ("default")))
int func()
{
return 0;
}
__attribute__ ((target ("avx")))
int func()
{
return 1;
}
int main()
{
std::cout << func() << std::endl;
return 0;
}
---------------------------------------------------------
I can compile this program without any issues on Linux using GCC 5.4 using:
$ g++ -o test test.cpp
---------------------------------------------------------
But when I try to compile the same program on macOS (Sierra, version 10.12.3)
using GCC 6.3.0 installed via homebrew I get the following error:
$ g++-6 -o test test.cpp
test.cpp: In function 'int main()':
test.cpp:4:5: error: multiversioning needs ifunc which is not
supported on this target
int func()
^~~~
test.cpp:17:23: error: use of multiversioned function without a default
std::cout << func() << std::endl;
^
test.cpp:17:23: error: overloaded function with no contextual type information
---------------------------------------------------------
Is this a known issue on macOS? Does function multi-versioning only work on
Linux or am I doing something wrong?
Best regards,
Kim
More information about the Gcc-help
mailing list