sys-apps/kexec-tools: respect CFLAGS for purgatory
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Sun, 3 May 2020 19:00:08 +0000 (21:00 +0200)
committerThomas Deutschmann <whissi@gentoo.org>
Sun, 3 May 2020 19:01:11 +0000 (21:01 +0200)
Only when building purgatory, replace -mfunction-return=thunk and
-mindirect-branch=thunk flags with similar -mfunction-return=thunk-inline
and -mindirect-branch=thunk-inline flags, which are not incompatible
with flags added by build system.

Closes: https://bugs.gentoo.org/646536
Closes: https://bugs.gentoo.org/692930
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Package-Manager: Portage-2.3.99, Repoman-2.3.22
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
sys-apps/kexec-tools/kexec-tools-2.0.20-r1.ebuild
sys-apps/kexec-tools/kexec-tools-9999.ebuild

index 85f71ffaf47bb32eda541ad60347abdf0595e63b..3cfa2914c936d3836b8ede889efb72e1f1051178 100644 (file)
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-inherit flag-o-matic libtool linux-info systemd
+inherit libtool linux-info systemd
 
 if [[ ${PV} == "9999" ]] ; then
        inherit git-r3 autotools
@@ -46,12 +46,15 @@ pkg_setup() {
 
 src_prepare() {
        default
+
+       # Append PURGATORY_EXTRA_CFLAGS flags set by configure, instead of overriding them completely.
+       sed -e "/^PURGATORY_EXTRA_CFLAGS =/s/=/+=/" -i Makefile.in || die
+
        if [[ "${PV}" == 9999 ]] ; then
                eautoreconf
        else
                elibtoolize
        fi
-       filter-flags '-mindirect-branch=thunk*'
 }
 
 src_configure() {
@@ -64,6 +67,23 @@ src_configure() {
        econf "${myeconfargs[@]}"
 }
 
+src_compile() {
+       # Respect CFLAGS for purgatory.
+       # purgatory/Makefile uses PURGATORY_EXTRA_CFLAGS variable.
+       # -mfunction-return=thunk and -mindirect-branch=thunk conflict with
+       # -mcmodel=large which is added by build system.
+       # Replace them with -mfunction-return=thunk-inline and -mindirect-branch=thunk-inline.
+       local flag flags=()
+       for flag in ${CFLAGS}; do
+               [[ ${flag} == -mfunction-return=thunk ]] && flag="-mfunction-return=thunk-inline"
+               [[ ${flag} == -mindirect-branch=thunk ]] && flag="-mindirect-branch=thunk-inline"
+               flags+=("${flag}")
+       done
+       local -x PURGATORY_EXTRA_CFLAGS="${flags[*]}"
+
+       default
+}
+
 src_install() {
        default
 
index 99c3438156f5dcc1d254f253b5d78c5b922a2d49..77c5d7c6e590683ced60fc6e586d6862ce222ae2 100644 (file)
@@ -1,9 +1,9 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
 
-inherit flag-o-matic libtool linux-info systemd
+inherit libtool linux-info systemd
 
 if [[ ${PV} == "9999" ]] ; then
        inherit git-r3 autotools
@@ -11,7 +11,7 @@ if [[ ${PV} == "9999" ]] ; then
 else
        SRC_URI="https://www.kernel.org/pub/linux/utils/kernel/kexec/${P/_/-}.tar.xz"
        [[ "${PV}" == *_rc* ]] || \
-       KEYWORDS="~amd64 ~arm64 ~hppa ~ppc64 ~x86"
+       KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
 fi
 
 DESCRIPTION="Load another kernel from the currently executing Linux kernel"
@@ -44,12 +44,15 @@ pkg_setup() {
 
 src_prepare() {
        default
+
+       # Append PURGATORY_EXTRA_CFLAGS flags set by configure, instead of overriding them completely.
+       sed -e "/^PURGATORY_EXTRA_CFLAGS =/s/=/+=/" -i Makefile.in || die
+
        if [[ "${PV}" == 9999 ]] ; then
                eautoreconf
        else
                elibtoolize
        fi
-       filter-flags '-mindirect-branch=thunk*'
 }
 
 src_configure() {
@@ -62,6 +65,23 @@ src_configure() {
        econf "${myeconfargs[@]}"
 }
 
+src_compile() {
+       # Respect CFLAGS for purgatory.
+       # purgatory/Makefile uses PURGATORY_EXTRA_CFLAGS variable.
+       # -mfunction-return=thunk and -mindirect-branch=thunk conflict with
+       # -mcmodel=large which is added by build system.
+       # Replace them with -mfunction-return=thunk-inline and -mindirect-branch=thunk-inline.
+       local flag flags=()
+       for flag in ${CFLAGS}; do
+               [[ ${flag} == -mfunction-return=thunk ]] && flag="-mfunction-return=thunk-inline"
+               [[ ${flag} == -mindirect-branch=thunk ]] && flag="-mindirect-branch=thunk-inline"
+               flags+=("${flag}")
+       done
+       local -x PURGATORY_EXTRA_CFLAGS="${flags[*]}"
+
+       default
+}
+
 src_install() {
        default