From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 61A7E138334 for ; Tue, 30 Oct 2018 07:19:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5FCAFE084A; Tue, 30 Oct 2018 07:19:06 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E8BFAE0839 for ; Tue, 30 Oct 2018 07:19:04 +0000 (UTC) Received: from pomiot (d202-252.icpnet.pl [109.173.202.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 3ADF2335C36; Tue, 30 Oct 2018 07:19:02 +0000 (UTC) Message-ID: <1540883938.1250.6.camel@gentoo.org> Subject: Re: [gentoo-dev] [PATCH] fortran-2.eclass: support EAPI 7 From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Date: Tue, 30 Oct 2018 08:18:58 +0100 In-Reply-To: <20181029035705.59f926ed6e7e604baa84de0c@gentoo.org> References: <20181028013841.7bd52f2b363d0b11fbe97dd1@gentoo.org> <1540751368.7710.0.camel@gentoo.org> <20181029035705.59f926ed6e7e604baa84de0c@gentoo.org> Organization: Gentoo Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-1nM00Mc6UbPqPXrQljtH" X-Mailer: Evolution 3.26.6 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 X-Archives-Salt: 21828e5e-4a9f-44fc-a530-74a921a7ce76 X-Archives-Hash: d341fb527f572b2a65f6e7a3e7cd7f25 --=-1nM00Mc6UbPqPXrQljtH Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2018-10-29 at 03:57 +0300, Andrew Savchenko wrote: > On Sun, 28 Oct 2018 19:29:28 +0100 Micha=C5=82 G=C3=B3rny wrote: > > On Sun, 2018-10-28 at 01:38 +0300, Andrew Savchenko wrote: > > > Hi all! > > >=20 > > > The only blocker for EAPI 7 update is eutils inheritance, but it > > > seems to be not used within the current eclass code, probably a > > > remnant from older days. So it is removed. > > >=20 > > > Looks like no other EAPI 7 specific changes needed. > > >=20 > >=20 > > Please use -U99999 to include more context to the patches. I'm going to include a few 'easy cleanup' comments since EAPI 7 is a good opportunity to improve the eclass. I'm going to skip horribly bad design decisions since I suppose nobody cares. > diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass > index 820cbbcb49bd..1baf776e368a 100644 > --- a/eclass/fortran-2.eclass > +++ b/eclass/fortran-2.eclass > @@ -1,285 +1,285 @@ > -# Copyright 1999-2017 Gentoo Foundation > +# Copyright 1999-2018 Gentoo Authors > # Distributed under the terms of the GNU General Public License v2 > =20 > # @ECLASS: fortran-2.eclass > # @MAINTAINER: > # jlec@gentoo.org > # sci@gentoo.org > # @AUTHOR: > # Author Justin Lecher > # Test functions provided by Sebastien Fabbro and Kacper Kowalik > -# @SUPPORTED_EAPIS: 4 5 6 > +# @SUPPORTED_EAPIS: 4 5 6 7 > # @BLURB: Simplify fortran compiler management > # @DESCRIPTION: > # If you need a fortran compiler, then you should be inheriting this ecl= ass. > # In case you only need optional support, please export FORTRAN_NEEDED b= efore > # inheriting the eclass. > # > # The eclass tests for working fortran compilers > # and exports the variables FC and F77. > # Optionally, it checks for extended capabilities based on > # the variable options selected in the ebuild > # The only phase function exported is fortran-2_pkg_setup. > # @EXAMPLE: > # FORTRAN_NEEDED=3D"lapack fortran" > # > # inherit fortran-2 > # > # FORTRAN_NEED_OPENMP=3D1 > =20 > -inherit eutils toolchain-funcs > +inherit toolchain-funcs > =20 > case ${EAPI:-0} in > - 4|5|6) EXPORT_FUNCTIONS pkg_setup ;; > + 4|5|6|7) EXPORT_FUNCTIONS pkg_setup ;; > *) die "EAPI=3D${EAPI} is not supported" ;; > esac > =20 > if [[ ! ${_FORTRAN_2_CLASS} ]]; then > =20 > # @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP > # @DESCRIPTION: > # Set to "1" in order to automatically have the eclass abort if the fort= ran > # compiler lacks openmp support. > : ${FORTRAN_NEED_OPENMP:=3D0} > =20 > # @ECLASS-VARIABLE: FORTRAN_STANDARD > # @DESCRIPTION: > # Set this, if a special dialect needs to be supported. > # Generally not needed as default is sufficient. > # > # Valid settings are any combination of: 77 90 95 2003 > : ${FORTRAN_STANDARD:=3D77} > =20 > # @ECLASS-VARIABLE: FORTRAN_NEEDED > # @DESCRIPTION: > # If your package has an optional fortran support, set this variable > # to the space separated list of USE triggering the fortran > # dependency. > # > # e.g. FORTRAN_NEEDED=3Dlapack would result in > # > # DEPEND=3D"lapack? ( virtual/fortran )" > # > # If unset, we always depend on virtual/fortran. > : ${FORTRAN_NEEDED:=3Dalways} > =20 > for _f_use in ${FORTRAN_NEEDED}; do > case ${_f_use} in > always) > DEPEND+=3D" virtual/fortran" > RDEPEND+=3D" virtual/fortran" > break > ;; > no) > break > ;; > test) > DEPEND+=3D" ${_f_use}? ( virtual/fortran )" > ;; > *) > DEPEND+=3D" ${_f_use}? ( virtual/fortran )" > RDEPEND+=3D" ${_f_use}? ( virtual/fortran )" > ;; > esac > done > unset _f_use > =20 > # @FUNCTION: fortran_int64_abi_fflags > # @DESCRIPTION: > # Return the Fortran compiler flag to enable 64 bit integers for > # array indices > # @CODE > fortran_int64_abi_fflags() { > debug-print-function ${FUNCNAME} "${@}" > =20 > _FC=3D$(tc-getFC) Any reason not to make it local? > if [[ ${_FC} =3D=3D *gfortran* ]]; then > echo "-fdefault-integer-8" > elif [[ ${_FC} =3D=3D ifort ]]; then > echo "-integer-size 64" > else > die "Compiler flag for 64bit interger for ${_FC} unknown" > fi > } > =20 > # @FUNCTION: _fortran_write_testsuite > # @INTERNAL > # @DESCRIPTION: > # writes fortran test code > _fortran_write_testsuite() { > debug-print-function ${FUNCNAME} "${@}" > =20 > local filebase=3D${T}/test-fortran > =20 > # f77 code > cat <<- EOF > "${filebase}.f" || die > end > EOF > =20 > # f90/95 code > cat <<- EOF > "${filebase}.f90" || die > end Also, why different indentation? > EOF > =20 > # f2003 code > cat <<- EOF > "${filebase}.f03" || die > procedure(), pointer :: p > end > EOF > } > =20 > # @FUNCTION: _fortran_compile_test > # @USAGE: [dialect] > # @INTERNAL > # @DESCRIPTION: > # Takes fortran compiler as first argument and dialect as second. > # Checks whether the passed fortran compiler speaks the fortran dialect > _fortran_compile_test() { > debug-print-function ${FUNCNAME} "${@}" > =20 > local filebase=3D${T}/test-fortran > local fcomp=3D${1} > local fdia=3D${2} > local fcode=3D${filebase}.f${fdia} > local ret > =20 > [[ $# -lt 1 ]] && \ > die "_fortran_compile_test() needs at least one argument" > =20 > [[ -f ${fcode} ]] || _fortran_write_testsuite > =20 > ${fcomp} "${fcode}" -o "${fcode}.x" \ > >> "${T}"/_fortran_compile_test.log 2>&1 > ret=3D$? > =20 > rm -f "${fcode}.x" > return ${ret} > } > =20 > # @FUNCTION: _fortran-has-openmp > # @RETURN: return code of the compiler > # @INTERNAL > # @DESCRIPTION: > # See if the fortran supports OpenMP. > _fortran-has-openmp() { > debug-print-function ${FUNCNAME} "${@}" > =20 > local flag > local filebase=3D${T}/test-fc-openmp > local fcode=3D${filebase}.f > local ret > local _fc=3D$(tc-getFC) > =20 > cat <<- EOF > "${fcode}" || die > call omp_get_num_threads > end > EOF > =20 > for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=3Domp; do > ${_fc} ${flag} "${fcode}" -o "${fcode}.x" \ > &>> "${T}"/_fortran_compile_test.log > ret=3D$? > (( ${ret} )) || break This (( ... )) is unreadable at best; please replace it with clear condition. > done > =20 > rm -f "${fcode}.x" > return ${ret} > } > =20 > # @FUNCTION: _fortran_die_msg > # @INTERNAL > # @DESCRIPTION: > # Detailed description how to handle fortran support > _fortran_die_msg() { > debug-print-function ${FUNCNAME} "${@}" > =20 > echo Don't mix echo with eerror. > eerror "Please install currently selected gcc version with USE=3Dfortra= n." > eerror "If you intend to use a different compiler then gfortran, please= " > eerror "set FC variable accordingly and take care that the necessary" > eerror "fortran dialects are supported." > echo > die "Currently no working fortran compiler is available (see ${T}/_fort= ran_compile_test.log for information)" > } > =20 > # @FUNCTION: _fortran_test_function > # @INTERNAL > # @DESCRIPTION: > # Internal test function for working fortran compiler. > # It is called in fortran-2_pkg_setup. > _fortran_test_function() { > debug-print-function ${FUNCNAME} "${@}" > =20 > local dialect > =20 > : ${F77:=3D$(tc-getFC)} > =20 > : ${FORTRAN_STANDARD:=3D77} > for dialect in ${FORTRAN_STANDARD}; do > case ${dialect} in > 77) _fortran_compile_test $(tc-getF77) || \ > _fortran_die_msg ;; > 90|95) _fortran_compile_test $(tc-getFC) 90 || \ > _fortran_die_msg ;; > 2003) _fortran_compile_test $(tc-getFC) 03 || \ > _fortran_die_msg ;; > 2008) die "Future" ;; > *) die "${dialect} is not a Fortran dialect." ;; > esac > done > =20 > tc-export F77 FC > einfo "Using following Fortran compiler:" > einfo " F77: ${F77}" > einfo " FC: ${FC}" > =20 > if [[ ${FORTRAN_NEED_OPENMP} =3D=3D 1 ]]; then > if _fortran-has-openmp; then > einfo "${FC} has OPENMP support" > else > die "Please install current gcc with USE=3Dopenmp or set the FC varia= ble to a compiler that supports OpenMP" > fi > fi > } > =20 > # @FUNCTION: _fortran-2_pkg_setup > # @INTERNAL > # @DESCRIPTION: > # _The_ fortran-2_pkg_setup() code > _fortran-2_pkg_setup() { > for _f_use in ${FORTRAN_NEEDED}; do > case ${_f_use} in > always) > _fortran_test_function && break > ;; > no) > einfo "Forcing fortran support off" > break > ;; > *) > if use ${_f_use}; then > _fortran_test_function && break > else > unset FC > unset F77 > fi This contradicts the dependency atoms. If FORTRAN_NEEDED=3D"foo bar", you'll get: DEP=3D"foo? ( virtual/fortran ) bar? ( virtual/fortran )" However, with USE=3D"foo -bar" this will first set the compiler for USE=3Dfoo, then reset it for USE=3Dbar. > ;; > esac > done > } > =20 > =20 > # @FUNCTION: fortran-2_pkg_setup > # @DESCRIPTION: > # Setup functionality, > # checks for a valid fortran compiler and optionally for its openmp supp= ort. > fortran-2_pkg_setup() { > debug-print-function ${FUNCNAME} "${@}" > =20 > if [[ ${MERGE_TYPE} !=3D binary ]]; then > _fortran-2_pkg_setup > fi > } > =20 > _FORTRAN_2_ECLASS=3D1 > fi --=20 Best regards, Micha=C5=82 G=C3=B3rny --=-1nM00Mc6UbPqPXrQljtH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQKTBAABCgB9FiEEXr8g+Zb7PCLMb8pAur8dX/jIEQoFAlvYBeJfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDVF QkYyMEY5OTZGQjNDMjJDQzZGQ0E0MEJBQkYxRDVGRjhDODExMEEACgkQur8dX/jI EQqtORAAiZHHbiX+5xxNWWBDxzbQH5vi8g2w22qDz4wNtDzNL4bENDLk84kqcIHF hpGs4YCUxT6YRhiZyjffm1BcuRWDpJZsx2Jhsx+xqqFl9n5DrWyZHo78vMsN++Tl DONlCyikpUJt1sMQ7nybKLVFpaAUJMrgQn8+OYvCDcFASIVgWIc18ZKYSYPKIC4n H9K6p72B7ZqJZCIlh4hUwiG3FdJIwhuHu9jmyUV83bsE5jQD1rxmfYyRrv/3J2Tx ABwmBfELVp7wd9CV+2quEezYlHnIDwUQ6kcVnd2lAXJqXqP/gjSxcaAgKP35kUxe t/rWXwL9EkCkAVHzarAJYyMcp5BBczqtJRaQY4r/2yH4btjM3D7lw2GJisf/bj6z wvNTZZnIQvPgK7oMMORf7u1O5s53UQFPD1gunCD9ueQat1qdO4+Epait3siX2ALo p15mTbaG5ugkNakJVUkcZS07aTp7cfrFslVBsHzFPzRWguKVAbikG3piUryI8fpH dZl6X58bPpaLinwaSVg6wY4d/FO9C1JygvH+f9+Pr32vwNoSnmuQRF28y3amlDHJ PzU6nbihYYOXpF9+XzfSqDGydLNIAvQxhdUyWPQOIn1bv9AgoRSP9UWYFbHmGPLC vdfounigM78yvvSJI7rO9oY/ce4h8U+bvwPh82XQDX58SHSvMs8= =fnfK -----END PGP SIGNATURE----- --=-1nM00Mc6UbPqPXrQljtH--