• [gentoo-dev] [PATCH 1/5] toolchain-funcs.eclass: add tc-enables-fortify

    From Sam James@21:1/5 to All on Mon Jan 30 02:50:01 2023
    As Zero_Chaos reported on IRC, the check we had wasn't good enough in systemd* (before we were able to remove it), as it wouldn't fire for e.g. -Os. While we could've changed it to fail safe (always unset, then set a lower F_S if possible),
    let's add a proper helper instead to the eclass.

    Bug: https://bugs.gentoo.org/841770
    Bug: https://bugs.gentoo.org/847148
    Bug: https://bugs.gentoo.org/876893
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/toolchain-funcs.eclass | 11 ++++++++++-
    1 file changed, 10 insertions(+), 1 deletion(-)

    diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index bfcd6819ed0b0..b9e956098b3e2 100644
    --- a/eclass/toolchain-funcs.eclass
    +++ b/eclass/toolchain-funcs.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 2002-2022 Gentoo Authors
    +# Copyright 2002-2023 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: toolchain-funcs.eclass
    @@ -1006,6 +1006,15 @@ tc-enables-pie() {
    tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
    }

    +# @FUNCTION: tc-enables-fortify-source
    +# @RETURN: Truth if the current compiler enables FORTIFY_SOURCE at any level +# @DESCRIPTION:
    +# Return truth if the current compiler enables fortification (FORTIFY_SOURCE) +# at any level (-D_FORTIFY_SOURCE).
    +tc-enables-fortify-source() {
    + tc-cpp-is-true "defined(_FORTIFY_SOURCE)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
    +}
    +
    # @FUNCTION: tc-enables-ssp
    # @RETURN:
  • From Sam James@21:1/5 to All on Mon Jan 30 02:50:01 2023
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/toolchain-funcs.eclass | 26 +++++++++++++-------------
    1 file changed, 13 insertions(+), 13 deletions(-)

    diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 840111f6cc30d..9bb660e4f71f3 100644
    --- a/eclass/toolchain-funcs.eclass
    +++ b/eclass/toolchain-funcs.eclass
    @@ -422,19 +422,19 @@ tc-env_build() {
    # src_configure() {
    # ECONF_SOURCE=${S}
    # if tc-is-cross-compiler ; then
    -# mkdir "${WORKDIR}"/${CBUILD}
    -# pushd "${WORKDIR}"/${CBUILD} >/dev/null
    +# mkdir "${WORKDIR}"/${CBUILD} || die
    +# pushd "${WORKDIR}"/${CBUILD} >/dev/null || die
    # econf_build --disable-some-unused-stuff
    -# popd >/dev/null
    +# popd >/dev/null || die
    # fi
    # ... normal build paths ...
    # }
    # src_compile() {
    # if tc-is-cross-compiler ; then
    -# pushd "${WORKDIR}"/${CBUILD} >/dev/null
    +# pushd "${WORKDIR}"/${CBUILD} >/dev/null || die
    # emake one-or-two-build-tools
    -# ln/mv build-tools to normal build paths in ${S}/
    -# popd >/dev/null
    +