On Wed, Oct 28, 2020 at 08:03:37PM -0000, GitLab Bridge on behalf of dzickusrh wrote:
From: Don Zickus <dzickus(a)redhat.com>
There are two parts to this fix. One is using the recommended way
to disable LTO. The other is to make it work for the kernel.spec
file.
Various kernel-tool programs (like perf) can not handle LTO yet, so
they are disabled.
This is done with '%define _lto_cflags {nil}'.
However that doesn't quite work for the kernel for the %install
section. It works for the %build section.
Oddly, back at the birth of dist-git, the initial kernel.spec
file was imported with a line at the top
%global __spec_install_pre %{___build_pre}
For whatever reason, the kernel was deemed special and that line
pre-built the %install scripts _before_ the lto_cflags could
dynamically be disabled.
Moving the _lto_cflags line above the _pre line disables LTO for both the
%build and %install sections of the spec file successfully.
However, because that _pre line is unintiutive and caused hours
of debugging headache, I hacked up the output to see what the
%__spec_install_pre and ___build_pre looked like at the
beginning of the %install section. The idea was __build_pre
is what we want going forward.
Unfortunately, after examining the results, I learned the %install
section expects a clean RPM_BUILD_ROOT. But the kernel %build
section puts each compiled variant into the RPM_BUILD_ROOT as
it completes. Thus is gets removed on %install setup. So the
%__spec_install_pre line has to stay.
Instead I add a bunch of comments explaining why it is necessary
and where to add changes like _lto_cflags. This hopefully
reduces headaches in the future.
V2: restore __spec_install_pre line and add comments.
Cc: Jeff Law <law(a)redhat.com>
Signed-off-by: Don Zickus <dzickus(a)redhat.com>
I like this version much better.
Acked-by: Brian Masney <bmasney(a)redhat.com>