Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ulmus-scott
Copy link
Contributor

This improves compiler analysis since the entire class definition
is in one compilation unit and decreases compile and link times
due to fewer object files being linked together. In addition,
for CMake this greatly speeds up incremental compilation since
this avoids the use of mocs_compilation.cpp where every moc_*.cpp
file was included.

I first had to fix header guards and hide the troublesome X11 headers. This includes #1151 since that moved some of the X11 including headers.

With ccache, this was 1-2% faster. With ccache cleared, qmake was about 10% faster.

Checklist

@ulmus-scott
Copy link
Contributor Author

@linuxdude42 I couldn't figure out how to ignore https://clang.llvm.org/extra/clang-tidy/checks/bugprone/suspicious-include.html for the moc_.+\.cpp includes.

Is there a way to run clang-tidy and cppcheck via CMake without first building the rest of the project?

Also, clang-tidy generates a lot of noise in libmythdvdnav.

@ulmus-scott
Copy link
Contributor Author

The IgnoredRegex option is not in the version 21 releases, so I can't test it, but I think this would work:


diff --git a/.clang-tidy b/.clang-tidy
index c155412517..e19ccd730c 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -290,6 +290,7 @@ Checks: '-*,
 
 CheckOptions:
   - { key: bugprone-narrowing-conversions.PedanticMode, value: 0 }
+  - { key: bugprone-suspicious-include.IgnoredRegex, value: '^(.*/)?(moc_.+)(\.cpp)$' }
   - { key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1 }
   - { key: bugprone-pointer-arithmetic-on-polymorphic-object.IgnoreInheritedVirtualFunctions, value: 1 }
   - { key: bugprone-unused-return-value.AllowCastToVoid, value: 1 }

and move MythNVControl into mythnvcontrol.cpp,
hiding the X11 includes from the header file.
and make LOG message selection easier to read.
This improves compiler analysis since the entire class definition
is in one compilation unit and decreases compile and link times
due to fewer object files being linked together.  In addition,
for CMake this greatly speeds up incremental compilation since
this avoids the use of mocs_compilation.cpp where every moc_*.cpp
file was included.

Build times with a cleared ccache (no LTO):
                Build   Test    Build plugins
qmake (before): 219.458 39.463  22.682
qmake (after) : 202.001 37.023  17.981
CMake (before): 246.225 24.18   n/a
CMake (after) : 241.419 24.122  n/a

Build times after git clean -xdf (filled ccache) (no LTO):
                Build   Test    Build plugins
qmake (before): 21.777  27.249  1.334
qmake (after) : 21.411  26.920  1.248
CMake (before): 54.205  24.08   n/a
CMake (after) : 53.860  24.148  n/a

A full rebuild with qmake is about 10% faster.
A full rebuild with CMake is about 2% faster.

After git clean -xdf, this is about 1-2% faster.

libmythprotoserver/socketrequesthandler.h is header only,
so mythsocketmanager.cpp is as good a place as any since
it already uses SocketRequestHandler.

mythfrontend/settingshelper.h and most of the files in
mythfrontend/servicecontracts/ and mythbackend/servicesv2/
are header only, so there is no good place to include each
moc_*.cpp file.  A few files in mythcommflag,
mythtv-setup/expertsettingseditor.h,
libmythbase/mythsystemprivate.h, libmythtv/channelscan/paneatsc.h,
and libmythtv/channelscan/panedvbutilsimport.h are also header only.

I used the script from
https://raymii.org/s/blog/Qt_add_moc_includes_to_speed_up_compilation.html
and manually touched it up.  The script does not account
for Q_OBJECT in a .cpp file.

Some further discussion of this, with some other scripts linked, is here:
https://planet.kde.org/friedrich-kossebau-2023-06-28-include-also-moc-files-of-headers/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant