summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-05-06 07:04:53 +0000
committerMike Frysinger <vapier@gentoo.org>2015-05-06 07:04:53 +0000
commitedb81d1cd8dfa2702a96f6274894bf39a1042a45 (patch)
treecfebdb8d269790e4b405c8d4b357abcca41a229d /eclass
parentFix file collision, bug #547890; drop old (diff)
downloadhistorical-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.eclass19
-rwxr-xr-xeclass/tests/flag-o-matic.sh27
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