tbb.scm 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015, 2016, 2022 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2016 Nikita <nikita@n0.is>
  4. ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
  6. ;;; Copyright © 2022 Efraim Flashner <efraim@flashner.co.il>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu packages tbb)
  23. #:use-module (guix packages)
  24. #:use-module (guix licenses)
  25. #:use-module (guix gexp)
  26. #:use-module (guix git-download)
  27. #:use-module (guix utils)
  28. #:use-module (guix build-system cmake)
  29. #:use-module (guix build-system gnu)
  30. #:use-module (gnu packages)
  31. #:use-module (gnu packages python)
  32. #:use-module (gnu packages swig))
  33. (define-public tbb
  34. (package
  35. (name "tbb")
  36. (version "2021.6.0")
  37. (source (origin
  38. (method git-fetch)
  39. (uri (git-reference
  40. (url "https://github.com/oneapi-src/oneTBB")
  41. (commit (string-append "v" version))))
  42. (file-name (git-file-name name version))
  43. (sha256
  44. (base32
  45. "039v4jmnkkxs7haxrfmk9j57vfbrwlhjynlm5byfaqddv4cbsy0p"))
  46. (patches (search-patches "tbb-other-arches.patch"))))
  47. (build-system cmake-build-system)
  48. (arguments
  49. `(#:configure-flags '("-DTBB_STRICT=OFF"))) ;; Don't fail on warnings
  50. (home-page "https://www.threadingbuildingblocks.org")
  51. (synopsis "C++ library for parallel programming")
  52. (description
  53. "Threading Building Blocks (TBB) is a C++ runtime library that abstracts
  54. the low-level threading details necessary for optimal multi-core performance.
  55. It uses common C++ templates and coding style to eliminate tedious threading
  56. implementation work. It provides parallel loop constructs, asynchronous
  57. tasks, synchronization primitives, atomic operations, and more.")
  58. (license asl2.0)))
  59. (define-public python-tbb
  60. (package
  61. (inherit tbb)
  62. (name "python-tbb")
  63. (arguments
  64. (list
  65. #:configure-flags
  66. #~(list "-DTBB_STRICT=OFF"
  67. "-DTBB4PY_BUILD=ON")
  68. #:phases
  69. #~(modify-phases %standard-phases
  70. (add-after 'unpack 'patch-python-install-directory
  71. (lambda _
  72. (substitute* "python/CMakeLists.txt"
  73. (("\\$\\{PYTHON_BUILD_WORK_DIR\\}/build")
  74. #$output))
  75. (substitute* "python/setup.py"
  76. (("extra_link_args=tbb_flag,")
  77. (string-append "extra_link_args=['-Wl,-rpath="
  78. #$(this-package-input "tbb") "/lib"
  79. "', '-Wl,-rpath=" #$output "/lib'] + tbb_flag,")))))
  80. (replace 'build
  81. (lambda _
  82. (setenv "PYTHONHASHSEED" "0")
  83. (setenv "PYTHONDONTWRITEBYTECODE" "1")
  84. (invoke "make" "python_build")))
  85. ;; The 'build phase already installs the modules
  86. (replace 'install
  87. (lambda _
  88. (with-directory-excursion "python/rml"
  89. (invoke "make" "install"))))
  90. (replace 'check
  91. (lambda* (#:key tests? #:allow-other-keys)
  92. (when tests?
  93. (invoke "ctest" "-R" "python_test" "--output-on-failure")))))))
  94. (inputs (list python tbb))
  95. (native-inputs (list swig))))
  96. (define-public tbb-2020
  97. (package
  98. (name "tbb")
  99. (version "2020.3")
  100. (source (origin
  101. (method git-fetch)
  102. (uri (git-reference
  103. (url "https://github.com/01org/tbb")
  104. (commit (string-append "v" version))))
  105. (file-name (git-file-name name version))
  106. (sha256
  107. (base32
  108. "0r9axsdlmacjlcnax4vkzg86nwf8lsx7wbqdi3wnryaxk0xvdcx6"))
  109. (modules '((guix build utils)))
  110. (snippet
  111. '(begin
  112. (substitute* "build/common.inc"
  113. (("export tbb_build_prefix.+$")
  114. "export tbb_build_prefix?=guix\n"))
  115. ;; Don't capture the build time and kernel version.
  116. (substitute* "build/version_info_linux.sh"
  117. (("uname -srv") "uname -s")
  118. (("`date -u`") "01 Jan 1970"))
  119. (substitute* "build/linux.inc"
  120. (("os_kernel_version:=.*")
  121. "os_kernel_version:=5\n")
  122. (("os_version:=.*")
  123. "os_version:=1\n"))))))
  124. (outputs '("out" "doc"))
  125. (build-system gnu-build-system)
  126. (arguments
  127. `(#:test-target "test"
  128. #:make-flags (list (string-append "LDFLAGS=-Wl,-rpath="
  129. (assoc-ref %outputs "out") "/lib")
  130. "CFLAGS=-fuse-ld=gold")
  131. #:phases
  132. (modify-phases %standard-phases
  133. (add-after 'unpack 'fail-on-test-errors
  134. (lambda _
  135. (substitute* "Makefile"
  136. (("-\\$\\(MAKE") "$(MAKE"))))
  137. (replace 'configure
  138. (lambda* (#:key outputs #:allow-other-keys)
  139. (substitute* "build/linux.gcc.inc"
  140. (("LIB_LINK_FLAGS =")
  141. (string-append "LIB_LINK_FLAGS = -Wl,-rpath="
  142. (assoc-ref outputs "out") "/lib")))))
  143. (replace 'install
  144. (lambda* (#:key outputs #:allow-other-keys)
  145. (let* ((doc (string-append
  146. (assoc-ref outputs "doc") "/doc"))
  147. (examples (string-append doc "/examples"))
  148. (lib (string-append
  149. (assoc-ref outputs "out") "/lib"))
  150. (include (string-append
  151. (assoc-ref outputs "out") "/include")))
  152. (mkdir-p lib)
  153. (for-each
  154. (lambda (f)
  155. (copy-file f
  156. (string-append lib "/"
  157. (basename f))))
  158. (find-files "build/guix_release" "\\.so"))
  159. (copy-recursively "doc" doc)
  160. (copy-recursively "examples" examples)
  161. (copy-recursively "include" include)))))))
  162. (native-inputs
  163. ;; XXX: For some reason, since commit "gnu: binutils: Absorb
  164. ;; binutils-next", the build of just this version of TBB crashes during
  165. ;; tests. Workaround it by linking the binaries with ld.gold.
  166. (list (module-ref (resolve-interface
  167. '(gnu packages commencement))
  168. 'ld-gold-wrapper)))
  169. (home-page "https://www.threadingbuildingblocks.org")
  170. (synopsis "C++ library for parallel programming")
  171. (description
  172. "Threading Building Blocks (TBB) is a C++ runtime library that abstracts
  173. the low-level threading details necessary for optimal multi-core performance.
  174. It uses common C++ templates and coding style to eliminate tedious threading
  175. implementation work. It provides parallel loop constructs, asynchronous
  176. tasks, synchronization primitives, atomic operations, and more.")
  177. (license asl2.0)))