This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
GCC function multi-versioning behaviour on Linux vs. macOS
- From: Kim Walisch <kim dot walisch at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 27 Feb 2017 14:22:07 +0100
- Subject: GCC function multi-versioning behaviour on Linux vs. macOS
- Authentication-results: sourceware.org; auth=none
- Reply-to: kim dot walisch at gmail dot com
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