git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #122587 from jtojnar/tbb-pc

tbb: install pkg-config file

commite91e91605604784675c57063117161ef73d1dd72 authorJan Tojnar <jtojnar@gmail.com> dateWed 12 May 2021, 23:49 (6 years ago) parent36a302cd8258b5
2 files changed+51−57
pkgs/development/libraries/tbb/default.nix+51−14 pkgs/development/libraries/tbb/glibc-struct-mallinfo.patch−43
pkgs/development/libraries/tbb/default.nix+51−14
@@ -1,22 +1,44 @@
1−{ lib, stdenv, fetchFromGitHub, fixDarwinDylibNames, compiler ? if stdenv.cc.isClang then "clang" else null, stdver ? null }:
1+{ lib
2+, stdenv
3+, fetchurl
4+, fetchFromGitHub
5+, fixDarwinDylibNames
6+}:
27
3−with lib; stdenv.mkDerivation rec {
8+stdenv.mkDerivation rec {
49 pname = "tbb";
5− version = "2020_U3";
10+ version = "2020.3";
611
712 src = fetchFromGitHub {
8− owner = "01org";
9− repo = "tbb";
10− rev = version;
11− sha256 = "sha256-prO2O5hd+Wz5iA0vfrqmyHFr0Ptzk64so5KpSpvuKmU=";
13+ owner = "oneapi-src";
14+ repo = "oneTBB";
15+ rev = "v${version}";
16+ sha256 = "prO2O5hd+Wz5iA0vfrqmyHFr0Ptzk64so5KpSpvuKmU=";
1217 };
1318
14− nativeBuildInputs = optional stdenv.isDarwin fixDarwinDylibNames;
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+ })
1525
16− makeFlags = optional (compiler != null) "compiler=${compiler}"
17− ++ optional (stdver != null) "stdver=${stdver}";
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+ })
31+ ];
1832
19− patches = lib.optional stdenv.hostPlatform.isMusl ./glibc-struct-mallinfo.patch;
33+ nativeBuildInputs = lib.optionals stdenv.isDarwin [
34+ fixDarwinDylibNames
35+ ];
36+
37+ makeFlags = lib.optionals stdenv.cc.isClang [
38+ "compiler=clang"
39+ ];
40+
41+ enableParallelBuilding = true;
2042
2143 installPhase = ''
2244 runHook preInstall
@@ -29,9 +51,24 @@ with lib; stdenv.mkDerivation rec {
2951 runHook postInstall
3052 '';
3153
32− enableParallelBuilding = true;
54+ postInstall = let
55+ pcTemplate = fetchurl {
56+ url = "https://github.com/oneapi-src/oneTBB/raw/master/integration/pkg-config/tbb.pc.in";
57+ sha256 = "2pCad9txSpNbzac0vp/VY3x7HNySaYkbH3Rx8LK53pI=";
58+ };
59+ in ''
60+ # Generate pkg-config file based on upstream template.
61+ # It should not be necessary with tbb after 2021.2.
62+ mkdir -p "$out/lib/pkgconfig"
63+ substitute "${pcTemplate}" "$out/lib/pkgconfig/tbb.pc" \
64+ --subst-var-by CMAKE_INSTALL_PREFIX "$out" \
65+ --subst-var-by CMAKE_INSTALL_LIBDIR "lib" \
66+ --subst-var-by CMAKE_INSTALL_INCLUDEDIR "include" \
67+ --subst-var-by TBB_VERSION "${version}" \
68+ --subst-var-by TBB_LIB_NAME "tbb"
69+ '';
3370
34− meta = {
71+ meta = with lib; {
3572 description = "Intel Thread Building Blocks C++ Library";
3673 homepage = "http://threadingbuildingblocks.org/";
3774 license = licenses.asl20;
@@ -43,7 +80,7 @@ with lib; stdenv.mkDerivation rec {
4380 represents a higher-level, task-based parallelism that abstracts platform
4481 details and threading mechanisms for scalability and performance.
4582 '';
46− platforms = with platforms; linux ++ darwin;
83+ platforms = platforms.unix;
4784 maintainers = with maintainers; [ thoughtpolice dizfer ];
4885 };
4986}
pkgs/development/libraries/tbb/glibc-struct-mallinfo.patchdeleted−43
@@ -1,43 +0,0 @@
1−From b577153a10c98f4e13405dc93ea2ab1a7b990e07 Mon Sep 17 00:00:00 2001
2−From: David Huffman <storedbox+alpine@outlook.com>
3−Date: Wed, 6 Jan 2016 07:09:30 -0500
4−Subject: [PATCH] hard-code glibc's definition of struct mallinfo
5−
6−---
7− src/tbbmalloc/proxy.h | 20 ++++++++++++++++++++
8− 1 file changed, 20 insertions(+)
9−
10−diff --git a/src/tbbmalloc/proxy.h b/src/tbbmalloc/proxy.h
11−index 781cadc..e1ea1ae 100644
12−--- a/src/tbbmalloc/proxy.h
13−+++ b/src/tbbmalloc/proxy.h
14−@@ -32,6 +32,26 @@
15−
16− #include <stddef.h>
17−
18−+// The following definition was taken from /usr/include/malloc.h as provided by
19−+// the glibc-devel-2.19-17.4.x86_64 package on openSUSE Leap 42.1; it is
20−+// made available under the GNU Lesser General Public License v2.1 or later.
21−+// See <https://www.gnu.org/licenses>.
22−+//
23−+// Copyright (C) 1996-2014 Free Software Foundation, Inc.
24−+struct mallinfo
25−+{
26−+ int arena; /* non-mmapped space allocated from system */
27−+ int ordblks; /* number of free chunks */
28−+ int smblks; /* number of fastbin blocks */
29−+ int hblks; /* number of mmapped regions */
30−+ int hblkhd; /* space in mmapped regions */
31−+ int usmblks; /* maximum total allocated space */
32−+ int fsmblks; /* space available in freed fastbin blocks */
33−+ int uordblks; /* total allocated space */
34−+ int fordblks; /* total free space */
35−+ int keepcost; /* top-most, releasable (via malloc_trim) space */
36−+};
37−+
38− extern "C" {
39− void * scalable_malloc(size_t size);
40− void * scalable_calloc(size_t nobj, size_t size);
41−--
42−2.6.2
43−