8 stdenv.mkDerivation rec {
12 src = fetchFromGitHub {
16 sha256 = "prO2O5hd+Wz5iA0vfrqmyHFr0Ptzk64so5KpSpvuKmU=";
20 # Fixes build with Musl.
22 url = "https://github.com/openembedded/meta-openembedded/raw/39185eb1d1615e919e3ae14ae63b8ed7d3e5d83f/meta-oe/recipes-support/tbb/tbb/GLIBC-PREREQ-is-not-defined-on-musl.patch";
23 sha256 = "gUfXQ9OZQ82qD6brgauBCsKdjLvyHafMc18B+KxZoYs=";
26 # Fixes build with Musl.
28 url = "https://github.com/openembedded/meta-openembedded/raw/39185eb1d1615e919e3ae14ae63b8ed7d3e5d83f/meta-oe/recipes-support/tbb/tbb/0001-mallinfo-is-glibc-specific-API-mark-it-so.patch";
29 sha256 = "fhorfqO1hHKZ61uq+yTR7eQ8KYdyLwpM3K7WpwJpV74=";
32 # Fixes build with upcoming gcc-13:
33 # https://github.com/oneapi-src/oneTBB/pull/833
35 name = "gcc-13.patch";
36 url = "https://github.com/oneapi-src/oneTBB/pull/833/commits/c18342ba667d1f33f5e9a773aa86b091a9694b97.patch";
37 sha256 = "ZUExE3nsW80Z5GPWZnDNuDiHHaD1EF7qNl/G5M+Wcxg=";
40 # Fixes build for aarch64-darwin
42 name = "aarch64-darwin.patch";
43 url = "https://github.com/oneapi-src/oneTBB/pull/258/commits/86f6dcdc17a8f5ef2382faaef860cfa5243984fe.patch";
44 sha256 = "sha256-JXqrFPCb3q1vfxk752tQu7HhApCB4YH2LoVnGRwmspk=";
48 nativeBuildInputs = lib.optionals stdenv.isDarwin [
52 makeFlags = lib.optionals stdenv.cc.isClang [
54 ] ++ (lib.optional (stdenv.buildPlatform != stdenv.hostPlatform)
55 (if stdenv.hostPlatform.isAarch64 then "arch=arm64"
56 else if stdenv.hostPlatform.isx86_64 then "arch=intel64"
57 else throw "Unsupported cross architecture"));
59 enableParallelBuilding = true;
65 cp "build/"*release*"/"*${stdenv.hostPlatform.extensions.sharedLibrary}* $out/lib/
67 rm $out/include/index.html
73 pcTemplate = fetchurl {
74 url = "https://github.com/oneapi-src/oneTBB/raw/478de5b1887c928e52f029d706af6ea640a877be/integration/pkg-config/tbb.pc.in";
75 sha256 = "2pCad9txSpNbzac0vp/VY3x7HNySaYkbH3Rx8LK53pI=";
78 # Generate pkg-config file based on upstream template.
79 # It should not be necessary with tbb after 2021.2.
80 mkdir -p "$out/lib/pkgconfig"
81 substitute "${pcTemplate}" "$out/lib/pkgconfig/tbb.pc" \
82 --subst-var-by CMAKE_INSTALL_PREFIX "$out" \
83 --subst-var-by CMAKE_INSTALL_LIBDIR "lib" \
84 --subst-var-by CMAKE_INSTALL_INCLUDEDIR "include" \
85 --subst-var-by TBB_VERSION "${version}" \
86 --subst-var-by TBB_LIB_NAME "tbb"
90 description = "Intel Thread Building Blocks C++ Library";
91 homepage = "http://threadingbuildingblocks.org/";
92 license = licenses.asl20;
94 Intel Threading Building Blocks offers a rich and complete approach to
95 expressing parallelism in a C++ program. It is a library that helps you
96 take advantage of multi-core processor performance without having to be a
97 threading expert. Intel TBB is not just a threads-replacement library. It
98 represents a higher-level, task-based parallelism that abstracts platform
99 details and threading mechanisms for scalability and performance.
101 platforms = platforms.unix;
102 maintainers = with maintainers; [ thoughtpolice dizfer ];