From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id B43DD1381F3 for ; Mon, 26 Nov 2012 22:04:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2BAE3E06BF; Mon, 26 Nov 2012 22:02:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4CDA4E06C0 for ; Mon, 26 Nov 2012 22:02:06 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 312FB33D8F2 for ; Mon, 26 Nov 2012 22:02:05 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 50D37E544B for ; Mon, 26 Nov 2012 22:02:02 +0000 (UTC) From: "Justin Lecher" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Justin Lecher" Message-ID: <1353940869.379f326a5bf8e98a08e6796cb57a02b683be151c.jlec@gentoo> Subject: [gentoo-commits] proj/sci:master commit in: eclass/ X-VCS-Repository: proj/sci X-VCS-Files: eclass/cuda.eclass X-VCS-Directories: eclass/ X-VCS-Committer: jlec X-VCS-Committer-Name: Justin Lecher X-VCS-Revision: 379f326a5bf8e98a08e6796cb57a02b683be151c X-VCS-Branch: master Date: Mon, 26 Nov 2012 22:02:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 274f9a3f-86cf-4601-87bd-8d1bb201b834 X-Archives-Hash: bc17058584bcbf28c2413b59db90f06f commit: 379f326a5bf8e98a08e6796cb57a02b683be151c Author: Justin Lecher gentoo org> AuthorDate: Fri Nov 16 15:48:47 2012 +0000 Commit: Justin Lecher gentoo org> CommitDate: Mon Nov 26 14:41:09 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=379f326a Add pkg_setup and gcc bindir detection --- eclass/cuda.eclass | 91 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 84 insertions(+), 7 deletions(-) diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass index 5a72d2f..3672d9e 100644 --- a/eclass/cuda.eclass +++ b/eclass/cuda.eclass @@ -9,16 +9,94 @@ inherit toolchain-funcs versionator # Justin Lecher # @BLURB: Common functions for cuda packages -# @ECLASS-VARIABLE: +# @ECLASS-VARIABLE: NVCCFLAGS +# DESCRIPTION: +# nvcc compiler flags (see nvcc --help) +: ${NVCCFLAGS:=-O2} +# @ECLASS-VARIABLE: CUDA_VERBOSE +# DESCRIPTION: +# Being verbose during compilation to see underlying commands +: ${CUDA_VERBOSE:=true} -# @ECLASS-FUNCTION: CUDA_SUPPORTED_GCC +if [[ "${CUDA_VERBOSE}" == true ]]; then + NVCCFLAGS+=" -v" +fi + +# @ECLASS-FUNCTION: cuda_gccdir # @DESCRIPTION: -# Listing of gcc version slots supported by nvidia cuda tool. -# Generally only needed py +# Helper for determination of the latest bindir supported by nvidia cuda toolkit. +# +# Calling plain it returns simply the path, but you probably want to add \"-f\"" +# to get the full flag to add to nvcc call. +# +# cuda_gccdir-f +# -> --compiler-bindir="/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3" +cuda_gccdir() { + local _gcc_bindir _ver _args="" _flag _ret + + # Currently we only support the gnu compiler suite + if [[ $(tc-getCXX) != *g++* ]]; then + return 2 + fi + + while [ "$1" ]; do + case $1 in + -f) + _flag="--compiler-bindir=" + ;; + *) + ;; + esac + shift + done + + if [[ ! $(type -P cuda-config) ]]; then + eerror "Could not execute cuda-config" + eerror "Make sure >=dev-util/nvidia-cuda-toolkit-4.2.9-r1 is installed" + die "cuda-config not found" + else + _args="$(version_sort $(cuda-config -s))" + if [[ ! -n ${_args} ]]; then + die "Could not determine supported gcc versions from cuda-config" + fi + fi + + for _ver in ${_args}; do + has_version sys-devel/gcc:${_ver} && \ + _gcc_bindir="$(ls -d ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${_ver}* | tail -n 1)" + done + + if [[ -n ${_gcc_bindir} ]]; then + if [[ -n ${_flag} ]]; then + _ret="${_flag}\\\"${_gcc_bindir}\\\"" + else + _ret="${_gcc_bindir}" + fi + echo ${_ret} + return 0 + else + eerror "Only gcc version(s) ${_args} are supported," + eerror "of which none is installed" + die "Only gcc version(s) ${_args} are supported" + return 1 + fi +} + +cuda_pkg_setup() { + # Tell nvcc where to find a compatible compiler + NVCCFLAGS+=" $(cuda_gccdir -f)" + + # Tell nvcc which flags should be used for underlying C compiler + NVCCFLAGS+=" --compiler-options=\"${CXXFLAGS}\"" + + export NVCCFLAGS +} cuda_pkg_postinst() { - if [[ $(tc-getCC) == *gcc* ]] && version_is_at_least 4.7 "$(gcc-version)"; then + local a + a="$(version_sort $(cuda-config -s))"; a=($a) + if [[ $(tc-getCC) == *gcc* ]] && version_is_at_least "$(gcc-version)" ${a[1]}; then ewarn "gcc >= 4.6 will not work with CUDA" ewarn "Make sure you set an earlier version of gcc with gcc-config" ewarn "or append --compiler-bindir= to the nvcc compiler flags" @@ -27,9 +105,8 @@ cuda_pkg_postinst() { fi } -EXPORT_FUNCTIONS pkg_postinst +EXPORT_FUNCTIONS pkg_setup pkg_postinst case "${EAPI:-0}" in 0|1|2|3|4|5) ;; *) die "EAPI=${EAPI} is not supported" ;; esac -