This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCC function multi-versioning behaviour on Linux vs. macOS


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]