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 3/3] flag-o-matic.eclass: Strip LDFLAGS unsupported by the C compiler, #621274
Date: Fri, 11 Aug 2017 15:28:28
Message-Id: 20170811152642.24661-4-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH] flag-o-matic.eclass: LDFLAGS stripping, take two by "Michał Górny"
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 79866e04a483..4e3cfff5afd5 100644
13 --- a/eclass/flag-o-matic.eclass
14 +++ b/eclass/flag-o-matic.eclass
15 @@ -546,6 +546,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 5e7ee354bf33..53af9f862c41 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.14.0