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: