flag-o-matic.eclass: Strip LDFLAGS unsupported by the C compiler, #621274
authorMichał Górny <mgorny@gentoo.org>
Sat, 1 Jul 2017 16:14:44 +0000 (18:14 +0200)
committerMichał Górny <mgorny@gentoo.org>
Fri, 25 Aug 2017 13:53:18 +0000 (15:53 +0200)
Include LDFLAGS in the variables stripped by strip-unsupported-flags.
The code reuses the current functions for testing CC, and so only remove
LDFLAGS that are rejected by the C compiler and not the linker. This
solves the case of bug #621274 where LDFLAGS contained GCC-specific
-flto flag.

eclass/flag-o-matic.eclass
eclass/tests/flag-o-matic.sh

index 79866e04a4837bfb121ce51ea6b9cb1e5ff35b08..4e3cfff5afd5b856cc7c1beeb1b9e9669bde581a 100644 (file)
@@ -546,6 +546,9 @@ strip-unsupported-flags() {
        export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
        export FFLAGS=$(test-flags-F77 ${FFLAGS})
        export FCFLAGS=$(test-flags-FC ${FCFLAGS})
+       # note: this does not verify the linker flags but it is enough
+       # to strip invalid C flags which are much more likely, #621274
+       export LDFLAGS=$(test-flags-CC ${LDFLAGS})
 }
 
 # @FUNCTION: get-flag
index 5e7ee354bf33dcc1242fdf9d218dc845d34e60d8..53af9f862c413169842ba8c25cb7e3e37f09b993 100755 (executable)
@@ -55,7 +55,7 @@ done <<<"
 
 tbegin "strip-unsupported-flags"
 strip-unsupported-flags
-[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]]
+[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
 ftend
 
 for var in $(all-flag-vars) ; do