Function Multiversioning in GCC6

O Mahony, Billy billy.o.mahony@intel.com
Thu Mar 23 09:21:00 GMT 2017


Hi, 

I've just started playing with FMV in GCC6.

Ideally I was hoping that the 'target' attribute which works only for C++ in GCC4 would now work with C in GCC6.  I already have hand-crafted architecture specific versions of some C functions that I'd like to keep. Currently there is a manual selection/dispatch mechanism based on cupid and function pointers but  the ifunc mechanism system of __attribute__ target would be much better.

However when I compile the first example in this LWN article https://lwn.net/Articles/691932/ with gcc-6 C compiler it fails with (error: redefinition of 'foo'...) .

Can someone confirm if the target attrib works for with gcc-6 C compiler or is it just the new target_clones attrib that works with the C compiler? If it should work, is there a secret sauce (gcc cli option or whatever) required - the gcc6 manual doesn't say much and the FMV wiki has not been updated since 4.x.

Alternatively is there a way to use target_clones but with specific implementations for each architecture? 

Thanks for any help!
Billy.



More information about the Gcc-help mailing list