From 0195f471f5b2efb44b20b2e03a049b71b3edd261 Mon Sep 17 00:00:00 2001 From: wxiat Date: Fri, 21 Jul 2023 09:26:53 +0800 Subject: [PATCH 1/2] sw-20230721 --- gc-8.0.4-sw.patch | 171 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 gc-8.0.4-sw.patch diff --git a/gc-8.0.4-sw.patch b/gc-8.0.4-sw.patch new file mode 100644 index 0000000..df08031 --- /dev/null +++ b/gc-8.0.4-sw.patch @@ -0,0 +1,171 @@ +diff -Naur gc-8.0.4.org/extra/msvc_dbg.c gc-8.0.4.sw/extra/msvc_dbg.c +--- gc-8.0.4.org/extra/msvc_dbg.c 2019-03-02 16:54:41.000000000 +0800 ++++ gc-8.0.4.sw/extra/msvc_dbg.c 2023-07-21 09:02:10.670168787 +0800 +@@ -146,12 +146,18 @@ + stackFrame.AddrStack.Offset = context->Esp; + stackFrame.AddrFrame.Mode = AddrModeFlat; + stackFrame.AddrFrame.Offset = context->Ebp; ++#elif defined(_M_SW_64) ++ machineType = IMAGE_FILE_MACHINE_SW_64; ++ stackFrame.AddrPC.Offset = context->Fir; + #elif defined(_M_MRX000) + machineType = IMAGE_FILE_MACHINE_R4000; + stackFrame.AddrPC.Offset = context->Fir; + #elif defined(_M_ALPHA) + machineType = IMAGE_FILE_MACHINE_ALPHA; + stackFrame.AddrPC.Offset = (unsigned long)context->Fir; ++#elif defined(_M_SW_64) ++ machineType = IMAGE_FILE_MACHINE_SW_6464; ++ stackFrame.AddrPC.Offset = context->Iar; + #elif defined(_M_PPC) + machineType = IMAGE_FILE_MACHINE_POWERPC; + stackFrame.AddrPC.Offset = context->Iar; +diff -Naur gc-8.0.4.org/include/gc_config_macros.h gc-8.0.4.sw/include/gc_config_macros.h +--- gc-8.0.4.org/include/gc_config_macros.h 2019-03-02 16:54:41.000000000 +0800 ++++ gc-8.0.4.sw/include/gc_config_macros.h 2023-07-21 09:03:17.851550872 +0800 +@@ -95,7 +95,7 @@ + # define GC_FREEBSD_THREADS + # elif defined(__NetBSD__) + # define GC_NETBSD_THREADS +-# elif defined(__alpha) || defined(__alpha__) /* && !Linux && !xBSD */ ++# elif defined(__alpha) || defined(__alpha__) || defined(__sw_64) || defined(__sw_64__) /* && !Linux && !xBSD */ + # define GC_OSF1_THREADS + # elif (defined(mips) || defined(__mips) || defined(_mips)) \ + && !(defined(nec_ews) || defined(_nec_ews) \ +diff -Naur gc-8.0.4.org/include/private/gcconfig.h gc-8.0.4.sw/include/private/gcconfig.h +--- gc-8.0.4.org/include/private/gcconfig.h 2023-07-21 08:58:38.808656710 +0800 ++++ gc-8.0.4.sw/include/private/gcconfig.h 2023-07-21 09:15:51.121260409 +0800 +@@ -410,6 +410,14 @@ + # define M32R + # define mach_type_known + # endif ++# if defined(__sw_64) || defined(__sw_64__) ++# define SW_64 ++# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \ ++ && !defined(FREEBSD) ++# define OSF1 /* a.k.a Digital Unix */ ++# endif ++# define mach_type_known ++# endif + # if defined(__alpha) || defined(__alpha__) + # define ALPHA + # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \ +@@ -2007,6 +2015,106 @@ + # endif + # endif /* HP_PA */ + ++# ifdef SW_64 ++# define MACH_TYPE "SW_64" ++# define ALIGNMENT 8 ++# define CPP_WORDSZ 64 ++# ifdef NETBSD ++# define OS_TYPE "NETBSD" ++# define HEURISTIC2 ++ extern ptr_t GC_data_start; ++# define DATASTART GC_data_start ++# define ELFCLASS32 32 ++# define ELFCLASS64 64 ++# define ELF_CLASS ELFCLASS64 ++# define DYNAMIC_LOADING ++# endif ++# ifdef OPENBSD ++# define OS_TYPE "OPENBSD" ++# define ELF_CLASS ELFCLASS64 ++# ifndef GC_OPENBSD_THREADS ++ EXTERN_C_END ++# include ++# include ++ EXTERN_C_BEGIN ++# ifdef USRSTACK ++# define STACKBOTTOM ((ptr_t)USRSTACK) ++# else ++# define HEURISTIC2 ++# endif ++# endif ++ extern int __data_start[]; ++# define DATASTART ((ptr_t)__data_start) ++ extern int _end[]; ++# define DATAEND ((ptr_t)(&_end)) ++# define DYNAMIC_LOADING ++# endif ++# ifdef FREEBSD ++# define OS_TYPE "FREEBSD" ++/* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */ ++# define SIG_SUSPEND SIGUSR1 ++# define SIG_THR_RESTART SIGUSR2 ++ /* SIGTSTP and SIGCONT could be used alternatively. */ ++# define FREEBSD_STACKBOTTOM ++# ifdef __ELF__ ++# define DYNAMIC_LOADING ++# endif ++/* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */ ++ extern char etext[]; ++ extern char edata[]; ++# if !defined(CPPCHECK) ++ extern char end[]; ++# endif ++# define NEED_FIND_LIMIT ++# define DATASTART ((ptr_t)(&etext)) ++ void * GC_find_limit(void *, int); ++# define DATAEND (ptr_t)GC_find_limit(DATASTART, TRUE) ++# define DATAEND_IS_FUNC ++# define GC_HAVE_DATAREGION2 ++# define DATASTART2 ((ptr_t)(&edata)) ++# define DATAEND2 ((ptr_t)(&end)) ++# endif ++# ifdef OSF1 ++# define OS_TYPE "OSF1" ++# define DATASTART ((ptr_t)0x140000000) ++ extern int _end[]; ++# define DATAEND ((ptr_t)(&_end)) ++ extern char ** environ; ++ /* round up from the value of environ to the nearest page boundary */ ++ /* Probably breaks if putenv is called before collector */ ++ /* initialization. */ ++# define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1)) ++/* # define HEURISTIC2 */ ++ /* Normally HEURISTIC2 is too conservative, since */ ++ /* the text segment immediately follows the stack. */ ++ /* Hence we give an upper pound. */ ++ /* This is currently unused, since we disabled HEURISTIC2 */ ++ extern int __start[]; ++# define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1))) ++# ifndef GC_OSF1_THREADS ++ /* Unresolved signal issues with threads. */ ++# define MPROTECT_VDB ++# endif ++# define DYNAMIC_LOADING ++# endif ++# ifdef LINUX ++# define OS_TYPE "LINUX" ++# define LINUX_STACKBOTTOM ++# ifdef __ELF__ ++# define SEARCH_FOR_DATA_START ++# define DYNAMIC_LOADING ++# else ++# define DATASTART ((ptr_t)0x140000000) ++# endif ++ extern int _end[]; ++# define DATAEND ((ptr_t)(_end)) ++# define MPROTECT_VDB ++ /* Has only been superficially tested. May not */ ++ /* work on all versions. */ ++# endif ++# endif ++ ++# ifdef IA64 + # ifdef ALPHA + # define MACH_TYPE "ALPHA" + # define ALIGNMENT 8 +diff -Naur gc-8.0.4.org/include/private/gc_priv.h gc-8.0.4.sw/include/private/gc_priv.h +--- gc-8.0.4.org/include/private/gc_priv.h 2019-03-02 16:54:41.000000000 +0800 ++++ gc-8.0.4.sw/include/private/gc_priv.h 2023-07-21 09:04:03.700176549 +0800 +@@ -842,7 +842,7 @@ + /* SMALL_CONFIG: Want less block-level fragmentation. */ + #ifndef HBLKSIZE + # if defined(LARGE_CONFIG) || !defined(SMALL_CONFIG) +-# ifdef ALPHA ++# if defined ALPHA || defined SW_64 + # define CPP_LOG_HBLKSIZE 13 + # elif defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PSP2) + # define CPP_LOG_HBLKSIZE 16 /* page size is set to 64K */ -- Gitee From 87394a4304598daf55c82d6ce5971dfadbba227c Mon Sep 17 00:00:00 2001 From: Weisson Date: Fri, 12 Jan 2024 10:31:24 +0800 Subject: [PATCH 2/2] add sw support in spec file. Signed-off-by: Weisson --- ...002-Add-SW64-architecture-definition.patch | 93 ++++++------------- gc.spec | 6 +- 2 files changed, 34 insertions(+), 65 deletions(-) rename gc-8.0.4-sw.patch => 0002-Add-SW64-architecture-definition.patch (54%) diff --git a/gc-8.0.4-sw.patch b/0002-Add-SW64-architecture-definition.patch similarity index 54% rename from gc-8.0.4-sw.patch rename to 0002-Add-SW64-architecture-definition.patch index df08031..15e838a 100644 --- a/gc-8.0.4-sw.patch +++ b/0002-Add-SW64-architecture-definition.patch @@ -1,59 +1,33 @@ -diff -Naur gc-8.0.4.org/extra/msvc_dbg.c gc-8.0.4.sw/extra/msvc_dbg.c ---- gc-8.0.4.org/extra/msvc_dbg.c 2019-03-02 16:54:41.000000000 +0800 -+++ gc-8.0.4.sw/extra/msvc_dbg.c 2023-07-21 09:02:10.670168787 +0800 -@@ -146,12 +146,18 @@ - stackFrame.AddrStack.Offset = context->Esp; - stackFrame.AddrFrame.Mode = AddrModeFlat; - stackFrame.AddrFrame.Offset = context->Ebp; -+#elif defined(_M_SW_64) -+ machineType = IMAGE_FILE_MACHINE_SW_64; -+ stackFrame.AddrPC.Offset = context->Fir; - #elif defined(_M_MRX000) - machineType = IMAGE_FILE_MACHINE_R4000; - stackFrame.AddrPC.Offset = context->Fir; - #elif defined(_M_ALPHA) - machineType = IMAGE_FILE_MACHINE_ALPHA; - stackFrame.AddrPC.Offset = (unsigned long)context->Fir; -+#elif defined(_M_SW_64) -+ machineType = IMAGE_FILE_MACHINE_SW_6464; -+ stackFrame.AddrPC.Offset = context->Iar; - #elif defined(_M_PPC) - machineType = IMAGE_FILE_MACHINE_POWERPC; - stackFrame.AddrPC.Offset = context->Iar; -diff -Naur gc-8.0.4.org/include/gc_config_macros.h gc-8.0.4.sw/include/gc_config_macros.h ---- gc-8.0.4.org/include/gc_config_macros.h 2019-03-02 16:54:41.000000000 +0800 -+++ gc-8.0.4.sw/include/gc_config_macros.h 2023-07-21 09:03:17.851550872 +0800 -@@ -95,7 +95,7 @@ - # define GC_FREEBSD_THREADS - # elif defined(__NetBSD__) - # define GC_NETBSD_THREADS --# elif defined(__alpha) || defined(__alpha__) /* && !Linux && !xBSD */ -+# elif defined(__alpha) || defined(__alpha__) || defined(__sw_64) || defined(__sw_64__) /* && !Linux && !xBSD */ - # define GC_OSF1_THREADS - # elif (defined(mips) || defined(__mips) || defined(_mips)) \ - && !(defined(nec_ews) || defined(_nec_ews) \ -diff -Naur gc-8.0.4.org/include/private/gcconfig.h gc-8.0.4.sw/include/private/gcconfig.h ---- gc-8.0.4.org/include/private/gcconfig.h 2023-07-21 08:58:38.808656710 +0800 -+++ gc-8.0.4.sw/include/private/gcconfig.h 2023-07-21 09:15:51.121260409 +0800 -@@ -410,6 +410,14 @@ - # define M32R +From f4db55e05088417eab1fdd8ec6f598db04864cf4 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Thu, 20 Jul 2023 19:40:14 +0800 +Subject: [PATCH] Add SW64 architecture definition. + +Signed-off-by: Weisson +--- + include/private/gcconfig.h | 105 +++++++++++++++++++++++++++++++++++++ + 1 file changed, 105 insertions(+) + +diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h +index 0ff3dc9..13239e3 100644 +--- a/include/private/gcconfig.h ++++ b/include/private/gcconfig.h +@@ -375,6 +375,10 @@ EXTERN_C_BEGIN + # define LOONGARCH64 # define mach_type_known # endif -+# if defined(__sw_64) || defined(__sw_64__) -+# define SW_64 -+# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \ -+ && !defined(FREEBSD) -+# define OSF1 /* a.k.a Digital Unix */ -+# endif -+# define mach_type_known ++# if defined(LINUX) && defined(__sw_64__) ++# define SW_64 ++# define mach_type_known +# endif - # if defined(__alpha) || defined(__alpha__) - # define ALPHA - # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \ -@@ -2007,6 +2015,106 @@ + # if defined(LINUX) && (defined(__arm) || defined(__arm__)) + # define ARM32 + # define mach_type_known +@@ -2007,6 +2011,107 @@ EXTERN_C_BEGIN # endif # endif /* HP_PA */ - + ++ +# ifdef SW_64 +# define MACH_TYPE "SW_64" +# define ALIGNMENT 8 @@ -153,19 +127,10 @@ diff -Naur gc-8.0.4.org/include/private/gcconfig.h gc-8.0.4.sw/include/private/g +# endif +# endif + -+# ifdef IA64 ++ # ifdef ALPHA # define MACH_TYPE "ALPHA" # define ALIGNMENT 8 -diff -Naur gc-8.0.4.org/include/private/gc_priv.h gc-8.0.4.sw/include/private/gc_priv.h ---- gc-8.0.4.org/include/private/gc_priv.h 2019-03-02 16:54:41.000000000 +0800 -+++ gc-8.0.4.sw/include/private/gc_priv.h 2023-07-21 09:04:03.700176549 +0800 -@@ -842,7 +842,7 @@ - /* SMALL_CONFIG: Want less block-level fragmentation. */ - #ifndef HBLKSIZE - # if defined(LARGE_CONFIG) || !defined(SMALL_CONFIG) --# ifdef ALPHA -+# if defined ALPHA || defined SW_64 - # define CPP_LOG_HBLKSIZE 13 - # elif defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PSP2) - # define CPP_LOG_HBLKSIZE 16 /* page size is set to 64K */ +-- +2.20.1.4621.g47101605 + diff --git a/gc.spec b/gc.spec index 28f7826..d3681b0 100644 --- a/gc.spec +++ b/gc.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 Summary: A garbage collector for C and C++ Name: gc Version: 8.0.4 @@ -17,6 +17,7 @@ Source0: http://www.hboehm.info/gc/gc_source/gc-%{version}%{?pre}.tar.gz Patch100: gc-7.6.4-dont_disable_exceptions.patch Patch1000: 0001-arch-support-loongarch64.patch +Patch1001: 0002-Add-SW64-architecture-definition.patch BuildRequires: automake libtool BuildRequires: gcc-c++ @@ -110,6 +111,9 @@ make check %{?arch_ignore} %changelog +* Fri Jan 12 2024 Weisson - 8.0.4-7.0.2 +- Support sw_64. + * Sun Dec 18 2022 Liwei Ge - 8.0.4-7.0.1 - Support loongarch64 -- Gitee