tbb: Split into tbb_2020_3 and tbb_2021_8

This is based on PR #214762.

For the new release 2021.8, see
https://www.intel.com/content/www/us/en/developer/articles/release-notes/intel-oneapi-threading-building-blocks-release-notes.html
https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0
https://github.com/oneapi-src/oneTBB/releases/tag/v2021.6.0
https://github.com/oneapi-src/oneTBB/releases/tag/v2021.7.0

Due to the significant breakage due to the update to TBB 2021.8, instead
split the tbb package into tbb_2020_3 and tbb_2021_8, with the default
tbb aliased to tbb_2020_3 in order to minimize breakage.

Also fixed build issues and improved code.

Co-Authored-By: Martin Weinelt <hexa@darmstadt.ccc.de>
Co-Authored-By: davidak <git@davidak.de>

authored by Tobias Markus Martin Weinelt davidak and committed by davidak cc541cb7 4f4c53e4

+138 -67
+106
pkgs/development/libraries/tbb/2020_3.nix
···
··· 1 + { lib 2 + , stdenv 3 + , fetchurl 4 + , fetchFromGitHub 5 + , fixDarwinDylibNames 6 + }: 7 + 8 + stdenv.mkDerivation rec { 9 + pname = "tbb"; 10 + version = "2020.3"; 11 + 12 + outputs = [ "out" "dev" ]; 13 + 14 + src = fetchFromGitHub { 15 + owner = "oneapi-src"; 16 + repo = "oneTBB"; 17 + rev = "v${version}"; 18 + sha256 = "prO2O5hd+Wz5iA0vfrqmyHFr0Ptzk64so5KpSpvuKmU="; 19 + }; 20 + 21 + patches = [ 22 + # Fixes build with Musl. 23 + (fetchurl { 24 + url = "https://github.com/openembedded/meta-openembedded/raw/39185eb1d1615e919e3ae14ae63b8ed7d3e5d83f/meta-oe/recipes-support/tbb/tbb/GLIBC-PREREQ-is-not-defined-on-musl.patch"; 25 + sha256 = "gUfXQ9OZQ82qD6brgauBCsKdjLvyHafMc18B+KxZoYs="; 26 + }) 27 + 28 + # Fixes build with Musl. 29 + (fetchurl { 30 + 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"; 31 + sha256 = "fhorfqO1hHKZ61uq+yTR7eQ8KYdyLwpM3K7WpwJpV74="; 32 + }) 33 + 34 + # Fixes build with upcoming gcc-13: 35 + # https://github.com/oneapi-src/oneTBB/pull/833 36 + (fetchurl { 37 + name = "gcc-13.patch"; 38 + url = "https://github.com/oneapi-src/oneTBB/pull/833/commits/c18342ba667d1f33f5e9a773aa86b091a9694b97.patch"; 39 + sha256 = "ZUExE3nsW80Z5GPWZnDNuDiHHaD1EF7qNl/G5M+Wcxg="; 40 + }) 41 + 42 + # Fixes build for aarch64-darwin 43 + (fetchurl { 44 + name = "aarch64-darwin.patch"; 45 + url = "https://github.com/oneapi-src/oneTBB/pull/258/commits/86f6dcdc17a8f5ef2382faaef860cfa5243984fe.patch"; 46 + sha256 = "sha256-JXqrFPCb3q1vfxk752tQu7HhApCB4YH2LoVnGRwmspk="; 47 + }) 48 + ]; 49 + 50 + nativeBuildInputs = (lib.optionals stdenv.isDarwin [ 51 + fixDarwinDylibNames 52 + ]); 53 + 54 + makeFlags = lib.optionals stdenv.cc.isClang [ 55 + "compiler=clang" 56 + ] ++ (lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) 57 + (if stdenv.hostPlatform.isAarch64 then "arch=arm64" 58 + else if stdenv.hostPlatform.isx86_64 then "arch=intel64" 59 + else throw "Unsupported cross architecture")); 60 + 61 + enableParallelBuilding = true; 62 + 63 + installPhase = '' 64 + runHook preInstall 65 + 66 + mkdir -p $out/lib 67 + cp "build/"*release*"/"*${stdenv.hostPlatform.extensions.sharedLibrary}* $out/lib/ 68 + mv include $out/ 69 + rm $out/include/index.html 70 + 71 + runHook postInstall 72 + ''; 73 + 74 + postInstall = let 75 + pcTemplate = fetchurl { 76 + url = "https://github.com/oneapi-src/oneTBB/raw/478de5b1887c928e52f029d706af6ea640a877be/integration/pkg-config/tbb.pc.in"; 77 + sha256 = "2pCad9txSpNbzac0vp/VY3x7HNySaYkbH3Rx8LK53pI="; 78 + }; 79 + in '' 80 + # Generate pkg-config file based on upstream template. 81 + # It should not be necessary with tbb after 2021.2. 82 + mkdir -p "$out/lib/pkgconfig" 83 + substitute "${pcTemplate}" "$out/lib/pkgconfig/tbb.pc" \ 84 + --subst-var-by CMAKE_INSTALL_PREFIX "$out" \ 85 + --subst-var-by CMAKE_INSTALL_LIBDIR "lib" \ 86 + --subst-var-by CMAKE_INSTALL_INCLUDEDIR "include" \ 87 + --subst-var-by TBB_VERSION "${version}" \ 88 + --subst-var-by TBB_LIB_NAME "tbb" 89 + ''; 90 + 91 + meta = with lib; { 92 + description = "Intel Thread Building Blocks C++ Library"; 93 + homepage = "http://threadingbuildingblocks.org/"; 94 + license = licenses.asl20; 95 + longDescription = '' 96 + Intel Threading Building Blocks offers a rich and complete approach to 97 + expressing parallelism in a C++ program. It is a library that helps you 98 + take advantage of multi-core processor performance without having to be a 99 + threading expert. Intel TBB is not just a threads-replacement library. It 100 + represents a higher-level, task-based parallelism that abstracts platform 101 + details and threading mechanisms for scalability and performance. 102 + ''; 103 + platforms = platforms.unix; 104 + maintainers = with maintainers; [ thoughtpolice tmarkus ]; 105 + }; 106 + }
+28 -66
pkgs/development/libraries/tbb/default.nix
··· 1 { lib 2 , stdenv 3 - , fetchurl 4 , fetchFromGitHub 5 - , fixDarwinDylibNames 6 }: 7 8 stdenv.mkDerivation rec { 9 pname = "tbb"; 10 - version = "2020.3"; 11 12 outputs = [ "out" "dev" ]; 13 ··· 15 owner = "oneapi-src"; 16 repo = "oneTBB"; 17 rev = "v${version}"; 18 - sha256 = "prO2O5hd+Wz5iA0vfrqmyHFr0Ptzk64so5KpSpvuKmU="; 19 }; 20 21 patches = [ 22 - # Fixes build with Musl. 23 - (fetchurl { 24 - url = "https://github.com/openembedded/meta-openembedded/raw/39185eb1d1615e919e3ae14ae63b8ed7d3e5d83f/meta-oe/recipes-support/tbb/tbb/GLIBC-PREREQ-is-not-defined-on-musl.patch"; 25 - sha256 = "gUfXQ9OZQ82qD6brgauBCsKdjLvyHafMc18B+KxZoYs="; 26 }) 27 28 - # Fixes build with Musl. 29 - (fetchurl { 30 - 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"; 31 - sha256 = "fhorfqO1hHKZ61uq+yTR7eQ8KYdyLwpM3K7WpwJpV74="; 32 }) 33 - 34 - # Fixes build with upcoming gcc-13: 35 - # https://github.com/oneapi-src/oneTBB/pull/833 36 - (fetchurl { 37 - name = "gcc-13.patch"; 38 - url = "https://github.com/oneapi-src/oneTBB/pull/833/commits/c18342ba667d1f33f5e9a773aa86b091a9694b97.patch"; 39 - sha256 = "ZUExE3nsW80Z5GPWZnDNuDiHHaD1EF7qNl/G5M+Wcxg="; 40 - }) 41 - 42 - # Fixes build for aarch64-darwin 43 - (fetchurl { 44 - name = "aarch64-darwin.patch"; 45 - url = "https://github.com/oneapi-src/oneTBB/pull/258/commits/86f6dcdc17a8f5ef2382faaef860cfa5243984fe.patch"; 46 - sha256 = "sha256-JXqrFPCb3q1vfxk752tQu7HhApCB4YH2LoVnGRwmspk="; 47 - }) 48 - ]; 49 - 50 - nativeBuildInputs = lib.optionals stdenv.isDarwin [ 51 - fixDarwinDylibNames 52 ]; 53 54 - makeFlags = lib.optionals stdenv.cc.isClang [ 55 - "compiler=clang" 56 - ] ++ (lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) 57 - (if stdenv.hostPlatform.isAarch64 then "arch=arm64" 58 - else if stdenv.hostPlatform.isx86_64 then "arch=intel64" 59 - else throw "Unsupported cross architecture")); 60 - 61 - enableParallelBuilding = true; 62 - 63 - installPhase = '' 64 - runHook preInstall 65 66 - mkdir -p $out/lib 67 - cp "build/"*release*"/"*${stdenv.hostPlatform.extensions.sharedLibrary}* $out/lib/ 68 - mv include $out/ 69 - rm $out/include/index.html 70 - 71 - runHook postInstall 72 - ''; 73 - 74 - postInstall = let 75 - pcTemplate = fetchurl { 76 - url = "https://github.com/oneapi-src/oneTBB/raw/478de5b1887c928e52f029d706af6ea640a877be/integration/pkg-config/tbb.pc.in"; 77 - sha256 = "2pCad9txSpNbzac0vp/VY3x7HNySaYkbH3Rx8LK53pI="; 78 - }; 79 - in '' 80 - # Generate pkg-config file based on upstream template. 81 - # It should not be necessary with tbb after 2021.2. 82 - mkdir -p "$out/lib/pkgconfig" 83 - substitute "${pcTemplate}" "$out/lib/pkgconfig/tbb.pc" \ 84 - --subst-var-by CMAKE_INSTALL_PREFIX "$out" \ 85 - --subst-var-by CMAKE_INSTALL_LIBDIR "lib" \ 86 - --subst-var-by CMAKE_INSTALL_INCLUDEDIR "include" \ 87 - --subst-var-by TBB_VERSION "${version}" \ 88 - --subst-var-by TBB_LIB_NAME "tbb" 89 ''; 90 91 meta = with lib; { ··· 101 details and threading mechanisms for scalability and performance. 102 ''; 103 platforms = platforms.unix; 104 - maintainers = with maintainers; [ thoughtpolice ]; 105 }; 106 }
··· 1 { lib 2 , stdenv 3 , fetchFromGitHub 4 + , fetchpatch 5 + , cmake 6 }: 7 8 stdenv.mkDerivation rec { 9 pname = "tbb"; 10 + version = "2021.8.0"; 11 12 outputs = [ "out" "dev" ]; 13 ··· 15 owner = "oneapi-src"; 16 repo = "oneTBB"; 17 rev = "v${version}"; 18 + hash = "sha256-7MjUdPB1GsPt7ZkYj7DCisq20X8psljsVCjDpCSTYT4="; 19 }; 20 + 21 + nativeBuildInputs = [ 22 + cmake 23 + ]; 24 25 patches = [ 26 + # Fix musl build from https://github.com/oneapi-src/oneTBB/pull/899 27 + (fetchpatch { 28 + url = "https://patch-diff.githubusercontent.com/raw/oneapi-src/oneTBB/pull/899.patch"; 29 + hash = "sha256-kU6RRX+sde0NrQMKlNtW3jXav6J4QiVIUmD50asmBPU="; 30 }) 31 32 + # Fix/suppress warnings on gcc12.1 from https://github.com/oneapi-src/oneTBB/pull/866 33 + (fetchpatch { 34 + url = "https://patch-diff.githubusercontent.com/raw/oneapi-src/oneTBB/pull/866.patch"; 35 + hash = "sha256-e44Yv84Hfl5xoxWWTnLJLSGeNA1RBbah4/L43gPLS+c="; 36 }) 37 ]; 38 39 + # Fix build with modern gcc 40 + # In member function 'void std::__atomic_base<_IntTp>::store(__int_type, std::memory_order) [with _ITp = bool]', 41 + NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isGNU [ "-Wno-error=stringop-overflow" ] ++ 42 + # Workaround for gcc-12 ICE when using -O3 43 + # https://gcc.gnu.org/PR108854 44 + lib.optionals (stdenv.cc.isGNU && stdenv.isx86_32) [ "-O2" ]; 45 46 + # Disable failing test on musl 47 + # 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’? 48 + postPatch = lib.optionalString stdenv.hostPlatform.isMusl '' 49 + substituteInPlace test/CMakeLists.txt \ 50 + --replace 'conformance_resumable_tasks' "" 51 ''; 52 53 meta = with lib; { ··· 63 details and threading mechanisms for scalability and performance. 64 ''; 65 platforms = platforms.unix; 66 + maintainers = with maintainers; [ thoughtpolice tmarkus ]; 67 }; 68 }
+4 -1
pkgs/top-level/all-packages.nix
··· 16103 }; 16104 swiPrologWithGui = swiProlog.override { withGui = true; }; 16105 16106 - tbb = callPackage ../development/libraries/tbb { }; 16107 16108 terra = callPackage ../development/compilers/terra { 16109 llvmPackages = llvmPackages_11;
··· 16103 }; 16104 swiPrologWithGui = swiProlog.override { withGui = true; }; 16105 16106 + tbb_2020_3 = callPackage ../development/libraries/tbb/2020_3.nix { }; 16107 + tbb_2021_8 = callPackage ../development/libraries/tbb { }; 16108 + # many packages still fail with latest version 16109 + tbb = tbb_2020_3; 16110 16111 terra = callPackage ../development/compilers/terra { 16112 llvmPackages = llvmPackages_11;