Advertisement
Guest User

Gentoo CUDA-4.0 and GCC-4.5 fix

a guest
Nov 7th, 2011
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.23 KB | None | 0 0
  1. ##file: dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-4.0.ebuild
  2. # Copyright 1999-2011 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: /var/cvsroot/gentoo-x86/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-4.0.ebuild,v 1.1 2011/05/29 20:26:10 spock Exp $
  5.  
  6. EAPI=2
  7.  
  8. inherit eutils toolchain-funcs
  9.  
  10. DESCRIPTION="NVIDIA CUDA Software Development Kit"
  11. HOMEPAGE="http://developer.nvidia.com/cuda"
  12.  
  13. CUDA_V=${PV//_/-}
  14. DIR_V=${CUDA_V//./_}
  15. DIR_V=${DIR_V//beta/Beta}
  16.  
  17. SRC_URI="http://developer.download.nvidia.com/compute/cuda/${DIR_V}/sdk/gpucomputingsdk_${CUDA_V}.17_linux.run"
  18. LICENSE="CUDPP"
  19. SLOT="0"
  20. KEYWORDS="~amd64 ~x86"
  21. IUSE="debug +doc +examples opencl +cuda"
  22.  
  23. RDEPEND=">=dev-util/nvidia-cuda-toolkit-4.0
  24. examples? ( >=x11-drivers/nvidia-drivers-260.19.21 )
  25. media-libs/freeglut"
  26. DEPEND="${RDEPEND}"
  27.  
  28. S="${WORKDIR}"
  29.  
  30. RESTRICT="binchecks"
  31.  
  32. pkg_setup() {
  33. if use cuda || use opencl && [ "$(gcc-major-version)" == "4" -a $(gcc-minor-version) -ge 6 ]; then
  34. eerror "This package requires <=sys-devel/gcc-4.5 to build successfully."
  35. eerror "Please use gcc-config to switch to a compatible GCC version."
  36. die "<=sys-devel/gcc-4.5 required"
  37. fi
  38. }
  39.  
  40. src_unpack() {
  41. unpack_makeself
  42. }
  43.  
  44. #src_prepare() {
  45. # epatch "${FILESDIR}"/${PN}-gcc4.4_fix.patch
  46. #}
  47.  
  48. src_compile() {
  49. if ! use examples; then
  50. return
  51. fi
  52. local myopts=""
  53.  
  54. if use debug; then
  55. myopts="${myopts} dbg=1"
  56. fi
  57.  
  58. cd "${S}/sdk"
  59.  
  60. if use cuda; then
  61. cd C
  62. emake cuda-install=/opt/cuda ${myopts} || die
  63. cd ..
  64. fi
  65.  
  66. if use opencl; then
  67. cd OpenCL
  68. emake || die
  69. cd ..
  70. fi
  71. }
  72.  
  73. src_install() {
  74. cd "${S}/sdk"
  75.  
  76. if ! use doc; then
  77. rm -rf *.txt doc */doc */Samples.htm */releaseNotesData
  78. fi
  79.  
  80. if ! use examples; then
  81. rm -rf bin */bin */tools
  82. fi
  83.  
  84. for f in $(find .); do
  85. local t="$(dirname ${f})"
  86. if [[ "${t/obj\/}" != "${t}" || "${t##*.}" == "a" ]]; then
  87. continue
  88. fi
  89.  
  90. if [[ ! -d "${f}" ]]; then
  91. if [[ -x "${f}" ]]; then
  92. exeinto "/opt/cuda/sdk/${t}"
  93. doexe "${f}"
  94. else
  95. insinto "/opt/cuda/sdk/${t}"
  96. doins "${f}"
  97. fi
  98. fi
  99. done
  100. }
  101.  
  102. diff -u /usr/portage/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-4.0.ebuild /usr/local/portage/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-4.0.ebuild
  103. --- /usr/portage/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-4.0.ebuild 2011-05-30 00:26:10.000000000 +0400
  104. +++ /usr/local/portage/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-4.0.ebuild 2011-10-20 14:32:45.000000000 +0400
  105. @@ -29,10 +29,10 @@
  106. RESTRICT="binchecks"
  107.  
  108. pkg_setup() {
  109. - if use cuda || use opencl && [ "$(gcc-major-version)" == "4" -a $(gcc-minor-version) -ge 5 ]; then
  110. - eerror "This package requires <=sys-devel/gcc-4.4 to build sucessfully."
  111. + if use cuda || use opencl && [ "$(gcc-major-version)" == "4" -a $(gcc-minor-version) -ge 6 ]; then
  112. + eerror "This package requires <=sys-devel/gcc-4.5 to build successfully."
  113. eerror "Please use gcc-config to switch to a compatible GCC version."
  114. - die "<=sys-devel/gcc-4.4 required"
  115. + die "<=sys-devel/gcc-4.5 required"
  116. fi
  117. }
  118.  
  119. @@ -40,6 +40,10 @@
  120. unpack_makeself
  121. }
  122.  
  123. +#src_prepare() {
  124. +# epatch "${FILESDIR}"/${PN}-gcc4.4_fix.patch
  125. +#}
  126. +
  127. src_compile() {
  128. if ! use examples; then
  129. return
  130.  
  131. ##file: dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-4.0.ebuild
  132. # Copyright 1999-2011 Gentoo Foundation
  133. # Distributed under the terms of the GNU General Public License v2
  134. # $Header: /var/cvsroot/gentoo-x86/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-4.0.ebuild,v 1.7 2011/09/04 10:08:12 maekke Exp $
  135.  
  136. EAPI=2
  137.  
  138. inherit eutils multilib
  139.  
  140. DESCRIPTION="NVIDIA CUDA Toolkit"
  141. HOMEPAGE="http://developer.nvidia.com/cuda"
  142. RESTRICT="binchecks"
  143.  
  144. CUDA_V=${PV//_/-}
  145. DIR_V=${CUDA_V//./_}
  146. DIR_V=${DIR_V//beta/Beta}
  147.  
  148. BASE_URI="http://developer.download.nvidia.com/compute/cuda/${DIR_V}/toolkit"
  149. SRC_URI="amd64? ( ${BASE_URI}/cudatoolkit_${CUDA_V}.17_linux_64_ubuntu10.10.run )
  150. x86? ( ${BASE_URI}/cudatoolkit_${CUDA_V}.17_linux_32_ubuntu10.10.run )"
  151.  
  152. LICENSE="NVIDIA"
  153. SLOT="0"
  154. KEYWORDS="amd64 x86"
  155. IUSE="debugger doc profiler"
  156.  
  157. RDEPEND="${DEPEND}
  158. >=sys-devel/binutils-2.20
  159. <sys-devel/gcc-4.6
  160. profiler? ( x86? (
  161. x11-libs/qt-gui
  162. x11-libs/qt-core
  163. x11-libs/qt-assistant[compat]
  164. x11-libs/qt-sql[sqlite] )
  165. media-libs/libpng:1.2
  166. )
  167. debugger? ( >=sys-libs/libtermcap-compat-2.0.8-r2 )
  168. !<=x11-drivers/nvidia-drivers-270.41"
  169.  
  170. S="${WORKDIR}"
  171.  
  172. #QA_DT_HASH_x86="opt/cuda/.*"
  173. #QA_DT_HASH_amd64="opt/cuda/.*"
  174.  
  175. src_unpack() {
  176. for f in ${A} ; do
  177. if [ "${f//*.run/}" == "" ]; then
  178. unpack_makeself ${f}
  179. fi
  180. done
  181. }
  182.  
  183. src_prepare() {
  184. epatch "${FILESDIR}"/${P}-gcc4.5_fix.patch
  185. }
  186.  
  187. src_install() {
  188. local DEST=/opt/cuda
  189.  
  190. into ${DEST}
  191. dobin bin/*
  192. dolib $(get_libdir)/*
  193.  
  194. if ! use debugger; then
  195. rm -f "${D}/${DEST}/bin/cuda-gdb"
  196. fi
  197.  
  198. chmod a-x "${D}/${DEST}/bin/nvcc.profile"
  199.  
  200. # TODO: Manuals are missing from this release. Remove the following
  201. # commented-out lines if they are not restored in the next releases.
  202. # doman does not respect DESTTREE
  203. #insinto ${DEST}/man/man1
  204. #doins man/man1/*
  205. #insinto ${DEST}/man/man3
  206. #doins man/man3/*
  207. #prepman ${DEST}
  208.  
  209. insinto ${DEST}/include
  210. doins -r include/*
  211.  
  212. insinto ${DEST}/src
  213. doins src/*
  214.  
  215. if use doc ; then
  216. insinto ${DEST}/doc
  217. doins -r doc/*
  218. fi
  219.  
  220. cat > "${T}/env" << EOF
  221. PATH=${DEST}/bin
  222. ROOTPATH=${DEST}/bin
  223. LDPATH=${DEST}/$(get_libdir)
  224. MANPATH=${DEST}/man
  225. EOF
  226. newenvd "${T}/env" 99cuda
  227.  
  228. if use profiler; then
  229. local target="computeprof"
  230.  
  231. into ${DEST}/${target}
  232. dobin ${target}/bin/${target}
  233.  
  234. cat > "${T}/env" << EOF
  235. PATH=${DEST}/${target}/bin
  236. ROOTPATH=${DEST}/${target}/bin
  237. EOF
  238. if use x86 ; then
  239. dosym /usr/bin/assistant ${DEST}/${target}/bin
  240.  
  241. insinto ${DEST}/${target}/bin
  242. doins ${target}/bin/cudaapitrace32.so
  243. else
  244. dobin ${target}/bin/assistant
  245. insinto ${DEST}/${target}/bin
  246. doins ${target}/bin/*.so.?.?.?
  247. for f in ${target}/bin/*.so.?; do
  248. dosym $(readlink ${f}) ${DEST}/${f}
  249. done
  250. insinto ${DEST}/${target}/bin/sqldrivers
  251. doins ${target}/bin/sqldrivers/*
  252.  
  253. cat >> "${T}/env" << EOF
  254. LDPATH=${DEST}/${target}/bin
  255. EOF
  256. fi
  257.  
  258. newenvd "${T}/env" 99${target}
  259.  
  260. if use doc; then
  261. insinto ${DEST}/${target}
  262. doins ${target}/*.txt
  263. insinto ${DEST}/${target}/doc
  264. doins ${target}/doc/*
  265. insinto ${DEST}/${target}/projects
  266. doins ${target}/projects/*
  267. fi
  268.  
  269. make_desktop_entry /opt/cuda/computeprof/bin/computeprof "NVIDIA Compute Visual Profiler"
  270. fi
  271.  
  272. export CONF_LIBDIR_OVERRIDE="lib"
  273. # HACK: temporary workaround until CONF_LIBDIR_OVERRIDE is respected.
  274. export LIBDIR_amd64="lib"
  275.  
  276. into ${DEST}/open64
  277. dobin open64/bin/*
  278. libopts -m0755
  279. dolib open64/lib/*
  280.  
  281. # TODO: ideally, there would be multiple OpenCL implementations available in
  282. # the tree and an eselect module would allow to switch between them.
  283. into /
  284. dosym /opt/cuda/include/CL usr/include/CL
  285. }
  286.  
  287. pkg_postinst() {
  288. env-update
  289. elog "If you want to natively run the code generated by this version of the"
  290. elog "CUDA toolkit, you will need >=x11-drivers/nvidia-drivers-260.19.21."
  291. elog ""
  292. elog "Run '. /etc/profile' before using the CUDA toolkit. "
  293. }
  294.  
  295. diff -u /usr/portage/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-4.0.ebuild /usr/local/portage/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-4.0.ebuild
  296. --- /usr/portage/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-4.0.ebuild 2011-09-04 14:31:12.000000000 +0400
  297. +++ /usr/local/portage/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-4.0.ebuild 2011-10-22 16:46:37.000000000 +0400
  298. @@ -25,7 +25,7 @@
  299.  
  300. RDEPEND="${DEPEND}
  301. >=sys-devel/binutils-2.20
  302. - sys-devel/gcc:4.4
  303. + <sys-devel/gcc-4.6
  304. profiler? ( x86? (
  305. x11-libs/qt-gui
  306. x11-libs/qt-core
  307. @@ -49,6 +49,10 @@
  308. done
  309. }
  310.  
  311. +src_prepare() {
  312. + epatch "${FILESDIR}"/${P}-gcc4.5_fix.patch
  313. +}
  314. +
  315. src_install() {
  316. local DEST=/opt/cuda
  317.  
  318. ##file: dev-util/nvidia-cuda-toolkit/files/nvidia-cuda-toolkit-4.0-gcc4.5_fix.patch
  319. --- include/host_config.h.backup 2011-10-20 14:30:16.213280825 +0400
  320. +++ include/host_config.h 2011-10-20 14:30:48.523876841 +0400
  321. @@ -77,11 +77,11 @@
  322.  
  323. #if defined(__GNUC__)
  324.  
  325. -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)
  326. +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
  327.  
  328. -#error -- unsupported GNU version! gcc 4.5 and up are not supported!
  329. +#error -- unsupported GNU version! gcc 4.6 and up are not supported!
  330.  
  331. -#endif /* __GNUC__> 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4) */
  332. +#endif /* __GNUC__> 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) */
  333.  
  334. #endif /* __GNUC__ */
  335.  
  336.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement