python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / tbb / default.nix
blob21fddb16562709ac0b47e796429076803edb9805
1 { lib
2 , stdenv
3 , fetchurl
4 , fetchFromGitHub
5 , fixDarwinDylibNames
6 }:
8 stdenv.mkDerivation rec {
9   pname = "tbb";
10   version = "2020.3";
12   src = fetchFromGitHub {
13     owner = "oneapi-src";
14     repo = "oneTBB";
15     rev = "v${version}";
16     sha256 = "prO2O5hd+Wz5iA0vfrqmyHFr0Ptzk64so5KpSpvuKmU=";
17   };
19   patches = [
20     # Fixes build with Musl.
21     (fetchurl {
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=";
24     })
26     # Fixes build with Musl.
27     (fetchurl {
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=";
30     })
32     # Fixes build with upcoming gcc-13:
33     #  https://github.com/oneapi-src/oneTBB/pull/833
34     (fetchurl {
35       name = "gcc-13.patch";
36       url = "https://github.com/oneapi-src/oneTBB/pull/833/commits/c18342ba667d1f33f5e9a773aa86b091a9694b97.patch";
37       sha256 = "ZUExE3nsW80Z5GPWZnDNuDiHHaD1EF7qNl/G5M+Wcxg=";
38     })
40     # Fixes build for aarch64-darwin
41     (fetchurl {
42       name = "aarch64-darwin.patch";
43       url = "https://github.com/oneapi-src/oneTBB/pull/258/commits/86f6dcdc17a8f5ef2382faaef860cfa5243984fe.patch";
44       sha256 = "sha256-JXqrFPCb3q1vfxk752tQu7HhApCB4YH2LoVnGRwmspk=";
45     })
46   ];
48   nativeBuildInputs = lib.optionals stdenv.isDarwin [
49     fixDarwinDylibNames
50   ];
52   makeFlags = lib.optionals stdenv.cc.isClang [
53     "compiler=clang"
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;
61   installPhase = ''
62     runHook preInstall
64     mkdir -p $out/lib
65     cp "build/"*release*"/"*${stdenv.hostPlatform.extensions.sharedLibrary}* $out/lib/
66     mv include $out/
67     rm $out/include/index.html
69     runHook postInstall
70   '';
72   postInstall = let
73     pcTemplate = fetchurl {
74       url = "https://github.com/oneapi-src/oneTBB/raw/478de5b1887c928e52f029d706af6ea640a877be/integration/pkg-config/tbb.pc.in";
75       sha256 = "2pCad9txSpNbzac0vp/VY3x7HNySaYkbH3Rx8LK53pI=";
76     };
77   in ''
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"
87   '';
89   meta = with lib; {
90     description = "Intel Thread Building Blocks C++ Library";
91     homepage = "http://threadingbuildingblocks.org/";
92     license = licenses.asl20;
93     longDescription = ''
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.
100     '';
101     platforms = platforms.unix;
102     maintainers = with maintainers; [ thoughtpolice dizfer ];
103   };