title: Does GCC LTO perform cross-file dead code elimination?
body: <p>Say I have a function</p>
  
  <pre><code>void do_something() {
      //....
      #ifdef FEATURE_X
          feature_x();
      #endif
      //....
  }
  </code></pre>
  
  <p>I can compile and run this with no problems; if I want the feature I can pass <code>-D FEATURE_X</code> and it works.</p>
  
  <p>However, what if I would like to put <code>do_something</code> into another file (And not have to recompile that file as well each time I decide to change the option).  If it was in the same file, I assume that</p>
  
  <pre><code>const int FEATURE_X=0;
  
  void do_something() {
      //....
      if(FEATURE_X) {
          feature_x();
      }
      //....
  }
  </code></pre>
  
  <p>will use dead code elimination properly, eliminating the call.  If I put this in another file, without LTO,</p>
  
  <pre><code>extern const int FEATURE_X;
  
  void do_something() {
      //....
      if(FEATURE_X) {
          feature_x();
      }
      //....
  }
  </code></pre>
  
  <p>It will not remove the code (It has no way of knowing).  So, with link time optimization enabled, can the compiler detect the value of <code>FEATURE_X</code> at link time, determine if the code is used or not, and remove it if appropriate?</p>