<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:mstahl@redhat.com" title="Michael Stahl <mstahl@redhat.com>"> <span class="fn">Michael Stahl</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - accelerating compile times by removing unnecessary header #include"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=42949">bug 42949</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>riccardo.magliocchetti@gmail.com
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Summary</td>
           <td>accelerating compile times ...
           </td>
           <td>accelerating compile times by removing unnecessary header #include
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - accelerating compile times by removing unnecessary header #include"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=42949#c15">Comment # 15</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - accelerating compile times by removing unnecessary header #include"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=42949">bug 42949</a>
              from <span class="vcard"><a class="email" href="mailto:mstahl@redhat.com" title="Michael Stahl <mstahl@redhat.com>"> <span class="fn">Michael Stahl</span></a>
</span></b>
        <pre>some issues that you should be aware of when doing cleanup:

1. we want each header file to be "complete" in the sense that it would build
successfully as a compilation unit on its own; it should not depend on some
other header being included before it into a source file to provide the types
it uses, it should either include a header that declares the needed type, or
contain a "forward declaration" of it.

2. removing an include from a source file because there is another include in
the source file that transitively brings in the needed include is also
undesirable: some time later somebody will refactor the code and reomve some
include that is no longer directly needed and then it turns out that there are
a lot of errors that need fixing because the source file was relying on
indirectly included files.

3. it's also too easy to remove platform dependent or configuration dependent
include this way; some of the code is behind some #ifdef. Ok, this is a more
general problem and you have to be aware of it whatever approach you use. best
to build with --enable-dbgutil to get all the debug code built.

include-what-you-use does indeed appear to be the best way to solve this
because it avoids issues 1 and 2.



how to build it on Fedora 20:

yum install llvm-static llvm-devel clang-devel
tar -xzvf /tmp/include-what-you-use-3.4.src.tar.gz
cd include-what-you-use/
[ edit the CMakeLists.txt and replace "link_directories(${LLVM_PATH}/lib)" with
"link_directories(${LLVM_PATH})" ]
cmake .
cmake  -DLLVM_PATH=/usr/lib/llvm-3.4 .
make

for LibreOffice use the --with-iwyu flag (see <a href="show_bug.cgi?id=42949#c14">comment #14</a>)



iwyu unfortunately only reports problems in the source file that is being
compiled, and in a header file with the same basename as the source file.
so i've added a "make iwyudummy" target that can be used to build all include
files: it will generate a iwyudummy/StaticLibrary_iwyudummy.mk that can be
edited to those include files you want to clean up.

i've already used iwyu to clean up all the headers that are shipped in the sdk
(i.e. listed in odk/Package_odk_headers.mk).

likely it would be a good approach to clean up include/ first in a bottom-up
way following the module dependency graph <a href="http://ostrovsky.org/libo/lo.png">http://ostrovsky.org/libo/lo.png</a>

oh and there is no need to clean up the precompiled_*.hxx headers manually,
since they are created automatically by some update_pch script anyway.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>