Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 115 lines 4.0 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch, 6 cmake, 7 ninja, 8}: 9 10stdenv.mkDerivation rec { 11 pname = "tbb"; 12 version = "2021.11.0"; 13 14 outputs = [ 15 "out" 16 "dev" 17 ]; 18 19 src = fetchFromGitHub { 20 owner = "oneapi-src"; 21 repo = "oneTBB"; 22 rev = "v${version}"; 23 hash = "sha256-zGZHMtAUVzBKFbCshpepm3ce3tW6wQ+F30kYYXAQ/TE="; 24 }; 25 26 nativeBuildInputs = [ 27 cmake 28 ninja 29 ]; 30 31 patches = [ 32 # Fix musl build from https://github.com/oneapi-src/oneTBB/pull/899 33 (fetchpatch { 34 url = "https://patch-diff.githubusercontent.com/raw/oneapi-src/oneTBB/pull/899.patch"; 35 hash = "sha256-kU6RRX+sde0NrQMKlNtW3jXav6J4QiVIUmD50asmBPU="; 36 }) 37 (fetchpatch { 38 name = "fix-tbb-mingw-compile.patch"; 39 url = "https://patch-diff.githubusercontent.com/raw/oneapi-src/oneTBB/pull/1361.patch"; 40 hash = "sha256-jVa4HQetZv0vImdv549MyTy6/8t9dy8m6YAmjPGNQ18="; 41 }) 42 (fetchpatch { 43 name = "fix-tbb-mingw-link.patch"; 44 url = "https://patch-diff.githubusercontent.com/raw/oneapi-src/oneTBB/pull/1193.patch"; 45 hash = "sha256-ZQbwUmuIZoGVBof8QNR3V8vU385e2X7EvU3+Fbj4+M8="; 46 }) 47 # Fix tests on FreeBSD and Windows 48 (fetchpatch { 49 name = "fix-tbb-freebsd-and-windows-tests.patch"; 50 url = "https://patch-diff.githubusercontent.com/raw/uxlfoundation/oneTBB/pull/1696.patch"; 51 hash = "sha256-yjX2FkOK8bz29a/XSA7qXgQw9lxzx8VIgEBREW32NN4="; 52 }) 53 # Fix Threads::Threads target for static from https://github.com/oneapi-src/oneTBB/pull/1248 54 # This is a conflict-resolved cherry-pick of the above PR to due to formatting differences. 55 (fetchpatch { 56 name = "fix-cmake-threads-threads-target-for-static.patch"; 57 url = "https://patch-diff.githubusercontent.com/raw/uxlfoundation/oneTBB/pull/1248.patch"; 58 hash = "sha256-3WKzxU93vxuy7NgW+ap+ocZz5Q5utZ/pK7+FQExzLLA="; 59 }) 60 ]; 61 62 patchFlags = [ 63 "-p1" 64 "--ignore-whitespace" 65 ]; 66 67 # Fix build with modern gcc 68 # In member function 'void std::__atomic_base<_IntTp>::store(__int_type, std::memory_order) [with _ITp = bool]', 69 NIX_CFLAGS_COMPILE = 70 lib.optionals stdenv.cc.isGNU [ 71 "-Wno-error=array-bounds" 72 "-Wno-error=stringop-overflow" 73 ] 74 ++ 75 # error: variable 'val' set but not used 76 lib.optionals stdenv.cc.isClang [ "-Wno-error=unused-but-set-variable" ] 77 ++ 78 # Workaround for gcc-12 ICE when using -O3 79 # https://gcc.gnu.org/PR108854 80 lib.optionals (stdenv.cc.isGNU && stdenv.hostPlatform.isx86_32) [ "-O2" ]; 81 82 # Fix undefined reference errors with version script under LLVM. 83 NIX_LDFLAGS = lib.optionalString ( 84 stdenv.cc.bintools.isLLVM && lib.versionAtLeast stdenv.cc.bintools.version "17" 85 ) "--undefined-version"; 86 87 # Disable failing test on musl 88 # test/conformance/conformance_resumable_tasks.cpp:37:24: error: ‘suspend’ is not a member of ‘tbb::v1::task’; did you mean ‘tbb::detail::r1::suspend’? 89 postPatch = lib.optionalString stdenv.hostPlatform.isMusl '' 90 substituteInPlace test/CMakeLists.txt \ 91 --replace-fail 'tbb_add_test(SUBDIR conformance NAME conformance_resumable_tasks DEPENDENCIES TBB::tbb)' "" 92 ''; 93 94 enableParallelBuilding = true; 95 96 meta = with lib; { 97 description = "Intel Thread Building Blocks C++ Library"; 98 homepage = "http://threadingbuildingblocks.org/"; 99 license = licenses.asl20; 100 longDescription = '' 101 Intel Threading Building Blocks offers a rich and complete approach to 102 expressing parallelism in a C++ program. It is a library that helps you 103 take advantage of multi-core processor performance without having to be a 104 threading expert. Intel TBB is not just a threads-replacement library. It 105 represents a higher-level, task-based parallelism that abstracts platform 106 details and threading mechanisms for scalability and performance. 107 ''; 108 platforms = platforms.unix ++ platforms.windows; 109 maintainers = with maintainers; [ 110 silvanshade 111 thoughtpolice 112 tmarkus 113 ]; 114 }; 115}