Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
5678a69bc3
!62 [sync] PR-60: Add sw_64 support
From: @openeuler-sync-bot 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2025-03-05 06:47:05 +00:00
maqi
d18aea5979 Add sw_64 support
(cherry picked from commit 08881aa8f7c7d1a82c3d2b345a83ba9935b960ff)
2025-03-05 11:55:40 +08:00
openeuler-ci-bot
9e16ce6a45
!55 riscv64: 增加--enable-frame-pointers配置选项
From: @laokz 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2024-04-24 09:08:56 +00:00
laokz
1d913d802a
riscv64: force --enable-frame-pointers configure option
Configure script detect -fno-omit-frame-pointer and -momit-leaf-frame-pointer
compile options both together, see,
  https://github.com/gperftools/gperftools/blob/master/configure.ac#L211

For RISC-V, until gcc14 -momit-leaf-frame-pointer was not supported, see,
  https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=39663298b5934831a0125e12f113ebd83248c3be

We use gcc12, thus the detection would be failed and no fp used in the code,
and then stacktrace_unittest's generic_fp test failed. Add --enable-frame-pointers
configure option can force -fno-omit-frame-pointer alone been used.

Sigend-off-by: laokz <zhangkai@iscas.ac.cn>
2024-04-21 10:41:22 +00:00
openeuler-ci-bot
b8bfb3ff2b
!53 Upgrade to 2.15
From: @ni-cunshu 
Reviewed-by: @wangbin224 
Signed-off-by: @wangbin224
2024-02-07 03:11:00 +00:00
Ni Cunshu
e55870e020 Upgrade to 2.15
Signed-off-by: Ni Cunshu <nicunshu@huawei.com>
2024-02-06 21:26:37 +08:00
openeuler-ci-bot
f01e51c651
!46 Resolving loongarch64 build error
From: @dpdwaj 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2023-07-14 07:46:11 +00:00
doupengda
6f2f66bd01 Resolving loongarch64 build error 2023-07-12 14:35:05 +08:00
openeuler-ci-bot
38e26b3eb2
!35 License compliance rectification
From: @lauk001 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2022-08-05 01:01:23 +00:00
lauk001
039a5230c6 License compliance rectification 2022-08-04 14:51:45 +08:00
8 changed files with 214 additions and 117 deletions

160
add-sw_64-support.patch Normal file
View File

@ -0,0 +1,160 @@
From a59f75b1951100a667db155a279f0a3cf6236c9a Mon Sep 17 00:00:00 2001
From: maqi <maqi@uniontech.com>
Date: Thu, 16 Jan 2025 17:05:35 +0800
Subject: [PATCH] add sw_64 support
---
config.guess | 3 +++
config.sub | 1 +
src/base/basictypes.h | 2 ++
src/base/linuxthreads.cc | 2 +-
src/getpc-inl.h | 16 +++++++++++++++-
src/stacktrace.cc | 19 +++++++++++++++++++
src/stacktrace_generic_fp-inl.h | 2 ++
src/tcmalloc.cc | 1 +
8 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/config.guess b/config.guess
index 7f76b62..fd3524f 100755
--- a/config.guess
+++ b/config.guess
@@ -1143,6 +1143,9 @@ EOF
sparc:Linux:*:* | sparc64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
+ sw_64*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
tile*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
diff --git a/config.sub b/config.sub
index dba16e8..c6a3b0b 100755
--- a/config.sub
+++ b/config.sub
@@ -1267,6 +1267,7 @@ case $cpu-$vendor in
| sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
| spu \
+ | sw_64 \
| tahoe \
| thumbv7* \
| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
diff --git a/src/base/basictypes.h b/src/base/basictypes.h
index 1f3b47b..595013f 100644
--- a/src/base/basictypes.h
+++ b/src/base/basictypes.h
@@ -386,6 +386,8 @@ class AssignAttributeStartEnd {
# define CACHELINE_ALIGNED __attribute__((aligned(64)))
# elif defined(__loongarch64)
# define CACHELINE_ALIGNED __attribute__((aligned(64)))
+# elif defined(__sw_64)
+# define CACHELINE_ALIGNED __attribute__((aligned(64)))
# else
# error Could not determine cache line length - unknown architecture
# endif
diff --git a/src/base/linuxthreads.cc b/src/base/linuxthreads.cc
index d477385..e6602ce 100644
--- a/src/base/linuxthreads.cc
+++ b/src/base/linuxthreads.cc
@@ -158,7 +158,7 @@ static int local_clone (int (*fn)(void *), void *arg) {
clone_stack_size = ~clone_stack_size + 1;
}
-#if defined(__i386__) || defined(__x86_64__) || defined(__riscv) || defined(__arm__) || defined(__aarch64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__riscv) || defined(__arm__) || defined(__aarch64__) || defined(__sw_64__)
// Sanity check code above. We know that those arch-es grow stack to
// lower addresses.
CHECK(grows_to_low);
diff --git a/src/getpc-inl.h b/src/getpc-inl.h
index 615e238..404fae6 100644
--- a/src/getpc-inl.h
+++ b/src/getpc-inl.h
@@ -119,6 +119,18 @@ struct get_4e9b682d<U, P, void_t<decltype(((U*){})->uc_mcontext.__pc)>> : public
}
};
+// Linux/sw_64
+template <class U, class P, class = void>
+struct get_4a81fbc6 : public P {
+};
+template <class U, class P>
+struct get_4a81fbc6<U, P, void_t<decltype(((U*){})->uc_mcontext.sc_pc)>> : public P {
+ static void* Get(const U* uc) {
+ // Linux/sw_64
+ return (void*)(uc->uc_mcontext.sc_pc);
+ }
+};
+
// Linux/{mips,aarch64}
template <class U, class P, class = void>
struct get_b94b7246 : public P {
@@ -378,8 +390,10 @@ inline void* RawUCToPC(const ucontext_t* uc) {
using g_d0eeceae = get_d0eeceae<ucontext_t, g_a81f6801>;
// Linux/{mips,aarch64}
using g_b94b7246 = get_b94b7246<ucontext_t, g_d0eeceae>;
+ // Linux/sw_64
+ using g_4a81fbc6 = get_4a81fbc6<ucontext_t, g_b94b7246>;
// Linux/loongarch64
- using g_4e9b682d = get_4e9b682d<ucontext_t, g_b94b7246>;
+ using g_4e9b682d = get_4e9b682d<ucontext_t, g_4a81fbc6>;
// Linux/ia64
using g_8fda99d3 = get_8fda99d3<ucontext_t, g_4e9b682d>;
// Linux/amd64 (with #ifdef REG_RIP)
diff --git a/src/stacktrace.cc b/src/stacktrace.cc
index b1fd04b..500cffb 100644
--- a/src/stacktrace.cc
+++ b/src/stacktrace.cc
@@ -144,6 +144,25 @@ struct GetStackImplementation {
#define HAVE_GST_generic_fp_unsafe
#endif
+#if defined(__GNUC__) && defined(__sw_64__)
+#define STACKTRACE_INL_HEADER "stacktrace_generic_fp-inl.h"
+#define GST_SUFFIX generic_fp
+#include "stacktrace_impl_setup-inl.h"
+#undef GST_SUFFIX
+#undef STACKTRACE_INL_HEADER
+#define HAVE_GST_generic_fp
+
+#undef TCMALLOC_UNSAFE_GENERIC_FP_STACKTRACE
+#define TCMALLOC_UNSAFE_GENERIC_FP_STACKTRACE 1
+
+#define STACKTRACE_INL_HEADER "stacktrace_generic_fp-inl.h"
+#define GST_SUFFIX generic_fp_unsafe
+#include "stacktrace_impl_setup-inl.h"
+#undef GST_SUFFIX
+#undef STACKTRACE_INL_HEADER
+#define HAVE_GST_generic_fp_unsafe
+#endif
+
#if defined(__ppc__) || defined(__PPC__)
#if defined(__linux__)
#define STACKTRACE_INL_HEADER "stacktrace_powerpc-linux-inl.h"
diff --git a/src/stacktrace_generic_fp-inl.h b/src/stacktrace_generic_fp-inl.h
index 12f93bb..e2da11b 100644
--- a/src/stacktrace_generic_fp-inl.h
+++ b/src/stacktrace_generic_fp-inl.h
@@ -319,6 +319,8 @@ static int GET_STACK_TRACE_OR_FRAMES {
#elif __linux__ && __arm__
// Note: arm's frame pointer support is borked in recent GCC-s.
SETUP_FRAME(&uc->uc_mcontext.arm_pc, uc->uc_mcontext.arm_fp);
+#elif __linux__ && __sw_64__
+ SETUP_FRAME(&uc->uc_mcontext.sc_pc,uc->uc_mcontext.sc_regs[15]);
#elif __linux__ && __i386__
SETUP_FRAME(&uc->uc_mcontext.gregs[REG_EIP], uc->uc_mcontext.gregs[REG_EBP]);
#elif __linux__ && __x86_64__
diff --git a/src/tcmalloc.cc b/src/tcmalloc.cc
index dcb9460..740171b 100644
--- a/src/tcmalloc.cc
+++ b/src/tcmalloc.cc
@@ -171,6 +171,7 @@ DECLARE_int64(tcmalloc_heap_limit_mb);
// jump. I am not able to reproduce that anymore.
#if !defined(__i386__) && !defined(__x86_64__) && \
!defined(__ppc__) && !defined(__PPC__) && \
+ !defined(__sw_64__) && \
!defined(__aarch64__) && !defined(__mips__) && !defined(__arm__) && !defined(__loongarch64)
#undef TCMALLOC_NO_ALIASES
#define TCMALLOC_NO_ALIASES
--
2.33.0

View File

@ -1,33 +0,0 @@
From 85158d45ec66c34f5903a15c3b74600a925703ef Mon Sep 17 00:00:00 2001
From: zhangyiru <zhanguyiru@huawei.com>
Date: Thu, 14 Oct 2021 22:16:15 +0800
Subject: [PATCH] avoid display problem if memleak exceeds range of int
if memleak exceeds range of int, heap checker result is incorrect, so
change it to size_t
---
src/heap-profile-table.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/heap-profile-table.cc b/src/heap-profile-table.cc
index c3ce41c..1001fb3 100644
--- a/src/heap-profile-table.cc
+++ b/src/heap-profile-table.cc
@@ -517,7 +517,7 @@ HeapProfileTable::Snapshot* HeapProfileTable::NonLiveSnapshot(
// Information kept per unique bucket seen
struct HeapProfileTable::Snapshot::Entry {
int count;
- int bytes;
+ size_t bytes;
Bucket* bucket;
Entry() : count(0), bytes(0) { }
@@ -592,7 +592,7 @@ void HeapProfileTable::Snapshot::ReportLeaks(const char* checker_name,
for (int i = 0; i < to_report; i++) {
const Entry& e = entries[i];
base::RawPrinter printer(buffer, kBufSize);
- printer.Printf("Leak of %d bytes in %d objects allocated from:\n",
+ printer.Printf("Leak of %zu bytes in %d objects allocated from:\n",
e.bytes, e.count);
for (int j = 0; j < e.bucket->depth; j++) {
const void* pc = e.bucket->stack[j];
--
2.27.0

Binary file not shown.

BIN
gperftools-2.15.tar.gz Normal file

Binary file not shown.

View File

@ -1,18 +1,17 @@
Name: gperftools
Version: 2.10
Release: 1
Version: 2.15
Release: 3
Summary: high-performance malloc and performance analysis tools
License: BSD
License: BSD-3-Clause
URL: https://github.com/gperftools/gperftools
Source0: https://github.com/gperftools/gperftools/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz
patch1: gperftools-generic-dynamic-tls.patch
Patch9000: issue-1122-fix-bus-error-on-aarch64.patch
#https://github.com/gperftools/gperftools/issues/1309
#Patch9001: skip-arm-in-stacktrace_unittest.patch
Patch9000: skip-arm-in-stacktrace_unittest.patch
#https://github.com/gperftools/gperftools/issues/890
Patch9001: skip-heapchecker-in-arm-arch.patch
Patch9002: avoid-exceed-int-range.patch
Patch9002: add-sw_64-support.patch
BuildRequires: autoconf automake gcc-c++
BuildRequires: libtool libunwind-devel perl-generators
@ -70,6 +69,9 @@ CXXFLAGS=`echo $RPM_OPT_FLAGS -fno-strict-aliasing -Wno-unused-local-typedefs -D
%configure \
%ifarch s390x aarch64
--disable-general-dynamic-tls \
%endif
%ifarch riscv64
--enable-frame-pointers \
%endif
--disable-dynamic-sized-delete-support \
@ -107,6 +109,22 @@ LD_LIBRARY_PATH=./.libs make check
%{_mandir}/man1/*.1.gz
%changelog
* Mon Mar 03 2025 maqi <maqi@uniontech.com> - 2.15-3
- Add sw_64 support
* Mon Apr 22 2024 laokz <zhangkai@iscas.ac.cn> - 2.15-2
- riscv64: force --enable-frame-pointers due to unsupported
-momit-leaf-frame-pointer compile option until gcc14
* Mon Feb 5 2024 nicunshu <nicunshu@huawei.com> - 2.15-1
- Upgrade tp 2.15
* Wed Jul 12 2023 doupengda <doupengda@loongson.cn> - 2.10-3
- Resolving loongarch64 build error
* Wed Aug 03 2022 liukuo <liukuo@kylinos.cn> - 2.10-2
- License compliance rectification
* Tue Jul 19 2022 Qingqing Li <liqingqing3@huawei.com> - 2.10-1
- upgrade to 2.10

View File

@ -1,42 +0,0 @@
From 42dbe9e2ced74ae7f0f3b70daabf634edf44d3d3 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Thu, 13 Jun 2019 23:16:43 +0800
Subject: [PATCH] issue-1122: fix bus error on aarch64
According to the ARMv8 Instruction Set Overview, among other documents,
"... if SP is used as the base register then the value of the stack
pointer prior to adding any offset must be quadword (16 byte) aligned,
or else a stack alignment exception will be generated.". So, we pass
the child_stack 16 byte aligned to sys_clone.
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
---
src/base/linuxthreads.cc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/base/linuxthreads.cc b/src/base/linuxthreads.cc
index 891e70c..00b1ea3 100644
--- a/src/base/linuxthreads.cc
+++ b/src/base/linuxthreads.cc
@@ -105,6 +105,7 @@ static int local_clone (int (*fn)(void *), void *arg, ...)
#define CLONE_STACK_SIZE 4096
#endif
+#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
static int local_clone (int (*fn)(void *), void *arg, ...) {
/* Leave 4kB of gap between the callers stack and the new clone. This
* should be more than sufficient for the caller to call waitpid() until
@@ -120,7 +121,9 @@ static int local_clone (int (*fn)(void *), void *arg, ...) {
* is being debugged. This is OK and the error code will be reported
* correctly.
*/
- return sys_clone(fn, (char *)&arg - CLONE_STACK_SIZE,
+ void *child_stack = (void *)ALIGN(((unsigned long)&arg - CLONE_STACK_SIZE),
+ 16);
+ return sys_clone(fn, child_stack,
CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_UNTRACED, arg, 0, 0, 0);
}
--
1.7.12.4

View File

@ -8,27 +8,23 @@ function is not affected, so skip it.
Signed-off-by: zhangyiru <zhangyiru3@huawei.com>
---
src/tests/stacktrace_unittest.cc | 5 +++++
1 file changed, 5 insertions(+)
src/tests/stacktrace_unittest.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/tests/stacktrace_unittest.cc b/src/tests/stacktrace_unittest.cc
index e55a632..85c0bcd 100644
index 55cb054..85e5916 100644
--- a/src/tests/stacktrace_unittest.cc
+++ b/src/tests/stacktrace_unittest.cc
@@ -285,8 +285,13 @@ void ATTRIBUTE_NOINLINE CheckStackTrace(int i) {
//-----------------------------------------------------------------------//
@@ -376,6 +376,10 @@ const char* TEST_bump_stacktrace_implementation(const char*);
}
int main(int argc, char ** argv) {
+#if defined(__x86_64__)
CheckStackTrace(0);
printf("PASS\n");
+#else
int main(int argc, char** argv) {
+#if defined(__aarch64__)
+ printf("ARM SKIP\n");
+ exit(77);
+#endif
#if TEST_UCONTEXT_BITS
leaf_capture_fn = CaptureLeafUContext;
if (argc > 1 && strcmp(argv[1], "--skip-ucontext") == 0) {
argc--;
argv--;
--
1.8.3.1
2.33.0

View File

@ -9,8 +9,8 @@ testcases.
Signed-off-by: zhangyiru <zhangyiru3@huawei.com>
---
src/tests/heap-checker-death_unittest.sh | 5 +++++
src/tests/heap-checker_unittest.sh | 5 +++++
2 files changed, 10 insertions(+)
src/tests/heap-checker_unittest.cc | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/src/tests/heap-checker-death_unittest.sh b/src/tests/heap-checker-death_unittest.sh
index 69db0c9..deac493 100755
@ -19,7 +19,7 @@ index 69db0c9..deac493 100755
@@ -34,6 +34,11 @@
# Run the heap checker unittest in a mode where it is supposed to crash and
# return an error if it doesn't.
+arch=$(uname -r | grep x86)
+if [[ $arch == "" ]]; then
+# skip this test, libtool define EXIT_SKIP=77
@ -28,22 +28,20 @@ index 69db0c9..deac493 100755
# We expect BINDIR to be set in the environment.
# If not, we set it to some reasonable value.
BINDIR="${BINDIR:-.}"
diff --git a/src/tests/heap-checker_unittest.sh b/src/tests/heap-checker_unittest.sh
index 3c9c0e9..7c27044 100755
--- a/src/tests/heap-checker_unittest.sh
+++ b/src/tests/heap-checker_unittest.sh
@@ -37,6 +37,11 @@
# and heap checker via environment variables. This test makes sure
# they all play well together.
+arch=$(uname -r | grep x86)
+if [[ $arch == "" ]]; then
+# skip this test, libtool define EXIT_SKIP=77
+ exit 77
+fi
# We expect BINDIR and PPROF_PATH to be set in the environment.
# If not, we set them to some reasonable values
BINDIR="${BINDIR:-.}"
--
2.27.0
diff --git a/src/tests/heap-checker_unittest.cc b/src/tests/heap-checker_unittest.cc
index 9a7086c..be483fe 100644
--- a/src/tests/heap-checker_unittest.cc
+++ b/src/tests/heap-checker_unittest.cc
@@ -1412,6 +1412,10 @@ bool spawn_subtest(const char* mode, char** argv) {
}
int main(int argc, char** argv) {
+#if defined(__aarch64__)
+ printf("ARM SKIP\n");
+ exit(77);
+#endif
if (getenv("HEAPCHECK") == nullptr) {
CHECK(!HeapLeakChecker::IsActive());
--
2.33.0