From 8f8fe9f62cc030aa1b6ca146bce014f37e2aed4e Mon Sep 17 00:00:00 2001 From: "taifu.gc" Date: Sun, 18 Dec 2022 15:20:39 +0800 Subject: [PATCH 1/5] Add loongarch support patch --- 1000-anolis-gc-7.6.4-add-loongarch.patch | 77 ++++++++++++++++++++++++ gc.spec | 1 + 2 files changed, 78 insertions(+) create mode 100644 1000-anolis-gc-7.6.4-add-loongarch.patch diff --git a/1000-anolis-gc-7.6.4-add-loongarch.patch b/1000-anolis-gc-7.6.4-add-loongarch.patch new file mode 100644 index 0000000..37343dc --- /dev/null +++ b/1000-anolis-gc-7.6.4-add-loongarch.patch @@ -0,0 +1,77 @@ +diff -Nurp gc-7.6.4.orig/configure.ac gc-7.6.4/configure.ac +--- gc-7.6.4.orig/configure.ac 2018-01-26 13:16:17.000000000 +0000 ++++ gc-7.6.4/configure.ac 2021-01-19 02:48:12.066406250 +0000 +@@ -184,7 +184,7 @@ case "$THREADS" in + AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,) + case "$host" in + x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* \ +- | x86_64-*-linux* | alpha-*-linux* | powerpc*-*-linux* | sparc*-*-linux*) ++ | x86_64-*-linux* | alpha-*-linux* | powerpc*-*-linux* | sparc*-*-linux* | loongarch*) + AC_DEFINE(GC_LINUX_THREADS) + AC_DEFINE(_REENTRANT) + if test "${enable_parallel_mark}" != no; then +diff -Nurp gc-7.6.4.orig/include/private/gcconfig.h gc-7.6.4/include/private/gcconfig.h +--- gc-7.6.4.orig/include/private/gcconfig.h 2021-01-08 06:32:07.746093750 +0000 ++++ gc-7.6.4/include/private/gcconfig.h 2021-01-19 02:47:16.933593750 +0000 +@@ -182,6 +182,10 @@ + # define VAX + # define mach_type_known + # endif ++# if defined(__loongarch64) ++# define LOONGARCH64 ++# define mach_type_known ++# endif + # if defined(mips) || defined(__mips) || defined(_mips) + # define MIPS + # if defined(nec_ews) || defined(_nec_ews) +@@ -450,6 +454,10 @@ + # define AARCH64 + # define mach_type_known + # endif ++# if defined(FREEBSD) && (defined(__loongarch64) ) ++# define LOONGARCH64 ++# define mach_type_known ++# endif + # if defined(FREEBSD) && (defined(mips) || defined(__mips) || defined(_mips)) + # define MIPS + # define mach_type_known +@@ -1624,6 +1632,26 @@ + # define STACKBOTTOM ((ptr_t)0xfffff000) /* for Encore */ + # endif + ++# ifdef LOONGARCH64 ++# define MACH_TYPE "LOONGARCH64" ++# ifdef LINUX ++# define OS_TYPE "LINUX" ++# define DYNAMIC_LOADING ++ extern int _end[]; ++# pragma weak __data_start ++ extern int __data_start[]; ++# define DATASTART ((ptr_t)(__data_start)) ++# define DATAEND ((ptr_t)(_end)) ++# define CPP_WORDSZ 64 ++# define ALIGNMENT (64/8) ++# ifndef HBLKSIZE ++# define HBLKSIZE 4096 ++# endif ++# define LINUX_STACKBOTTOM ++# endif ++# endif ++ ++ + # ifdef MIPS + # define MACH_TYPE "MIPS" + # ifdef LINUX +diff -Nurp gc-7.6.4.orig/os_dep.c gc-7.6.4/os_dep.c +--- gc-7.6.4.orig/os_dep.c 2018-01-26 13:16:17.000000000 +0000 ++++ gc-7.6.4/os_dep.c 2021-01-19 02:47:16.937500000 +0000 +@@ -3166,7 +3166,7 @@ GC_API GC_push_other_roots_proc GC_CALL + # ifndef SEGV_ACCERR + # define SEGV_ACCERR 2 + # endif +-# if defined(AARCH64) || defined(ARM32) || defined(MIPS) ++# if defined(AARCH64) || defined(ARM32) || defined(MIPS) || defined(LOONGARCH64) + # define CODE_OK (si -> si_code == SEGV_ACCERR) + # elif defined(POWERPC) + # define AIM /* Pretend that we're AIM. */ + diff --git a/gc.spec b/gc.spec index 98cfd6e..54f42b9 100644 --- a/gc.spec +++ b/gc.spec @@ -15,6 +15,7 @@ Source0: http://www.hboehm.info/gc/gc_source/gc-%{version}%{?pre}.tar.gz ## downstream patches # https://bugzilla.redhat.com/show_bug.cgi?id=1551671 Patch100: gc-7.6.4-dont_disable_exceptions.patch +Patch1000: 1000-anolis-gc-7.6.4-add-loongarch.patch BuildRequires: automake libtool BuildRequires: gcc-c++ -- Gitee From fa9cf4622229773b593b48874bb36b52178c206f Mon Sep 17 00:00:00 2001 From: "taifu.gc" Date: Sun, 18 Dec 2022 16:55:35 +0800 Subject: [PATCH 2/5] test --- 1000-anolis-gc-7.6.4-add-loongarch.patch | 90 ++++-------------------- 1 file changed, 13 insertions(+), 77 deletions(-) diff --git a/1000-anolis-gc-7.6.4-add-loongarch.patch b/1000-anolis-gc-7.6.4-add-loongarch.patch index 37343dc..b6a2d96 100644 --- a/1000-anolis-gc-7.6.4-add-loongarch.patch +++ b/1000-anolis-gc-7.6.4-add-loongarch.patch @@ -1,77 +1,13 @@ -diff -Nurp gc-7.6.4.orig/configure.ac gc-7.6.4/configure.ac ---- gc-7.6.4.orig/configure.ac 2018-01-26 13:16:17.000000000 +0000 -+++ gc-7.6.4/configure.ac 2021-01-19 02:48:12.066406250 +0000 -@@ -184,7 +184,7 @@ case "$THREADS" in - AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,) - case "$host" in - x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* \ -- | x86_64-*-linux* | alpha-*-linux* | powerpc*-*-linux* | sparc*-*-linux*) -+ | x86_64-*-linux* | alpha-*-linux* | powerpc*-*-linux* | sparc*-*-linux* | loongarch*) - AC_DEFINE(GC_LINUX_THREADS) - AC_DEFINE(_REENTRANT) - if test "${enable_parallel_mark}" != no; then -diff -Nurp gc-7.6.4.orig/include/private/gcconfig.h gc-7.6.4/include/private/gcconfig.h ---- gc-7.6.4.orig/include/private/gcconfig.h 2021-01-08 06:32:07.746093750 +0000 -+++ gc-7.6.4/include/private/gcconfig.h 2021-01-19 02:47:16.933593750 +0000 -@@ -182,6 +182,10 @@ - # define VAX - # define mach_type_known - # endif -+# if defined(__loongarch64) -+# define LOONGARCH64 -+# define mach_type_known -+# endif - # if defined(mips) || defined(__mips) || defined(_mips) - # define MIPS - # if defined(nec_ews) || defined(_nec_ews) -@@ -450,6 +454,10 @@ - # define AARCH64 - # define mach_type_known - # endif -+# if defined(FREEBSD) && (defined(__loongarch64) ) -+# define LOONGARCH64 -+# define mach_type_known -+# endif - # if defined(FREEBSD) && (defined(mips) || defined(__mips) || defined(_mips)) - # define MIPS - # define mach_type_known -@@ -1624,6 +1632,26 @@ - # define STACKBOTTOM ((ptr_t)0xfffff000) /* for Encore */ - # endif - -+# ifdef LOONGARCH64 -+# define MACH_TYPE "LOONGARCH64" -+# ifdef LINUX -+# define OS_TYPE "LINUX" -+# define DYNAMIC_LOADING -+ extern int _end[]; -+# pragma weak __data_start -+ extern int __data_start[]; -+# define DATASTART ((ptr_t)(__data_start)) -+# define DATAEND ((ptr_t)(_end)) -+# define CPP_WORDSZ 64 -+# define ALIGNMENT (64/8) -+# ifndef HBLKSIZE -+# define HBLKSIZE 4096 -+# endif -+# define LINUX_STACKBOTTOM -+# endif -+# endif -+ -+ - # ifdef MIPS - # define MACH_TYPE "MIPS" - # ifdef LINUX -diff -Nurp gc-7.6.4.orig/os_dep.c gc-7.6.4/os_dep.c ---- gc-7.6.4.orig/os_dep.c 2018-01-26 13:16:17.000000000 +0000 -+++ gc-7.6.4/os_dep.c 2021-01-19 02:47:16.937500000 +0000 -@@ -3166,7 +3166,7 @@ GC_API GC_push_other_roots_proc GC_CALL - # ifndef SEGV_ACCERR - # define SEGV_ACCERR 2 - # endif --# if defined(AARCH64) || defined(ARM32) || defined(MIPS) -+# if defined(AARCH64) || defined(ARM32) || defined(MIPS) || defined(LOONGARCH64) - # define CODE_OK (si -> si_code == SEGV_ACCERR) - # elif defined(POWERPC) - # define AIM /* Pretend that we're AIM. */ - +diff --git a/configure.ac b/configure.ac +index 1bd0fd6..325367d 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -722,7 +722,7 @@ AC_ARG_ENABLE(gc-debug, + AC_MSG_WARN("Client code may need to link against libunwind.") + ]) + ;; +- x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* ) ++ x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | loongarch*) + AC_DEFINE(MAKE_BACK_GRAPH) + AC_MSG_WARN("Client must not use -fomit-frame-pointer.") + AC_DEFINE(SAVE_CALL_COUNT, 8) -- Gitee From 19af87a7e5d8095636dc18dff958ef724aa6590b Mon Sep 17 00:00:00 2001 From: "taifu.gc" Date: Sun, 18 Dec 2022 17:39:43 +0800 Subject: [PATCH 3/5] test2 --- 1000-anolis-gc-7.6.4-add-loongarch.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1000-anolis-gc-7.6.4-add-loongarch.patch b/1000-anolis-gc-7.6.4-add-loongarch.patch index b6a2d96..14a5fe0 100644 --- a/1000-anolis-gc-7.6.4-add-loongarch.patch +++ b/1000-anolis-gc-7.6.4-add-loongarch.patch @@ -1,13 +1,13 @@ diff --git a/configure.ac b/configure.ac -index 1bd0fd6..325367d 100644 +index 325367d..0d93474 100644 --- a/configure.ac +++ b/configure.ac @@ -722,7 +722,7 @@ AC_ARG_ENABLE(gc-debug, AC_MSG_WARN("Client code may need to link against libunwind.") ]) ;; -- x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* ) -+ x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | loongarch*) +- x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | loongarch*) ++ x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | *loongarch*) AC_DEFINE(MAKE_BACK_GRAPH) AC_MSG_WARN("Client must not use -fomit-frame-pointer.") AC_DEFINE(SAVE_CALL_COUNT, 8) -- Gitee From 7db44b471bb8c4547997ec5e1bad70f9992ab259 Mon Sep 17 00:00:00 2001 From: "taifu.gc" Date: Sun, 18 Dec 2022 17:49:35 +0800 Subject: [PATCH 4/5] test3 --- 1000-anolis-gc-7.6.4-add-loongarch.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1000-anolis-gc-7.6.4-add-loongarch.patch b/1000-anolis-gc-7.6.4-add-loongarch.patch index 14a5fe0..8d80cf2 100644 --- a/1000-anolis-gc-7.6.4-add-loongarch.patch +++ b/1000-anolis-gc-7.6.4-add-loongarch.patch @@ -1,12 +1,12 @@ diff --git a/configure.ac b/configure.ac -index 325367d..0d93474 100644 +index 1bd0fd6..0d93474 100644 --- a/configure.ac +++ b/configure.ac @@ -722,7 +722,7 @@ AC_ARG_ENABLE(gc-debug, AC_MSG_WARN("Client code may need to link against libunwind.") ]) ;; -- x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | loongarch*) +- x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* ) + x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | *loongarch*) AC_DEFINE(MAKE_BACK_GRAPH) AC_MSG_WARN("Client must not use -fomit-frame-pointer.") -- Gitee From f6b19bff9eff25075372ad1658bcc01bc14f880f Mon Sep 17 00:00:00 2001 From: "taifu.gc" Date: Sun, 18 Dec 2022 19:37:16 +0800 Subject: [PATCH 5/5] test3 --- gc.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gc.spec b/gc.spec index 54f42b9..43a6c18 100644 --- a/gc.spec +++ b/gc.spec @@ -58,7 +58,7 @@ CPPFLAGS="-DUSE_GET_STACKBASE_FOR_MAIN"; export CPPFLAGS --disable-docs \ --enable-cplusplus \ --enable-large-config \ -%ifarch %{ix86} +%ifarch %{ix86} loongarch64 --enable-parallel-mark \ %endif --enable-threads=posix -- Gitee