Opened 3 years ago

Closed 3 years ago

#13653 closed Patch - Feature (Duplicate)

Initial support for enabling the building of MythTV with LTO

Reported by: Gary Buhrmaster Owned by: Mark Kendall
Priority: minor Milestone: 32.0
Component: MythTV - General Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Initial support for enabling the building of MythTV with LTO.

LTO may be (or may not be, your experience will vary) beneficial to systems which are on the low end of performance.

While FFmpeg itself has support for LTO builds in the latest version(s) using the --enable-lto configure option, the MythTV build process did not support the necessary options and code requirements.

These patches are intended to get the compile to properly work if one wishes to test a LTO build, although I have been running a LTO build on my "production" system. It seems to operationally work for my use cases.

The patches are provided in smaller sections so that a developer can more easily review them.

The first set of four patches are to address the requirement for an LTO build to have consistent definitions of all names and structures for a compilation unit.  The next set of two patches (also required for the consistent definitions) remove the local videodev2.h include, as the original requirement was for an older kernel which is no longer supported by the project (2.6.something).  The last patch updates configure to properly pass along the necessary options to QMAKE and FFmpeg that can be set during configure.

Note: The resulting set has been compile tested on Fedora, EL, Debian and FreeBSD 11/12 using a standard configure to verify nothing breaks with these patches on those platforms.

For individual LTO testing purposes, and depending on whether your disto has changed the default ar/ranlib/nm commands to be the gcc enabled variants, you make need explicitly specify those in your configure, as in:

   make distclean
   ./configure --cc=gcc --cxx=g++ --enable-lto --ar=gcc-ar --ranlib=gcc-ranlib --nm="gcc-nm -g"
   make

or for the equivalent for clang of the form (alternative is to use gold rather than lld, but the gold linker seems to be mostly dead upstream, so we use the llvm linker):

   make distclean
   ./configure --cc=clang --cxx=clang --enable-lto --ar=llvm-ar --ranlib=llvm-ranlib --nm="llvm-nm -g" --extra-ldflags="-fuse-ld=lld"
   make

Note: lld creates 8 byte build-ids by default, and some post processing/debugging utilities were/are known to have challenges with those build-ids, so you may need to include -Wl,--build-id=sha1 in the extra-ldflags.

Note:  If you are using --extra-cflags, you may need to add --extra-ldflags (with equivalent flags) to avoid certain flag merging artifacts during the link stage compilation as the linker will use the flags in the first object files, which might not be ideal for your use case.

Patches will be attached.

Attachments (7)

0001-use-FFmpeg-definitions-of-av_malloc-and-av_free.patch (940 bytes) - added by Gary Buhrmaster 3 years ago.
use FFmpeg definitions of av_malloc and av_free
0002-Rename-the-RecordingType-stream-selection-UI-element.patch (1.5 KB) - added by Gary Buhrmaster 3 years ago.
Rename the RecordingType? stream selection UI element in recordingprofile.cpp - Renamed to avoid (global) name conflict with RecordingType? enum in libs/libmyth/recordingtypes.h
0003-Rename-the-ScanFrequency-starting-scan-frequency-UI-.patch (1.5 KB) - added by Gary Buhrmaster 3 years ago.
Rename the ScanFrequency? starting scan frequency UI element in videosource.cpp - Renamed to avoid (global) name conflict with ScanFrequency? class in libs/libmythtv/channelscan/channelscanmiscsettings.h
0004-remove-unneeded-definitions.patch (1.0 KB) - added by Gary Buhrmaster 3 years ago.
remove unneeded definitions - commit 50310355 removed the member variable that required the QMap, and the definition that the QMap required.
0005-use-system-videodev2.h-include-rather-than-a-local-s.patch (1.3 KB) - added by Gary Buhrmaster 3 years ago.
use system videodev2.h include rather than a local (sometimes different) copy - The project no longer supports distributions with the older kernels that required having a local copy of videodev2.h.
0006-remove-local-videodev2.h.patch (96.2 KB) - added by Gary Buhrmaster 3 years ago.
remove local videodev2.h
0007-update-config-to-pass-enable-lto-to-ffmpeg-and-expor.patch (1.6 KB) - added by Gary Buhrmaster 3 years ago.
update config to pass enable-lto to ffmpeg and export appropriate QMAKE vars

Download all attachments as: .zip

Change History (11)

Changed 3 years ago by Gary Buhrmaster

use FFmpeg definitions of av_malloc and av_free

Changed 3 years ago by Gary Buhrmaster

Rename the RecordingType? stream selection UI element in recordingprofile.cpp - Renamed to avoid (global) name conflict with RecordingType? enum in libs/libmyth/recordingtypes.h

Changed 3 years ago by Gary Buhrmaster

Rename the ScanFrequency? starting scan frequency UI element in videosource.cpp - Renamed to avoid (global) name conflict with ScanFrequency? class in libs/libmythtv/channelscan/channelscanmiscsettings.h

Changed 3 years ago by Gary Buhrmaster

remove unneeded definitions - commit 50310355 removed the member variable that required the QMap, and the definition that the QMap required.

Changed 3 years ago by Gary Buhrmaster

use system videodev2.h include rather than a local (sometimes different) copy - The project no longer supports distributions with the older kernels that required having a local copy of videodev2.h.

Changed 3 years ago by Gary Buhrmaster

remove local videodev2.h

Changed 3 years ago by Gary Buhrmaster

update config to pass enable-lto to ffmpeg and export appropriate QMAKE vars

comment:1 Changed 3 years ago by Mark Kendall

Milestone: needs_triage32.0
Owner: set to Mark Kendall
Status: newaccepted

comment:2 Changed 3 years ago by Gary Buhrmaster <gary.buhrmaster@…>

In ac1898c1d0/mythtv:

VideoVisualSpectrum?: Use FFmpeg definitions of av_malloc and av_free

Refs #13653

Signed-off-by: Mark Kendall <mark.kendall@…>

comment:3 Changed 3 years ago by Gary Buhrmaster <gary.buhrmaster@…>

In 4b3b92db97/mythtv:

V4LChannel: Remove unneeded definitions

Refs #13653

Signed-off-by: Mark Kendall <mark.kendall@…>

comment:4 Changed 3 years ago by Mark Kendall

Resolution: Duplicate
Status: acceptedclosed

Migrated to github issues for remaining patches: https://github.com/MythTV/mythtv/issues/224

Note: See TracTickets for help on using tickets.