1 |
On Mon, 2018-10-29 at 03:57 +0300, Andrew Savchenko wrote: |
2 |
> On Sun, 28 Oct 2018 19:29:28 +0100 Michał Górny wrote: |
3 |
> > On Sun, 2018-10-28 at 01:38 +0300, Andrew Savchenko wrote: |
4 |
> > > Hi all! |
5 |
> > > |
6 |
> > > The only blocker for EAPI 7 update is eutils inheritance, but it |
7 |
> > > seems to be not used within the current eclass code, probably a |
8 |
> > > remnant from older days. So it is removed. |
9 |
> > > |
10 |
> > > Looks like no other EAPI 7 specific changes needed. |
11 |
> > > |
12 |
> > |
13 |
> > Please use -U99999 to include more context to the patches. |
14 |
|
15 |
I'm going to include a few 'easy cleanup' comments since EAPI 7 |
16 |
is a good opportunity to improve the eclass. I'm going to skip horribly |
17 |
bad design decisions since I suppose nobody cares. |
18 |
|
19 |
> diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass |
20 |
> index 820cbbcb49bd..1baf776e368a 100644 |
21 |
> --- a/eclass/fortran-2.eclass |
22 |
> +++ b/eclass/fortran-2.eclass |
23 |
> @@ -1,285 +1,285 @@ |
24 |
> -# Copyright 1999-2017 Gentoo Foundation |
25 |
> +# Copyright 1999-2018 Gentoo Authors |
26 |
> # Distributed under the terms of the GNU General Public License v2 |
27 |
> |
28 |
> # @ECLASS: fortran-2.eclass |
29 |
> # @MAINTAINER: |
30 |
> # jlec@g.o |
31 |
> # sci@g.o |
32 |
> # @AUTHOR: |
33 |
> # Author Justin Lecher <jlec@g.o> |
34 |
> # Test functions provided by Sebastien Fabbro and Kacper Kowalik |
35 |
> -# @SUPPORTED_EAPIS: 4 5 6 |
36 |
> +# @SUPPORTED_EAPIS: 4 5 6 7 |
37 |
> # @BLURB: Simplify fortran compiler management |
38 |
> # @DESCRIPTION: |
39 |
> # If you need a fortran compiler, then you should be inheriting this eclass. |
40 |
> # In case you only need optional support, please export FORTRAN_NEEDED before |
41 |
> # inheriting the eclass. |
42 |
> # |
43 |
> # The eclass tests for working fortran compilers |
44 |
> # and exports the variables FC and F77. |
45 |
> # Optionally, it checks for extended capabilities based on |
46 |
> # the variable options selected in the ebuild |
47 |
> # The only phase function exported is fortran-2_pkg_setup. |
48 |
> # @EXAMPLE: |
49 |
> # FORTRAN_NEEDED="lapack fortran" |
50 |
> # |
51 |
> # inherit fortran-2 |
52 |
> # |
53 |
> # FORTRAN_NEED_OPENMP=1 |
54 |
> |
55 |
> -inherit eutils toolchain-funcs |
56 |
> +inherit toolchain-funcs |
57 |
> |
58 |
> case ${EAPI:-0} in |
59 |
> - 4|5|6) EXPORT_FUNCTIONS pkg_setup ;; |
60 |
> + 4|5|6|7) EXPORT_FUNCTIONS pkg_setup ;; |
61 |
> *) die "EAPI=${EAPI} is not supported" ;; |
62 |
> esac |
63 |
> |
64 |
> if [[ ! ${_FORTRAN_2_CLASS} ]]; then |
65 |
> |
66 |
> # @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP |
67 |
> # @DESCRIPTION: |
68 |
> # Set to "1" in order to automatically have the eclass abort if the fortran |
69 |
> # compiler lacks openmp support. |
70 |
> : ${FORTRAN_NEED_OPENMP:=0} |
71 |
> |
72 |
> # @ECLASS-VARIABLE: FORTRAN_STANDARD |
73 |
> # @DESCRIPTION: |
74 |
> # Set this, if a special dialect needs to be supported. |
75 |
> # Generally not needed as default is sufficient. |
76 |
> # |
77 |
> # Valid settings are any combination of: 77 90 95 2003 |
78 |
> : ${FORTRAN_STANDARD:=77} |
79 |
> |
80 |
> # @ECLASS-VARIABLE: FORTRAN_NEEDED |
81 |
> # @DESCRIPTION: |
82 |
> # If your package has an optional fortran support, set this variable |
83 |
> # to the space separated list of USE triggering the fortran |
84 |
> # dependency. |
85 |
> # |
86 |
> # e.g. FORTRAN_NEEDED=lapack would result in |
87 |
> # |
88 |
> # DEPEND="lapack? ( virtual/fortran )" |
89 |
> # |
90 |
> # If unset, we always depend on virtual/fortran. |
91 |
> : ${FORTRAN_NEEDED:=always} |
92 |
> |
93 |
> for _f_use in ${FORTRAN_NEEDED}; do |
94 |
> case ${_f_use} in |
95 |
> always) |
96 |
> DEPEND+=" virtual/fortran" |
97 |
> RDEPEND+=" virtual/fortran" |
98 |
> break |
99 |
> ;; |
100 |
> no) |
101 |
> break |
102 |
> ;; |
103 |
> test) |
104 |
> DEPEND+=" ${_f_use}? ( virtual/fortran )" |
105 |
> ;; |
106 |
> *) |
107 |
> DEPEND+=" ${_f_use}? ( virtual/fortran )" |
108 |
> RDEPEND+=" ${_f_use}? ( virtual/fortran )" |
109 |
> ;; |
110 |
> esac |
111 |
> done |
112 |
> unset _f_use |
113 |
> |
114 |
> # @FUNCTION: fortran_int64_abi_fflags |
115 |
> # @DESCRIPTION: |
116 |
> # Return the Fortran compiler flag to enable 64 bit integers for |
117 |
> # array indices |
118 |
> # @CODE |
119 |
> fortran_int64_abi_fflags() { |
120 |
> debug-print-function ${FUNCNAME} "${@}" |
121 |
> |
122 |
> _FC=$(tc-getFC) |
123 |
|
124 |
Any reason not to make it local? |
125 |
|
126 |
> if [[ ${_FC} == *gfortran* ]]; then |
127 |
> echo "-fdefault-integer-8" |
128 |
> elif [[ ${_FC} == ifort ]]; then |
129 |
> echo "-integer-size 64" |
130 |
> else |
131 |
> die "Compiler flag for 64bit interger for ${_FC} unknown" |
132 |
> fi |
133 |
> } |
134 |
> |
135 |
> # @FUNCTION: _fortran_write_testsuite |
136 |
> # @INTERNAL |
137 |
> # @DESCRIPTION: |
138 |
> # writes fortran test code |
139 |
> _fortran_write_testsuite() { |
140 |
> debug-print-function ${FUNCNAME} "${@}" |
141 |
> |
142 |
> local filebase=${T}/test-fortran |
143 |
> |
144 |
> # f77 code |
145 |
> cat <<- EOF > "${filebase}.f" |
146 |
|
147 |
|| die |
148 |
|
149 |
> end |
150 |
> EOF |
151 |
> |
152 |
> # f90/95 code |
153 |
> cat <<- EOF > "${filebase}.f90" |
154 |
|
155 |
|| die |
156 |
|
157 |
> end |
158 |
|
159 |
Also, why different indentation? |
160 |
|
161 |
> EOF |
162 |
> |
163 |
> # f2003 code |
164 |
> cat <<- EOF > "${filebase}.f03" |
165 |
|
166 |
|| die |
167 |
|
168 |
> procedure(), pointer :: p |
169 |
> end |
170 |
> EOF |
171 |
> } |
172 |
> |
173 |
> # @FUNCTION: _fortran_compile_test |
174 |
> # @USAGE: <compiler> [dialect] |
175 |
> # @INTERNAL |
176 |
> # @DESCRIPTION: |
177 |
> # Takes fortran compiler as first argument and dialect as second. |
178 |
> # Checks whether the passed fortran compiler speaks the fortran dialect |
179 |
> _fortran_compile_test() { |
180 |
> debug-print-function ${FUNCNAME} "${@}" |
181 |
> |
182 |
> local filebase=${T}/test-fortran |
183 |
> local fcomp=${1} |
184 |
> local fdia=${2} |
185 |
> local fcode=${filebase}.f${fdia} |
186 |
> local ret |
187 |
> |
188 |
> [[ $# -lt 1 ]] && \ |
189 |
> die "_fortran_compile_test() needs at least one argument" |
190 |
> |
191 |
> [[ -f ${fcode} ]] || _fortran_write_testsuite |
192 |
> |
193 |
> ${fcomp} "${fcode}" -o "${fcode}.x" \ |
194 |
> >> "${T}"/_fortran_compile_test.log 2>&1 |
195 |
> ret=$? |
196 |
> |
197 |
> rm -f "${fcode}.x" |
198 |
> return ${ret} |
199 |
> } |
200 |
> |
201 |
> # @FUNCTION: _fortran-has-openmp |
202 |
> # @RETURN: return code of the compiler |
203 |
> # @INTERNAL |
204 |
> # @DESCRIPTION: |
205 |
> # See if the fortran supports OpenMP. |
206 |
> _fortran-has-openmp() { |
207 |
> debug-print-function ${FUNCNAME} "${@}" |
208 |
> |
209 |
> local flag |
210 |
> local filebase=${T}/test-fc-openmp |
211 |
> local fcode=${filebase}.f |
212 |
> local ret |
213 |
> local _fc=$(tc-getFC) |
214 |
> |
215 |
> cat <<- EOF > "${fcode}" |
216 |
|
217 |
|| die |
218 |
|
219 |
> call omp_get_num_threads |
220 |
> end |
221 |
> EOF |
222 |
> |
223 |
> for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do |
224 |
> ${_fc} ${flag} "${fcode}" -o "${fcode}.x" \ |
225 |
> &>> "${T}"/_fortran_compile_test.log |
226 |
> ret=$? |
227 |
> (( ${ret} )) || break |
228 |
|
229 |
This (( ... )) is unreadable at best; please replace it with clear |
230 |
condition. |
231 |
|
232 |
> done |
233 |
> |
234 |
> rm -f "${fcode}.x" |
235 |
> return ${ret} |
236 |
> } |
237 |
> |
238 |
> # @FUNCTION: _fortran_die_msg |
239 |
> # @INTERNAL |
240 |
> # @DESCRIPTION: |
241 |
> # Detailed description how to handle fortran support |
242 |
> _fortran_die_msg() { |
243 |
> debug-print-function ${FUNCNAME} "${@}" |
244 |
> |
245 |
> echo |
246 |
|
247 |
Don't mix echo with eerror. |
248 |
|
249 |
> eerror "Please install currently selected gcc version with USE=fortran." |
250 |
> eerror "If you intend to use a different compiler then gfortran, please" |
251 |
> eerror "set FC variable accordingly and take care that the necessary" |
252 |
> eerror "fortran dialects are supported." |
253 |
> echo |
254 |
> die "Currently no working fortran compiler is available (see ${T}/_fortran_compile_test.log for information)" |
255 |
> } |
256 |
> |
257 |
> # @FUNCTION: _fortran_test_function |
258 |
> # @INTERNAL |
259 |
> # @DESCRIPTION: |
260 |
> # Internal test function for working fortran compiler. |
261 |
> # It is called in fortran-2_pkg_setup. |
262 |
> _fortran_test_function() { |
263 |
> debug-print-function ${FUNCNAME} "${@}" |
264 |
> |
265 |
> local dialect |
266 |
> |
267 |
> : ${F77:=$(tc-getFC)} |
268 |
> |
269 |
> : ${FORTRAN_STANDARD:=77} |
270 |
> for dialect in ${FORTRAN_STANDARD}; do |
271 |
> case ${dialect} in |
272 |
> 77) _fortran_compile_test $(tc-getF77) || \ |
273 |
> _fortran_die_msg ;; |
274 |
> 90|95) _fortran_compile_test $(tc-getFC) 90 || \ |
275 |
> _fortran_die_msg ;; |
276 |
> 2003) _fortran_compile_test $(tc-getFC) 03 || \ |
277 |
> _fortran_die_msg ;; |
278 |
> 2008) die "Future" ;; |
279 |
> *) die "${dialect} is not a Fortran dialect." ;; |
280 |
> esac |
281 |
> done |
282 |
> |
283 |
> tc-export F77 FC |
284 |
> einfo "Using following Fortran compiler:" |
285 |
> einfo " F77: ${F77}" |
286 |
> einfo " FC: ${FC}" |
287 |
> |
288 |
> if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then |
289 |
> if _fortran-has-openmp; then |
290 |
> einfo "${FC} has OPENMP support" |
291 |
> else |
292 |
> die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP" |
293 |
> fi |
294 |
> fi |
295 |
> } |
296 |
> |
297 |
> # @FUNCTION: _fortran-2_pkg_setup |
298 |
> # @INTERNAL |
299 |
> # @DESCRIPTION: |
300 |
> # _The_ fortran-2_pkg_setup() code |
301 |
> _fortran-2_pkg_setup() { |
302 |
> for _f_use in ${FORTRAN_NEEDED}; do |
303 |
> case ${_f_use} in |
304 |
> always) |
305 |
> _fortran_test_function && break |
306 |
> ;; |
307 |
> no) |
308 |
> einfo "Forcing fortran support off" |
309 |
> break |
310 |
> ;; |
311 |
> *) |
312 |
> if use ${_f_use}; then |
313 |
> _fortran_test_function && break |
314 |
> else |
315 |
> unset FC |
316 |
> unset F77 |
317 |
> fi |
318 |
|
319 |
This contradicts the dependency atoms. |
320 |
|
321 |
If FORTRAN_NEEDED="foo bar", you'll get: |
322 |
|
323 |
DEP="foo? ( virtual/fortran ) bar? ( virtual/fortran )" |
324 |
|
325 |
However, with USE="foo -bar" this will first set the compiler |
326 |
for USE=foo, then reset it for USE=bar. |
327 |
|
328 |
> ;; |
329 |
> esac |
330 |
> done |
331 |
> } |
332 |
> |
333 |
> |
334 |
> # @FUNCTION: fortran-2_pkg_setup |
335 |
> # @DESCRIPTION: |
336 |
> # Setup functionality, |
337 |
> # checks for a valid fortran compiler and optionally for its openmp support. |
338 |
> fortran-2_pkg_setup() { |
339 |
> debug-print-function ${FUNCNAME} "${@}" |
340 |
> |
341 |
> if [[ ${MERGE_TYPE} != binary ]]; then |
342 |
> _fortran-2_pkg_setup |
343 |
> fi |
344 |
> } |
345 |
> |
346 |
> _FORTRAN_2_ECLASS=1 |
347 |
> fi |
348 |
|
349 |
-- |
350 |
Best regards, |
351 |
Michał Górny |