diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-05-06 07:04:53 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-05-06 07:04:53 +0000 |
commit | edb81d1cd8dfa2702a96f6274894bf39a1042a45 (patch) | |
tree | cfebdb8d269790e4b405c8d4b357abcca41a229d /eclass | |
parent | Fix file collision, bug #547890; drop old (diff) | |
download | historical-edb81d1cd8dfa2702a96f6274894bf39a1042a45.tar.gz historical-edb81d1cd8dfa2702a96f6274894bf39a1042a45.tar.bz2 historical-edb81d1cd8dfa2702a96f6274894bf39a1042a45.zip |
make flag testing work for clang too crbug.com/474652
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/flag-o-matic.eclass | 19 | ||||
-rwxr-xr-x | eclass/tests/flag-o-matic.sh | 27 |
2 files changed, 39 insertions, 7 deletions
diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass index 5ede6bf8c50a..f5919cccf2bd 100644 --- a/eclass/flag-o-matic.eclass +++ b/eclass/flag-o-matic.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.204 2014/12/31 08:26:48 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.205 2015/05/06 07:04:53 vapier Exp $ # @ECLASS: flag-o-matic.eclass # @MAINTAINER: @@ -415,13 +415,18 @@ test-flag-PROG() { [[ -z ${comp} || -z ${flag} ]] && return 1 - # use -c so we can test the assembler as well - local PROG=$(tc-get${comp}) - if ${PROG} -c -o /dev/null -x${lang} - < /dev/null > /dev/null 2>&1 ; then - ${PROG} "${flag}" -c -o /dev/null -x${lang} - < /dev/null \ - > /dev/null 2>&1 + local cmdline=( + $(tc-get${comp}) + # Clang will warn about unknown gcc flags but exit 0. + # Need -Werror to force it to exit non-zero. + -Werror + # Use -c so we can test the assembler as well. + -c -o /dev/null + ) + if "${cmdline[@]}" -x${lang} - </dev/null >/dev/null 2>&1 ; then + "${cmdline[@]}" "${flag}" -x${lang} - </dev/null >/dev/null 2>&1 else - ${PROG} "${flag}" -c -o /dev/null /dev/null > /dev/null 2>&1 + "${cmdline[@]}" "${flag}" -c -o /dev/null /dev/null >/dev/null 2>&1 fi } diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh index 7fd0182260e3..5132c319f401 100755 --- a/eclass/tests/flag-o-matic.sh +++ b/eclass/tests/flag-o-matic.sh @@ -116,4 +116,31 @@ LDFLAGS=$(raw-ldflags) [[ ${LDFLAGS} == '-O1 --as-needed -z now' ]] ftend +tbegin "test-flags-CC (valid flags)" +out=$(test-flags-CC -O3) +[[ $? -eq 0 && ${out} == "-O3" ]] +ftend + +tbegin "test-flags-CC (invalid flags)" +out=$(test-flags-CC -finvalid-flag) +[[ $? -ne 0 && -z ${out} ]] +ftend + +if type -P clang >/dev/null ; then +tbegin "test-flags-CC (valid flags w/clang)" +out=$(CC=clang test-flags-CC -O3) +[[ $? -eq 0 && ${out} == "-O3" ]] +ftend + +tbegin "test-flags-CC (invalid flags w/clang)" +out=$(CC=clang test-flags-CC -finvalid-flag) +[[ $? -ne 0 && -z ${out} ]] +ftend + +tbegin "test-flags-CC (gcc-valid but clang-invalid flags)" +out=$(CC=clang test-flags-CC -finline-limit=1200) +[[ $? -ne 0 && -z ${out} ]] +ftend +fi + texit |