Gentoo Archives: gentoo-dev

From: Sergei Trofimovich <slyfox@g.o>
To: Mike Gilbert <floppym@g.o>
Cc: gentoo-dev@l.g.o, toolchain@g.o
Subject: [gentoo-dev] Re: [PATCH] flag-o-matic.eclass: treat "--param x" as a unit when testing flags
Date: Fri, 13 Apr 2018 22:01:52
Message-Id: 20180413230139.1798ba1c@sf
In Reply to: [gentoo-dev] [PATCH] flag-o-matic.eclass: treat "--param x" as a unit when testing flags by Mike Gilbert
1 On Fri, 13 Apr 2018 12:21:47 -0400
2 Mike Gilbert <floppym@g.o> wrote:
3
4 > For clang and gcc, --param consumes the next argument. Testing --param
5 > and its value separately is nonsensical.
6 > ---
7 > eclass/flag-o-matic.eclass | 33 +++++++++++++++++++++++----------
8 > eclass/tests/flag-o-matic.sh | 4 ++--
9 > 2 files changed, 25 insertions(+), 12 deletions(-)
10 >
11 > diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
12 > index 14b84fbdbebe..5ab14b08d6ec 100644
13 > --- a/eclass/flag-o-matic.eclass
14 > +++ b/eclass/flag-o-matic.eclass
15 > @@ -421,9 +421,9 @@ strip-flags() {
16 > test-flag-PROG() {
17 > local comp=$1
18 > local lang=$2
19 > - local flag=$3
20 > + shift 2
21 >
22 > - [[ -z ${comp} || -z ${flag} ]] && return 1
23 > + [[ -z ${comp} || -z $1 ]] && return 1
24 >
25 > local cmdline=(
26 > $(tc-get${comp})
27 > @@ -434,11 +434,11 @@ test-flag-PROG() {
28 > -c -o /dev/null
29 > )
30 > if "${cmdline[@]}" -x${lang} - </dev/null &>/dev/null ; then
31 > - cmdline+=( "${flag}" -x${lang} - )
32 > + cmdline+=( "$@" -x${lang} - )
33 > else
34 > # XXX: what's the purpose of this? does it even work with
35 > # any compiler?
36 > - cmdline+=( "${flag}" -c -o /dev/null /dev/null )
37 > + cmdline+=( "$@" -c -o /dev/null /dev/null )
38 > fi
39 >
40 > if ! "${cmdline[@]}" </dev/null &>/dev/null; then
41 > @@ -455,25 +455,25 @@ test-flag-PROG() {
42 > # @USAGE: <flag>
43 > # @DESCRIPTION:
44 > # Returns shell true if <flag> is supported by the C compiler, else returns shell false.
45 > -test-flag-CC() { test-flag-PROG "CC" c "$1"; }
46 > +test-flag-CC() { test-flag-PROG "CC" c "$@"; }
47 >
48 > # @FUNCTION: test-flag-CXX
49 > # @USAGE: <flag>
50 > # @DESCRIPTION:
51 > # Returns shell true if <flag> is supported by the C++ compiler, else returns shell false.
52 > -test-flag-CXX() { test-flag-PROG "CXX" c++ "$1"; }
53 > +test-flag-CXX() { test-flag-PROG "CXX" c++ "$@"; }
54 >
55 > # @FUNCTION: test-flag-F77
56 > # @USAGE: <flag>
57 > # @DESCRIPTION:
58 > # Returns shell true if <flag> is supported by the Fortran 77 compiler, else returns shell false.
59 > -test-flag-F77() { test-flag-PROG "F77" f77 "$1"; }
60 > +test-flag-F77() { test-flag-PROG "F77" f77 "$@"; }
61 >
62 > # @FUNCTION: test-flag-FC
63 > # @USAGE: <flag>
64 > # @DESCRIPTION:
65 > # Returns shell true if <flag> is supported by the Fortran 90 compiler, else returns shell false.
66 > -test-flag-FC() { test-flag-PROG "FC" f95 "$1"; }
67 > +test-flag-FC() { test-flag-PROG "FC" f95 "$@"; }
68 >
69 > test-flags-PROG() {
70 > local comp=$1
71 > @@ -484,8 +484,21 @@ test-flags-PROG() {
72 >
73 > [[ -z ${comp} ]] && return 1
74 >
75 > - for x ; do
76 > - test-flag-${comp} "${x}" && flags+=( "${x}" )
77 > + while (( $# )); do
78 > + case "$1" in
79 > + --param)
80 > + if test-flag-${comp} "$1" "$2"; then
81 > + flags+=( "$1" "$2" )
82 > + fi
83 > + shift 2
84 > + ;;
85 > + *)
86 > + if test-flag-${comp} "$1"; then
87 > + flags+=( "$1" )
88 > + fi
89 > + shift 1
90 > + ;;
91 > + esac
92 > done
93 >
94 > echo "${flags[*]}"
95 > diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
96 > index 53af9f862c41..97cd71d710a2 100755
97 > --- a/eclass/tests/flag-o-matic.sh
98 > +++ b/eclass/tests/flag-o-matic.sh
99 > @@ -6,7 +6,7 @@ source tests-common.sh
100 >
101 > inherit flag-o-matic
102 >
103 > -CFLAGS="-a -b -c=1"
104 > +CFLAGS="-a -b -c=1 --param l1-cache-size=32"
105 > CXXFLAGS="-x -y -z=2"
106 > LDFLAGS="-l -m -n=3"
107 > ftend() {
108 > @@ -55,7 +55,7 @@ done <<<"
109 >
110 > tbegin "strip-unsupported-flags"
111 > strip-unsupported-flags
112 > -[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
113 > +[[ ${CFLAGS} == "--param l1-cache-size=32" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
114 > ftend
115 >
116 > for var in $(all-flag-vars) ; do
117 > --
118 > 2.17.0.rc2
119 >
120
121 Looks good. I personally use '--param=l1-cache-line-size=64' form :)
122
123 --
124
125 Sergei