Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] flag-o-matic.eclass: Strip LDFLAGS unsupported by the C compiler, #621274
Date: Sat, 01 Jul 2017 16:23:11
Message-Id: 20170701162242.8939-1-mgorny@gentoo.org
1 Include LDFLAGS in the variables stripped by strip-unsupported-flags.
2 The code reuses the current functions for testing CC, and so only remove
3 LDFLAGS that are rejected by the C compiler and not the linker. This
4 solves the case of bug #621274 where LDFLAGS contained GCC-specific
5 -flto flag.
6 ---
7 eclass/flag-o-matic.eclass | 3 +++
8 eclass/tests/flag-o-matic.sh | 2 +-
9 2 files changed, 4 insertions(+), 1 deletion(-)
10
11 diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
12 index b2f3742b3ecf..4ef32c519f22 100644
13 --- a/eclass/flag-o-matic.eclass
14 +++ b/eclass/flag-o-matic.eclass
15 @@ -535,6 +535,9 @@ strip-unsupported-flags() {
16 export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
17 export FFLAGS=$(test-flags-F77 ${FFLAGS})
18 export FCFLAGS=$(test-flags-FC ${FCFLAGS})
19 + # note: this does not verify the linker flags but it is enough
20 + # to strip invalid C flags which are much more likely, #621274
21 + export LDFLAGS=$(test-flags-CC ${LDFLAGS})
22 }
23
24 # @FUNCTION: get-flag
25 diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
26 index 92c68b82c3c9..24f2a4c4af4e 100755
27 --- a/eclass/tests/flag-o-matic.sh
28 +++ b/eclass/tests/flag-o-matic.sh
29 @@ -55,7 +55,7 @@ done <<<"
30
31 tbegin "strip-unsupported-flags"
32 strip-unsupported-flags
33 -[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]]
34 +[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
35 ftend
36
37 for var in $(all-flag-vars) ; do
38 --
39 2.13.2

Replies