Patch for oneTBB (#2036372)

Update FindTBB.cmake to look in the new version.h header.

Fix the incorrect allocator used with tbb::concurrent_hash_map.  Define
a tbb_hash_compare specialization for std::pair to cope with the
deprecated tbb_hasher function being removed.

Adjust tbb_hash_compare specialization to account for TBB 2021.x
defining it in a different namespace.
This commit is contained in:
Jonathan Wakely 2023-06-27 22:37:31 +01:00
parent df818674e3
commit afaa35c98c
2 changed files with 95 additions and 1 deletions

View File

@ -2,7 +2,7 @@ Summary: An API for Run-time Code Generation
License: LGPLv2+ License: LGPLv2+
Name: dyninst Name: dyninst
Group: Development/Libraries Group: Development/Libraries
Release: 4%{?dist} Release: 5%{?dist}
URL: http://www.dyninst.org URL: http://www.dyninst.org
Version: 12.2.0 Version: 12.2.0
ExclusiveArch: %{ix86} x86_64 ppc64le aarch64 ExclusiveArch: %{ix86} x86_64 ppc64le aarch64
@ -14,6 +14,7 @@ Source1: https://github.com/dyninst/testsuite/archive/%{__testsuite_version}/tes
Patch1: dwarf-error.patch Patch1: dwarf-error.patch
Patch2: cmdline.patch Patch2: cmdline.patch
Patch3: rhbz2173030.patch Patch3: rhbz2173030.patch
Patch4: onetbb.patch
%global dyninst_base dyninst-%{version} %global dyninst_base dyninst-%{version}
%global testsuite_base testsuite-%{__testsuite_version} %global testsuite_base testsuite-%{__testsuite_version}
@ -91,6 +92,7 @@ popd
pushd %{dyninst_base} pushd %{dyninst_base}
%patch3 -p1 %patch3 -p1
%patch4 -p1
popd popd
# cotire seems to cause non-deterministic gcc errors # cotire seems to cause non-deterministic gcc errors
@ -193,6 +195,9 @@ find %{buildroot}%{_libdir}/dyninst/testsuite/ \
%attr(644,root,root) %{_libdir}/dyninst/testsuite/*.a %attr(644,root,root) %{_libdir}/dyninst/testsuite/*.a
%changelog %changelog
* Tue Jun 27 2023 Jonathan Wakely <jwakely@fedoraproject.org> - 12.2.0-5
- Patch for oneTBB (#2036372)
* Thu Feb 23 2023 Frank Ch. Eigler <fche@redhat.com> - 12.2.0-4 * Thu Feb 23 2023 Frank Ch. Eigler <fche@redhat.com> - 12.2.0-4
- rhbz2173030: ftbfs with gcc 13 - rhbz2173030: ftbfs with gcc 13

89
onetbb.patch Normal file
View File

@ -0,0 +1,89 @@
--- dyninst-12.2.0/cmake/Modules/FindTBB.cmake~ 2023-06-27 22:52:25.396598265 +0100
+++ dyninst-12.2.0/cmake/Modules/FindTBB.cmake 2023-06-27 22:52:27.776601825 +0100
@@ -154,7 +154,8 @@
if(TBB_INCLUDE_DIRS)
# Starting in 2020.1.1, tbb_stddef.h is replaced by version.h
set(_version_files "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h"
- "${TBB_INCLUDE_DIRS}/tbb/version.h")
+ "${TBB_INCLUDE_DIRS}/tbb/version.h"
+ "${TBB_INCLUDE_DIRS}/oneapi/tbb/version.h")
foreach(f IN ITEMS ${_version_files})
if(EXISTS ${f})
set(_version_file ${f})
--- dyninst-12.2.0/common/h/concurrent.h~ 2023-06-27 23:31:35.971166585 +0100
+++ dyninst-12.2.0/common/h/concurrent.h 2023-06-27 23:32:31.889253848 +0100
@@ -41,6 +41,22 @@
#include <tbb/concurrent_vector.h>
#include <tbb/concurrent_queue.h>
+#if __has_include(<tbb/version.h>)
+#include <tbb/version.h>
+#if TBB_INTERFACE_VERSION_MAJOR >= 12
+// oneTBB version of tbb_hash_compare doesn't work for std::pair.
+template<typename T, typename U>
+struct tbb::tbb_hash_compare<std::pair<T, U>> {
+ static size_t hash(const std::pair<T, U>& p) {
+ return tbb_hash_compare<T>().hash(p.first) ^ tbb_hash_compare<U>().hash(p.second);
+ }
+ static bool equal(const std::pair<T, U>& p1, const std::pair<T, U>& p2) {
+ return p1 == p2;
+ }
+};
+#endif
+#endif
+
namespace Dyninst {
namespace dyn_c_annotations {
@@ -54,10 +70,10 @@
template<typename K, typename V>
class dyn_c_hash_map : protected tbb::concurrent_hash_map<K, V,
- tbb::tbb_hash_compare<K>, std::allocator<std::pair<K,V>>> {
+ tbb::tbb_hash_compare<K>, std::allocator<std::pair<const K,V>>> {
typedef tbb::concurrent_hash_map<K, V,
- tbb::tbb_hash_compare<K>, std::allocator<std::pair<K,V>>> base;
+ tbb::tbb_hash_compare<K>, std::allocator<std::pair<const K,V>>> base;
public:
using typename base::value_type;
using typename base::mapped_type;
--- dyninst-12.2.0/symtabAPI/src/dwarfWalker.h~ 2023-06-27 23:49:03.290956830 +0100
+++ dyninst-12.2.0/symtabAPI/src/dwarfWalker.h 2023-06-28 09:12:36.672398326 +0100
@@ -35,22 +35,20 @@
}
}
-namespace tbb {
- using namespace Dyninst::SymtabAPI;
- template<>
- struct tbb_hash_compare<type_key> {
- static size_t hash(const type_key& k) {
- size_t seed = 0;
- boost::hash_combine(seed, k.off);
- boost::hash_combine(seed, k.file);
- boost::hash_combine(seed, static_cast<void *>(k.m));
- return seed;
- }
- static bool equal(const type_key& k1, const type_key& k2) {
- return (k1.off==k2.off && k1.file==k2.file && k1.m==k2.m);
- }
- };
-}
+template<>
+struct tbb::tbb_hash_compare<Dyninst::SymtabAPI::type_key> {
+ using type_key = Dyninst::SymtabAPI::type_key;
+ static size_t hash(const type_key& k) {
+ size_t seed = 0;
+ boost::hash_combine(seed, k.off);
+ boost::hash_combine(seed, k.file);
+ boost::hash_combine(seed, static_cast<void *>(k.m));
+ return seed;
+ }
+ static bool equal(const type_key& k1, const type_key& k2) {
+ return (k1.off==k2.off && k1.file==k2.file && k1.m==k2.m);
+ }
+};
namespace Dyninst {
namespace SymtabAPI {