Commit b9acbf9b authored by Emily's avatar Emily
Browse files

tbb_2022: vendor unmerged patches

Unmerged PRs are not stable fetch targets.
parent c240345f
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
From c828ae47b8f4bea7736d2f9d05460e2b529c9d7d Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Fri, 9 Dec 2022 12:36:11 +0100
Subject: [PATCH] Add cmake check for libatomic requirement when building with
 gcc (#980)

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
---
 cmake/compilers/GNU.cmake | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/cmake/compilers/GNU.cmake b/cmake/compilers/GNU.cmake
index cd76acfe1e..59f4e6934f 100644
--- a/cmake/compilers/GNU.cmake
+++ b/cmake/compilers/GNU.cmake
@@ -44,6 +44,22 @@ if (NOT MINGW)
     set(TBB_COMMON_LINK_LIBS dl)
 endif()
 
+# Check whether code with full atomics can be built without libatomic
+# see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358
+include(CheckCXXSourceCompiles)
+check_cxx_source_compiles("#include <atomic>
+int main() {
+  std::atomic<uint8_t> w1;
+  std::atomic<uint16_t> w2;
+  std::atomic<uint32_t> w4;
+  std::atomic<uint64_t> w8;
+  return ++w1 + ++w2 + ++w4 + ++w8;
+}" TBB_BUILDS_WITHOUT_LIBATOMIC)
+
+if(NOT TBB_BUILDS_WITHOUT_LIBATOMIC)
+   set(TBB_COMMON_LINK_LIBS ${TBB_COMMON_LINK_LIBS} atomic)
+endif()
+
 # Ignore -Werror set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled.
 if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
     tbb_remove_compile_flag(-Werror)
+24 −0
Original line number Diff line number Diff line
From 493774eb57f9c424fc8907d137665e687861ad94 Mon Sep 17 00:00:00 2001
From: Ismael Luceno <ismael@iodev.co.uk>
Date: Fri, 9 Sep 2022 16:18:18 +0200
Subject: [PATCH] Fix build against musl libc

Probably MALLOC_UNIXLIKE_OVERLOAD_ENABLED only works with glibc, so use
__GLIBC__ in addition to __linux__ to define it.
---
 src/tbbmalloc_proxy/proxy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tbbmalloc_proxy/proxy.h b/src/tbbmalloc_proxy/proxy.h
index 5f0133f9e0..ba1a07c396 100644
--- a/src/tbbmalloc_proxy/proxy.h
+++ b/src/tbbmalloc_proxy/proxy.h
@@ -17,7 +17,7 @@
 #ifndef _TBB_malloc_proxy_H_
 #define _TBB_malloc_proxy_H_
 
-#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__
+#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED (__linux__ && __GLIBC__)
 #define MALLOC_ZONE_OVERLOAD_ENABLED __APPLE__
 
 // MALLOC_UNIXLIKE_OVERLOAD_ENABLED depends on MALLOC_CHECK_RECURSION stuff
+8 −14
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
  lib,
  stdenv,
  fetchFromGitHub,
  fetchpatch,
  cmake,
  ninja,
  ctestCheckHook,
@@ -24,25 +23,20 @@ stdenv.mkDerivation (finalAttrs: {
    hash = "sha256-ASQPAGm5e4q7imvTVWlmj5ON4fGEao1L5m2C5wF7EhI=";
  };

  patches = [
    # <https://github.com/uxlfoundation/oneTBB/pull/899>
    ./fix-musl-build.patch

    # <https://github.com/uxlfoundation/oneTBB/pull/987>
    ./fix-32-bit-powerpc-build.patch
  ];

  nativeBuildInputs = [
    cmake
    ninja
    ctestCheckHook
  ];

  patches = [
    # Fix musl build from https://github.com/oneapi-src/oneTBB/pull/899
    (fetchpatch {
      url = "https://patch-diff.githubusercontent.com/raw/oneapi-src/oneTBB/pull/899.patch";
      hash = "sha256-kU6RRX+sde0NrQMKlNtW3jXav6J4QiVIUmD50asmBPU=";
    })
    # Fix 32-bit PowerPC build
    (fetchpatch {
      url = "https://github.com/uxlfoundation/oneTBB/pull/987/commits/c828ae47b8f4bea7736d2f9d05460e2b529c9d7d.patch";
      hash = "sha256-faNiVdHRIkmavufDHQQ8vHppvdahZ7yhJVL3bOwNTFg=";
    })
  ];

  doCheck = true;

  dontUseNinjaCheck = true;