Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Mon, 30 Jan 2023 17:37:26
Message-Id: 1675100223.f06cb39a5d25c754c01e96313f76dc802e361995.sam@gentoo
1 commit: f06cb39a5d25c754c01e96313f76dc802e361995
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 30 01:05:55 2023 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 30 17:37:03 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f06cb39a
7
8 toolchain-funcs.eclass: add tc-enables-fortify-source for FORTIFY_SOURCE
9
10 As Zero_Chaos reported on IRC, the check we had wasn't good enough in systemd*
11 (before we were able to remove it), as it wouldn't fire for e.g. -Os. While we
12 could've changed it to fail safe (always unset, then set a lower F_S if possible),
13 let's add a proper helper instead to the eclass.
14
15 Bug: https://bugs.gentoo.org/841770
16 Bug: https://bugs.gentoo.org/847148
17 Bug: https://bugs.gentoo.org/876893
18 Signed-off-by: Sam James <sam <AT> gentoo.org>
19
20 eclass/toolchain-funcs.eclass | 11 ++++++++++-
21 1 file changed, 10 insertions(+), 1 deletion(-)
22
23 diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
24 index bfcd6819ed0b..b9e956098b3e 100644
25 --- a/eclass/toolchain-funcs.eclass
26 +++ b/eclass/toolchain-funcs.eclass
27 @@ -1,4 +1,4 @@
28 -# Copyright 2002-2022 Gentoo Authors
29 +# Copyright 2002-2023 Gentoo Authors
30 # Distributed under the terms of the GNU General Public License v2
31
32 # @ECLASS: toolchain-funcs.eclass
33 @@ -1006,6 +1006,15 @@ tc-enables-pie() {
34 tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
35 }
36
37 +# @FUNCTION: tc-enables-fortify-source
38 +# @RETURN: Truth if the current compiler enables FORTIFY_SOURCE at any level
39 +# @DESCRIPTION:
40 +# Return truth if the current compiler enables fortification (FORTIFY_SOURCE)
41 +# at any level (-D_FORTIFY_SOURCE).
42 +tc-enables-fortify-source() {
43 + tc-cpp-is-true "defined(_FORTIFY_SOURCE)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
44 +}
45 +
46 # @FUNCTION: tc-enables-ssp
47 # @RETURN: Truth if the current compiler enables stack smashing protection (SSP) on at least minimal level
48 # @DESCRIPTION: