Why isn't gcc designed to use option boundary only for targets in target_clones attribute?

Mason slash.tmp@free.fr
Tue Dec 13 09:50:00 GMT 2016

On 13/12/2016 02:36, Mingye Wang (Arthur2e5) wrote:

> GCC 6's __attribute__((target_clones)) feature looks quite exciting to 
> me, but I cannot understand why it is designed to take, say, a single 
> string option like "sse2,avx2" and make it two separate 
> __attribute__((target)) clones. Using commas in single option strings 
> sounds like defeating the whole purpose of allowing multiple options; 
> furthermore, after some inspection on the source, it seems that all the 
> options will be smashed together with a comma and processed as a single 
> string.
> So take __attribute__((target_clones("sse3,tune=generic,default", 
> "arch=ivybridge"))) as an example.  Instead of creating two clones with 
> targets "sse3,tune=generic,default" and "arch=ivybridge" respectively, 
> GCC's target_clones would create three clones with their targets defined 
> as "sse3" "default", "tune=generic", and "arch=ivybridge".  This 
> behavior, although documented somehow, is confusing.
> Could anyone please tell me why GCC decided to go with such "smash the 
> string options together and split later" design?  Is it possible to have 
> GCC change this behavior in later releases, if it is indeed a design flaw?


Out of curiosity, I took a peak at the source code.
(1.6 GiB repo, clone requires 15 minutes on fast connection)
$ git clone git://gcc.gnu.org/git/gcc.git

AFAICT (?) the implementation is in gcc/multiple_target.c

Likely candidates are ab50af2a61a65 (initial) and
cb6c05f855c41 (update).


I've CCed the respective authors.


More information about the Gcc-help mailing list