Gentoo Archives: gentoo-dev

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

Replies