• [gentoo-dev] [PATCH 1/2] flag-o-matic.eclass: have is-flagq respect suc

    From Sam James@21:1/5 to All on Mon Jun 27 09:10:02 2022
    From: Jannik Glückert <jannik.glueckert@gmail.com>

    Handle bits like -flto -fno-lto.

    Signed-off-by: Jannik Glückert <jannik.glueckert@gmail.com>
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/flag-o-matic.eclass | 20 +++++++++++++++-----
    1 file changed, 15 insertions(+), 5 deletions(-)

    diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
    index 50caa401bacfb..eca39cd2bdfdc 100644
    --- a/eclass/flag-o-matic.eclass
    +++ b/eclass/flag-o-matic.eclass
    @@ -372,19 +372,29 @@ replace-cpu-flags() {
    # @USAGE: <variable> <flag>
    # @INTERNAL
    # @DESCRIPTION:
    -# Returns shell true if <flag> is in a given <variable>, else returns shell false.
    +# Returns shell true if <flag> is in a given <variable> and not surpassed by e.g. -fno-<flag>,
    +# else returns shell false.
    _is_flagq() {
    - local x var="$1[*]"
    + local x var="$1[*]" equal_str equal_pos flag_no ret=1
    + equal_str=${2%%=*}
    + equal_pos=${#equal_str}
    + # This results in -fno-flag for -fflag=*
    + flag_no=${2::2}no-${equal_str:2}
    +
    for x in ${!var} ; do
    - [[ ${x} == $2 ]] && return 0
    + case ${x} in
    + $2) ret=0 ;;
    + ${flag_no}) ret=1 ;;
    + esac
    done
    - return 1
    + return ${ret}
    }

    # @FUNCTION
  • From Sam James@21:1/5 to All on Mon Jun 27 09:10:01 2022
    From: Jannik Glückert <jannik.glueckert@gmail.com>

    Signed-off-by: Jannik Glückert <jannik.glueckert@gmail.com>
    Closes: https://github.com/gentoo/gentoo/pull/26036
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/flag-o-matic.eclass | 8 ++++++++
    1 file changed, 8 insertions(+)

    diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
    index eca39cd2bdfdc..9624af93c963e 100644
    --- a/eclass/flag-o-matic.eclass
    +++ b/eclass/flag-o-matic.eclass
    @@ -218,6 +218,14 @@ filter-lfs-flags() {
    filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_TIME_BITS=64
    }

    +# @FUNCTION: filter-lto
    +# @DESCRIPTION:
    +# Remove flags that enable LTO and those that depend on it
    +filter-lto() {
    + [[ $# -ne 0 ]] && die "filter-lto takes no arguments"
    + filter-flags '-flto*' -fwhole-program-vtables '-fsanitize=cfi*'
    +}
    +
    # @FUNCTION: filter-ldflags
    # @USAGE: <flags>
    # @DESCRIPTION:
    --
    2.36.1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)