Add support for OpenBSD/arm64 to lang/mono. The port itself is in a good shape
for arm64, it just needs a few defines so that Mono recognizes the platform as a valid one. The garbage collector patch is copied from amd64, the ucontext defines simply have to use the correct sigcontext members, and for BoringSSL we need to provide the setup function that tells BoringSSL which crypto accel is supported by the CPU. For now this only enables NEON, which we have on all OpenBSD/arm64 machines. "makes sense, need to be sure it doesn't break existing working archs" sthen@ Tested by myself on arm64 by playing games/openra through iked(8) IPsec Tested by myself on amd64 and i386 ok robert@ naddy@
This commit is contained in:
parent
699bf3a31c
commit
cb93188d9b
@ -0,0 +1,51 @@
|
||||
$OpenBSD: patch-external_bdwgc_include_private_gcconfig_h,v 1.1 2021/04/10 15:31:33 patrick Exp $
|
||||
|
||||
Index: external/bdwgc/include/private/gcconfig.h
|
||||
--- external/bdwgc/include/private/gcconfig.h.orig
|
||||
+++ external/bdwgc/include/private/gcconfig.h
|
||||
@@ -155,7 +155,7 @@ EXTERN_C_BEGIN
|
||||
# if defined(__aarch64__)
|
||||
# define AARCH64
|
||||
# if !defined(LINUX) && !defined(DARWIN) && !defined(FREEBSD) \
|
||||
- && !defined(NN_BUILD_TARGET_PLATFORM_NX)
|
||||
+ && !defined(OPENBSD) && !defined(NN_BUILD_TARGET_PLATFORM_NX)
|
||||
# define NOSYS
|
||||
# define mach_type_known
|
||||
# endif
|
||||
@@ -348,6 +348,10 @@ EXTERN_C_BEGIN
|
||||
# define X86_64
|
||||
# define mach_type_known
|
||||
# endif
|
||||
+# if defined(OPENBSD) && defined(__aarch64__)
|
||||
+# define AARCH64
|
||||
+# define mach_type_known
|
||||
+# endif
|
||||
# if defined(LINUX) && (defined(i386) || defined(__i386__))
|
||||
# define I386
|
||||
# define mach_type_known
|
||||
@@ -2298,6 +2302,25 @@ EXTERN_C_BEGIN
|
||||
extern char etext[];
|
||||
# define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
|
||||
# define DATASTART_USES_BSDGETDATASTART
|
||||
+# endif
|
||||
+# ifdef OPENBSD
|
||||
+# define OS_TYPE "OPENBSD"
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+ EXTERN_C_END
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+ EXTERN_C_BEGIN
|
||||
+# ifdef USRSTACK
|
||||
+# define STACKBOTTOM ((ptr_t)USRSTACK)
|
||||
+# else
|
||||
+# define HEURISTIC2
|
||||
+# endif
|
||||
+# endif
|
||||
+ extern int __data_start[];
|
||||
+ extern int _end[];
|
||||
+# define DATASTART ((ptr_t)__data_start)
|
||||
+# define DATAEND ((ptr_t)(&_end))
|
||||
+# define DYNAMIC_LOADING
|
||||
# endif
|
||||
# ifdef NINTENDO_SWITCH
|
||||
static int zero_fd = -1;
|
@ -0,0 +1,31 @@
|
||||
$OpenBSD: patch-external_boringssl_crypto_cpu-aarch64-linux_c,v 1.1 2021/04/10 15:31:33 patrick Exp $
|
||||
|
||||
Index: external/boringssl/crypto/cpu-aarch64-linux.c
|
||||
--- external/boringssl/crypto/cpu-aarch64-linux.c.orig
|
||||
+++ external/boringssl/crypto/cpu-aarch64-linux.c
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
#if defined(OPENSSL_AARCH64) && !defined(OPENSSL_STATIC_ARMCAP)
|
||||
|
||||
+#if !defined(__OpenBSD__)
|
||||
#include <sys/auxv.h>
|
||||
+#endif
|
||||
|
||||
#include <openssl/arm_arch.h>
|
||||
|
||||
@@ -63,6 +65,15 @@ void OPENSSL_cpuid_setup(void) {
|
||||
if (ID_AA64ISAR0_SHA2_VAL(isar0_val) >= ID_AA64ISAR0_SHA2_BASE) {
|
||||
OPENSSL_armcap_P |= ARMV8_SHA256;
|
||||
}
|
||||
+}
|
||||
+
|
||||
+#elif defined(__OpenBSD__)
|
||||
+
|
||||
+#include <stdlib.h>
|
||||
+#include <sys/types.h>
|
||||
+
|
||||
+void OPENSSL_cpuid_setup(void) {
|
||||
+ OPENSSL_armcap_P |= ARMV7_NEON;
|
||||
}
|
||||
|
||||
#else // linux
|
18
lang/mono/patches/patch-mono_utils_mono-sigcontext_h
Normal file
18
lang/mono/patches/patch-mono_utils_mono-sigcontext_h
Normal file
@ -0,0 +1,18 @@
|
||||
$OpenBSD: patch-mono_utils_mono-sigcontext_h,v 1.8 2021/04/10 15:31:33 patrick Exp $
|
||||
|
||||
Index: mono/utils/mono-sigcontext.h
|
||||
--- mono/utils/mono-sigcontext.h.orig
|
||||
+++ mono/utils/mono-sigcontext.h
|
||||
@@ -472,6 +472,12 @@ typedef struct ucontext {
|
||||
#define UCONTEXT_REG_SP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_gpregs.gp_sp)
|
||||
#define UCONTEXT_REG_R0(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_gpregs.gp_x [ARMREG_R0])
|
||||
#define UCONTEXT_GREGS(ctx) (&(((ucontext_t*)(ctx))->uc_mcontext.mc_gpregs.gp_x))
|
||||
+#elif defined(__OpenBSD__)
|
||||
+ /* ucontext_t == sigcontext */
|
||||
+ #define UCONTEXT_REG_PC(ctx) (((ucontext_t*)(ctx))->sc_elr)
|
||||
+ #define UCONTEXT_REG_SP(ctx) (((ucontext_t*)(ctx))->sc_sp)
|
||||
+ #define UCONTEXT_REG_R0(ctx) (((ucontext_t*)(ctx))->sc_x [ARMREG_R0])
|
||||
+ #define UCONTEXT_GREGS(ctx) (&(((ucontext_t*)(ctx))->sc_x))
|
||||
#else
|
||||
#include <ucontext.h>
|
||||
#define UCONTEXT_REG_PC(ctx) (((ucontext_t*)(ctx))->uc_mcontext.pc)
|
Loading…
x
Reference in New Issue
Block a user