From: "Justin Lecher" <jlec@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sci:cuda commit in: eclass/
Date: Fri, 16 Nov 2012 15:50:43 +0000 (UTC) [thread overview]
Message-ID: <1353080927.c68b60e656ddf468dc9d51704cd0ada7a3dab7c2.jlec@gentoo> (raw)
commit: c68b60e656ddf468dc9d51704cd0ada7a3dab7c2
Author: Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 16 15:48:47 2012 +0000
Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Fri Nov 16 15:48:47 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=c68b60e6
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 <jlec@gentoo.org>
# @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
-
reply other threads:[~2012-11-16 15:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353080927.c68b60e656ddf468dc9d51704cd0ada7a3dab7c2.jlec@gentoo \
--to=jlec@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox