From b9acbf9befaf1b85ec42ad137394ebf42c185c37 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 12 Sep 2025 23:03:47 +0100 Subject: [PATCH] tbb_2022: vendor unmerged patches Unmerged PRs are not stable fetch targets. --- .../tbb_2022/fix-32-bit-powerpc-build.patch | 38 +++++++++++++++++++ pkgs/by-name/tb/tbb_2022/fix-musl-build.patch | 24 ++++++++++++ pkgs/by-name/tb/tbb_2022/package.nix | 22 ++++------- 3 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 pkgs/by-name/tb/tbb_2022/fix-32-bit-powerpc-build.patch create mode 100644 pkgs/by-name/tb/tbb_2022/fix-musl-build.patch diff --git a/pkgs/by-name/tb/tbb_2022/fix-32-bit-powerpc-build.patch b/pkgs/by-name/tb/tbb_2022/fix-32-bit-powerpc-build.patch new file mode 100644 index 000000000000..7cc8216153d0 --- /dev/null +++ b/pkgs/by-name/tb/tbb_2022/fix-32-bit-powerpc-build.patch @@ -0,0 +1,38 @@ +From c828ae47b8f4bea7736d2f9d05460e2b529c9d7d Mon Sep 17 00:00:00 2001 +From: John Paul Adrian Glaubitz +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 +--- + 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 ++int main() { ++ std::atomic w1; ++ std::atomic w2; ++ std::atomic w4; ++ std::atomic 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) diff --git a/pkgs/by-name/tb/tbb_2022/fix-musl-build.patch b/pkgs/by-name/tb/tbb_2022/fix-musl-build.patch new file mode 100644 index 000000000000..5a6700a86a24 --- /dev/null +++ b/pkgs/by-name/tb/tbb_2022/fix-musl-build.patch @@ -0,0 +1,24 @@ +From 493774eb57f9c424fc8907d137665e687861ad94 Mon Sep 17 00:00:00 2001 +From: Ismael Luceno +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 diff --git a/pkgs/by-name/tb/tbb_2022/package.nix b/pkgs/by-name/tb/tbb_2022/package.nix index 31af81c371c8..00fd6e3d9e8b 100644 --- a/pkgs/by-name/tb/tbb_2022/package.nix +++ b/pkgs/by-name/tb/tbb_2022/package.nix @@ -2,7 +2,6 @@ lib, stdenv, fetchFromGitHub, - fetchpatch, cmake, ninja, ctestCheckHook, @@ -24,25 +23,20 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-ASQPAGm5e4q7imvTVWlmj5ON4fGEao1L5m2C5wF7EhI="; }; + patches = [ + # + ./fix-musl-build.patch + + # + ./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;