https://bugs.freedesktop.org/show_bug.cgi?id=42949
Michael Stahl <mstahl@redhat.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |riccardo.magliocchetti@gmai
| |l.com
Summary|accelerating compile times |accelerating compile times
|... |by removing unnecessary
| |header #include
--- Comment #15 from Michael Stahl <mstahl@redhat.com> ---
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 comment #14)
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 http://ostrovsky.org/libo/lo.png
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
Context
- [Bug 42949] accelerating compile times by removing unnecessary header #include · bugzilla-daemon
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.