From 89deba2dadaef76367b29dafb51b576fd44a902e Mon Sep 17 00:00:00 2001 From: langfei Date: Tue, 8 Aug 2023 06:28:53 +0000 Subject: [PATCH] Adapts to gcc-12 and python-3.11 Signed-off-by: langfei --- ...ility-re-tweak-for-rhel6-use-functio.patch | 51 +++++++++++++++++++ ...ility-tweak-use-lambdas-instead-of-p.patch | 37 ++++++++++++++ ...ved-direct-access-to-PyFrameObject-m.patch | 33 ++++++++++++ systemtap.spec | 11 +++- 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 0001-gcc12-c-compatibility-re-tweak-for-rhel6-use-functio.patch create mode 100644 0001-gcc12-c-compatibility-tweak-use-lambdas-instead-of-p.patch create mode 100644 0001-python-3.11-removed-direct-access-to-PyFrameObject-m.patch diff --git a/0001-gcc12-c-compatibility-re-tweak-for-rhel6-use-functio.patch b/0001-gcc12-c-compatibility-re-tweak-for-rhel6-use-functio.patch new file mode 100644 index 0000000..20608e0 --- /dev/null +++ b/0001-gcc12-c-compatibility-re-tweak-for-rhel6-use-functio.patch @@ -0,0 +1,51 @@ +From f199d1982ef8a6c6d5c06c082d057b8793bcc6aa Mon Sep 17 00:00:00 2001 +From: Serhei Makarov +Date: Fri, 21 Jan 2022 18:21:46 -0500 +Subject: [PATCH] gcc12 c++ compatibility re-tweak for rhel6: use function + pointer instead of lambdas instead of ptr_fun<> + +Saving 2 lines in ltrim/rtrim is probably not a good reason to drop +compatibility with the RHEL6 system compiler. Actually declaring a +named function and passing the function pointer is compatible with +everything. +--- + util.cxx | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/util.cxx b/util.cxx +index e9286eca3..ad36259c9 100644 +--- a/util.cxx ++++ b/util.cxx +@@ -1757,21 +1757,24 @@ flush_to_stream (const string &fname, ostream &o) + return 1; // Failure + } + ++int ++not_isspace(unsigned char c) ++{ ++ return !std::isspace(c); ++} ++ + // trim from start (in place) + void + ltrim(std::string &s) + { +- s.erase(s.begin(), +- std::find_if(s.begin(), s.end(), +- [](unsigned char c) { return !std::isspace(c); })); ++ s.erase(s.begin(), std::find_if(s.begin(), s.end(), not_isspace)); + } + + // trim from end (in place) + void + rtrim(std::string &s) + { +- s.erase(std::find_if(s.rbegin(), s.rend(), +- [](unsigned char c) { return !std::isspace(c); }).base(), s.end()); ++ s.erase(std::find_if(s.rbegin(), s.rend(), not_isspace).base(), s.end()); + } + + // trim from both ends (in place) +-- +2.21.0.windows.1 + diff --git a/0001-gcc12-c-compatibility-tweak-use-lambdas-instead-of-p.patch b/0001-gcc12-c-compatibility-tweak-use-lambdas-instead-of-p.patch new file mode 100644 index 0000000..70a9f04 --- /dev/null +++ b/0001-gcc12-c-compatibility-tweak-use-lambdas-instead-of-p.patch @@ -0,0 +1,37 @@ +From 56c498d95c4749f15980da73b4933e7443b3f26c Mon Sep 17 00:00:00 2001 +From: Jonathan Wakely +Date: Tue, 18 Jan 2022 15:52:18 -0500 +Subject: [PATCH] gcc12 c++ compatibility tweak: use lambdas instead of + ptr_fun<> + +Even while stap is a c++11 code base, such cleanups make code +nicer to look at. +--- + util.cxx | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/util.cxx b/util.cxx +index c20f76003..e9286eca3 100644 +--- a/util.cxx ++++ b/util.cxx +@@ -1763,7 +1763,7 @@ ltrim(std::string &s) + { + s.erase(s.begin(), + std::find_if(s.begin(), s.end(), +- std::not1(std::ptr_fun(std::isspace)))); ++ [](unsigned char c) { return !std::isspace(c); })); + } + + // trim from end (in place) +@@ -1771,7 +1771,7 @@ void + rtrim(std::string &s) + { + s.erase(std::find_if(s.rbegin(), s.rend(), +- std::not1(std::ptr_fun(std::isspace))).base(), s.end()); ++ [](unsigned char c) { return !std::isspace(c); }).base(), s.end()); + } + + // trim from both ends (in place) +-- +2.21.0.windows.1 + diff --git a/0001-python-3.11-removed-direct-access-to-PyFrameObject-m.patch b/0001-python-3.11-removed-direct-access-to-PyFrameObject-m.patch new file mode 100644 index 0000000..e429d6f --- /dev/null +++ b/0001-python-3.11-removed-direct-access-to-PyFrameObject-m.patch @@ -0,0 +1,33 @@ +From 069e109c95d1afca17cd3781b39f220cf8b39978 Mon Sep 17 00:00:00 2001 +From: Stan Cox +Date: Wed, 13 Jul 2022 09:49:51 -0400 +Subject: [PATCH] python 3.11 removed direct access to PyFrameObject members + +Take into account the change in PyFrameObject definition to allow +building systemtap with python 3.11. Additional support for python +3.11 is forthcoming. +--- + python/HelperSDT/_HelperSDT.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/python/HelperSDT/_HelperSDT.c b/python/HelperSDT/_HelperSDT.c +index 967cb6077..4d287132e 100644 +--- a/python/HelperSDT/_HelperSDT.c ++++ b/python/HelperSDT/_HelperSDT.c +@@ -14,7 +14,13 @@ + // PR25841: ensure that the libHelperSDT.so file contains debuginfo + // for the tapset helper functions, so they don't have to look into libpython* + #include ++// python 3.11 removed direct access to PyFrameObject members ++// https://docs.python.org/3.11/whatsnew/3.11.html#c-api-changes ++#if PY_MAJOR_VERSION <= 3 && PY_MINOR_VERSION < 11 + PyFrameObject _dummy_frame; ++#else ++//PyFrameObject *_dummy_frame; ++#endif + #include + PyVarObject _dummy_var; + #include +-- +2.21.0.windows.1 + diff --git a/systemtap.spec b/systemtap.spec index 2f2ec93..892b67c 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -22,7 +22,7 @@ Name: systemtap Version: 4.5 -Release: 6 +Release: 7 Summary: Linux trace and probe tool License: GPLv2+ and Public Domain URL: http://sourceware.org/systemtap @@ -30,6 +30,9 @@ Source: https://sourceware.org/systemtap/ftp/releases/%{name}-%{version}.tar.gz Patch1: 0001-Add-init-type-cast-to-resolve-gcc-issue.patch Patch2: 0001-PR29094-Include-rpm-rpmcrypto.h-when-required.patch +Patch3: 0001-gcc12-c-compatibility-tweak-use-lambdas-instead-of-p.patch +Patch4: 0001-gcc12-c-compatibility-re-tweak-for-rhel6-use-functio.patch +Patch5: 0001-python-3.11-removed-direct-access-to-PyFrameObject-m.patch Patch9000: huawei-fix-py3example-script-run-fail.patch Patch9001: huawei-fix-py3example-script-run-fail2.patch @@ -462,6 +465,12 @@ exit 0 %{_mandir}/man[1378]/* %changelog +* Tue Aug 8 2023 langfei - 4.5-7 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Adapts to gcc 12 and python 3.11 + * Wed Jul 5 2023 langfei - 4.5-6 - Type:bugfix - CVE:NA