Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: eclass/
Date: Fri, 08 Jul 2016 11:17:40
Message-Id: 1467976639.bfd6b1346c60047b04563a61dd6cedec361e2d59.grobian@gentoo
1 commit: bfd6b1346c60047b04563a61dd6cedec361e2d59
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jul 8 11:17:19 2016 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 8 11:17:19 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=bfd6b134
7
8 eclass/toolchain-funcs: sync with gx86
9
10 eclass/toolchain-funcs.eclass | 124 +++++++++++++++++++++++++++++++++---------
11 1 file changed, 99 insertions(+), 25 deletions(-)
12
13 diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
14 index 4a5c5e1..b2eeb69 100644
15 --- a/eclass/toolchain-funcs.eclass
16 +++ b/eclass/toolchain-funcs.eclass
17 @@ -22,7 +22,7 @@ inherit multilib prefix
18 _tc-getPROG() {
19 local tuple=$1
20 local v var vars=$2
21 - local prog=$3
22 + local prog=( $3 )
23
24 var=${vars%% *}
25 for v in ${vars} ; do
26 @@ -34,11 +34,11 @@ _tc-getPROG() {
27 done
28
29 local search=
30 - [[ -n $4 ]] && search=$(type -p "$4-${prog}")
31 - [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}")
32 - [[ -n ${search} ]] && prog=${search##*/}
33 + [[ -n $4 ]] && search=$(type -p $4-${prog[0]})
34 + [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]})
35 + [[ -n ${search} ]] && prog[0]=${search##*/}
36
37 - export ${var}=${prog}
38 + export ${var}="${prog[*]}"
39 echo "${!var}"
40 }
41 tc-getBUILD_PROG() { _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"; }
42 @@ -59,7 +59,7 @@ tc-getCC() { tc-getPROG CC gcc "$@"; }
43 # @FUNCTION: tc-getCPP
44 # @USAGE: [toolchain prefix]
45 # @RETURN: name of the C preprocessor
46 -tc-getCPP() { tc-getPROG CPP cpp "$@"; }
47 +tc-getCPP() { tc-getPROG CPP "${CC:-gcc} -E" "$@"; }
48 # @FUNCTION: tc-getCXX
49 # @USAGE: [toolchain prefix]
50 # @RETURN: name of the C++ compiler
51 @@ -132,7 +132,7 @@ tc-getBUILD_CC() { tc-getBUILD_PROG CC gcc "$@"; }
52 # @FUNCTION: tc-getBUILD_CPP
53 # @USAGE: [toolchain prefix]
54 # @RETURN: name of the C preprocessor for building binaries to run on the build machine
55 -tc-getBUILD_CPP() { tc-getBUILD_PROG CPP cpp "$@"; }
56 +tc-getBUILD_CPP() { tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"; }
57 # @FUNCTION: tc-getBUILD_CXX
58 # @USAGE: [toolchain prefix]
59 # @RETURN: name of the C++ compiler for building binaries to run on the build machine
60 @@ -221,6 +221,21 @@ tc-is-static-only() {
61 [[ ${host} == *-mint* ]]
62 }
63
64 +# @FUNCTION: tc-stack-grows-down
65 +# @DESCRIPTION:
66 +# Return shell true if the stack grows down. This is the default behavior
67 +# for the vast majority of systems out there and usually projects shouldn't
68 +# care about such internal details.
69 +tc-stack-grows-down() {
70 + # List the few that grow up.
71 + case ${ARCH} in
72 + hppa|metag) return 1 ;;
73 + esac
74 +
75 + # Assume all others grow down.
76 + return 0
77 +}
78 +
79 # @FUNCTION: tc-export_build_env
80 # @USAGE: [compiler variables]
81 # @DESCRIPTION:
82 @@ -445,11 +460,6 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
83 local host=$2
84 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
85
86 - local KV=${KV:-${KV_FULL}}
87 - use kernel_linux &&
88 - [[ ${type} == "kern" ]] && [[ -z ${KV} ]] && \
89 - ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info"
90 -
91 case ${host} in
92 powerpc-apple-darwin*) echo ppc-macos;;
93 powerpc64-apple-darwin*) echo ppc64-macos;;
94 @@ -488,7 +498,7 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
95 # Starting with linux-2.6.24, the 'x86_64' and 'i386'
96 # trees have been unified into 'x86'.
97 # FreeBSD still uses i386
98 - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]] ; then
99 + if [[ ${type} == "kern" && ${host} == *freebsd* ]] ; then
100 echo i386
101 else
102 echo x86
103 @@ -506,18 +516,10 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
104 # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
105 # have been unified into simply 'powerpc', but until 2.6.16,
106 # ppc32 is still using ARCH="ppc" as default
107 - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then
108 + if [[ ${type} == "kern" ]] ; then
109 echo powerpc
110 - elif [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] ; then
111 - if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
112 - echo powerpc
113 - else
114 - echo ppc
115 - fi
116 elif [[ ${host} == powerpc64* ]] ; then
117 echo ppc64
118 - elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
119 - ninj ppc64 ppc
120 else
121 echo ppc
122 fi
123 @@ -538,10 +540,10 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
124 x86_64*)
125 # Starting with linux-2.6.24, the 'x86_64' and 'i386'
126 # trees have been unified into 'x86'.
127 - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then
128 + if [[ ${type} == "kern" ]] ; then
129 echo x86
130 else
131 - ninj x86_64 amd64
132 + echo amd64
133 fi
134 ;;
135 xtensa*) echo xtensa;;
136 @@ -594,12 +596,46 @@ tc-endian() {
137 esac
138 }
139
140 +# @FUNCTION: tc-get-compiler-type
141 +# @RETURN: keyword identifying the compiler: gcc, clang, pathcc, unknown
142 +tc-get-compiler-type() {
143 + local code='
144 +#if defined(__PATHSCALE__)
145 + HAVE_PATHCC
146 +#elif defined(__clang__)
147 + HAVE_CLANG
148 +#elif defined(__GNUC__)
149 + HAVE_GCC
150 +#endif
151 +'
152 + local res=$($(tc-getCPP "$@") -E -P - <<<"${code}")
153 +
154 + case ${res} in
155 + *HAVE_PATHCC*) echo pathcc;;
156 + *HAVE_CLANG*) echo clang;;
157 + *HAVE_GCC*) echo gcc;;
158 + *) echo unknown;;
159 + esac
160 +}
161 +
162 +# @FUNCTION: tc-is-gcc
163 +# @RETURN: Shell true if the current compiler is GCC, false otherwise.
164 +tc-is-gcc() {
165 + [[ $(tc-get-compiler-type) == gcc ]]
166 +}
167 +
168 +# @FUNCTION: tc-is-clang
169 +# @RETURN: Shell true if the current compiler is clang, false otherwise.
170 +tc-is-clang() {
171 + [[ $(tc-get-compiler-type) == clang ]]
172 +}
173 +
174 # Internal func. The first argument is the version info to expand.
175 # Query the preprocessor to improve compatibility across different
176 # compilers rather than maintaining a --version flag matrix. #335943
177 _gcc_fullversion() {
178 local ver="$1"; shift
179 - set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`
180 + set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__")
181 eval echo "$ver"
182 }
183
184 @@ -629,6 +665,39 @@ gcc-micro-version() {
185 _gcc_fullversion '$3' "$@"
186 }
187
188 +# Internal func. Based on _gcc_fullversion() above.
189 +_clang_fullversion() {
190 + local ver="$1"; shift
191 + set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__")
192 + eval echo "$ver"
193 +}
194 +
195 +# @FUNCTION: clang-fullversion
196 +# @RETURN: compiler version (major.minor.micro: [3.4.6])
197 +clang-fullversion() {
198 + _clang_fullversion '$1.$2.$3' "$@"
199 +}
200 +# @FUNCTION: clang-version
201 +# @RETURN: compiler version (major.minor: [3.4].6)
202 +clang-version() {
203 + _clang_fullversion '$1.$2' "$@"
204 +}
205 +# @FUNCTION: clang-major-version
206 +# @RETURN: major compiler version (major: [3].4.6)
207 +clang-major-version() {
208 + _clang_fullversion '$1' "$@"
209 +}
210 +# @FUNCTION: clang-minor-version
211 +# @RETURN: minor compiler version (minor: 3.[4].6)
212 +clang-minor-version() {
213 + _clang_fullversion '$2' "$@"
214 +}
215 +# @FUNCTION: clang-micro-version
216 +# @RETURN: micro compiler version (micro: 3.4.[6])
217 +clang-micro-version() {
218 + _clang_fullversion '$3' "$@"
219 +}
220 +
221 # Returns the installation directory - internal toolchain
222 # function for use by _gcc-specs-exists (for flag-o-matic).
223 _gcc-install-dir() {
224 @@ -754,6 +823,11 @@ gen_usr_ldscript() {
225 # we keep on using gen_usr_ldscript.
226 [[ -n ${PREFIX_DISABLE_GEN_USR_LDSCRIPT} ]] && return
227
228 + # We only care about stuffing / for the native ABI. #479448
229 + if [[ $(type -t multilib_is_native_abi) == "function" ]] ; then
230 + multilib_is_native_abi || return 0
231 + fi
232 +
233 # Eventually we'd like to get rid of this func completely #417451
234 case ${CTARGET:-${CHOST}} in
235 *-darwin*) type -P scanmacho > /dev/null || return ;; # excluded for now due to known breakage