title: g++ Optimization Flags: -fuse-linker-plugin vs -fwhole-program
body: <p>I am reading:<br>
  <a href="http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html" rel="nofollow noreferrer">http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html</a></p>
  
  <p>It first suggests:<br>
  In combination with <code>-flto</code> using this option (<code>-fwhole-program</code>) should not be used. Instead relying on a linker plugin should provide <strong>safer and more precise information.</strong></p>
  
  <p>And then, it suggests:<br>
  If the program does not require any symbols to be exported, it is possible to combine <code>-flto</code> and <code>-fwhole-program</code> to allow the interprocedural optimizers to use more aggressive assumptions which may lead to improved optimization opportunities. Use of <code>-fwhole-program</code> is not needed when linker plugin is active (see <code>-fuse-linker-plugin</code>).</p>
  
  <p>Does it mean that in theory, using <code>-fuse-linker-plugin</code> with <code>-flto</code> always gets a better optimized executable than using <code>-fwhole-program</code> with <code>-flto</code>?</p>
  
  <p>I tried to use <code>ld</code> to link with <code>-fuse-linker-plugin</code> and <code>-fwhole-program</code> separately, and the executables' sizes at least are different.</p>
  
  <p>P.S. I am using gcc 4.6.2, and ld 2.21.53.0.1 on CentOS 6.</p>