commit: f06cb39a5d25c754c01e96313f76dc802e361995 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Mon Jan 30 01:05:55 2023 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Mon Jan 30 17:37:03 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f06cb39a
toolchain-funcs.eclass: add tc-enables-fortify-source for FORTIFY_SOURCE 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 <AT> 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 bfcd6819ed0b..b9e956098b3e 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: Truth if the current compiler enables stack smashing protection (SSP) on at least minimal level # @DESCRIPTION:
