Skip to content

Commit

Permalink
Merge pull request #80 from bruvzg/btls_arm_macos
Browse files Browse the repository at this point in the history
Add patch for ARM64 macOS BTLS build.
  • Loading branch information
akien-mga authored Feb 9, 2023
2 parents 5299efd + a0e457e commit 8767196
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 1 deletion.
59 changes: 59 additions & 0 deletions files/patches/btls-cmake-arm64.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
diff --git a/configure.ac b/configure.ac
index 088128e5e74..235acfe9181 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4921,9 +4921,6 @@ if test "x$target_mach" = "xyes"; then
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_OSX"
CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_OSX"
target_osx=yes
- if test "x$TARGET" = "xARM64"; then
- BTLS_SUPPORTED=no
- fi
], [
AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_IOS"
@@ -5942,7 +5939,11 @@ if test "x$enable_btls" = "xyes"; then
;;
aarch64)
btls_arch=aarch64
- btls_cflags="-march=armv8-a+crypto"
+ if test "x$target_mach" = "xyes"; then
+ btls_cflags="-arch arm64"
+ else
+ btls_cflags="-march=armv8-a+crypto"
+ fi
;;
s390x)
btls_arch=s390x
diff --git a/mono/btls/CMakeLists.txt b/mono/btls/CMakeLists.txt
index 992f41e4c7f..ee3e956c5b0 100644
--- a/mono/btls/CMakeLists.txt
+++ b/mono/btls/CMakeLists.txt
@@ -21,6 +21,15 @@ if (MSVC OR CYGWIN)
set(BTLS_HOST_WIN32 1)
endif ()

+if (NOT "${BTLS_ARCH}" STREQUAL "")
+ message (STATUS "SET ARCH: ${BTLS_ARCH}")
+ set (CMAKE_SYSTEM_PROCESSOR "${BTLS_ARCH}")
+endif ()
+
+if ((("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64") OR ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")) AND APPLE AND NOT IOS)
+ set(OPENSSL_NO_ASM 1)
+endif ()
+
if (NOT OPENSSL_NO_ASM)
if (BTLS_HOST_WIN32)
if (CYGWIN AND "${BTLS_ARCH}" STREQUAL "i386")
@@ -38,11 +47,6 @@ if (NOT OPENSSL_NO_ASM)
endif ()
endif ()

-if (NOT "${BTLS_ARCH}" STREQUAL "")
- message (STATUS "SET ARCH: ${BTLS_ARCH}")
- set (CMAKE_SYSTEM_PROCESSOR "${BTLS_ARCH}")
-endif ()
-
if (NOT MSVC)
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX" OR ${CMAKE_SYSTEM_NAME} MATCHES "OS400")
# GCC+XCOFF doesn't support -fvisibility=hidden, and we would prefer XCOFF debugging info.
59 changes: 59 additions & 0 deletions files/patches/xcode_13_14_fix.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
diff --git a/configure.ac b/configure.ac
index 088128e5e74..19b20127ca2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3308,6 +3308,12 @@ if test x$host_win32 = xno; then
dnl ******************************************
AC_CHECK_HEADERS(CommonCrypto/CommonDigest.h)

+ AC_CHECK_MEMBER(struct objc_super.super_class,
+ [AC_DEFINE(HAVE_OBJC_SUPER_SUPER_CLASS, 1, [struct objc_super.super_class])],
+ [],
+ [#include <objc/runtime.h>
+ #include <objc/message.h>])
+
dnl *********************************
dnl *** Check for Console 2.0 I/O ***
dnl *********************************
diff --git a/mono/metadata/w32process-unix-osx.c b/mono/metadata/w32process-unix-osx.c
index 2568a44223e..f320e270c39 100644
--- a/mono/metadata/w32process-unix-osx.c
+++ b/mono/metadata/w32process-unix-osx.c
@@ -183,12 +183,19 @@ mono_dyld_image_info_free (void *info)
static void
image_added (const struct mach_header *hdr32, intptr_t vmaddr_slide)
{
+#if defined(__APPLE__) && defined(__clang__) // getsectbynamefromheader functions are deprecated as of macOS 13.0
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
#if SIZEOF_VOID_P == 8
const struct mach_header_64 *hdr64 = (const struct mach_header_64 *)hdr32;
const struct section_64 *sec = getsectbynamefromheader_64 (hdr64, SEG_DATA, SECT_DATA);
#else
const struct section *sec = getsectbynamefromheader (hdr32, SEG_DATA, SECT_DATA);
#endif
+#if defined(__APPLE__) && defined(__clang__)
+#pragma clang diagnostic pop
+#endif
Dl_info dlinfo;
if (!dladdr (hdr32, &dlinfo)) return;
if (sec == NULL) return;
diff --git a/mono/utils/mono-threads-mach-helper.c b/mono/utils/mono-threads-mach-helper.c
index 7b4f140b619..0a2ff341fc4 100644
--- a/mono/utils/mono-threads-mach-helper.c
+++ b/mono/utils/mono-threads-mach-helper.c
@@ -59,10 +59,10 @@ mono_dead_letter_dealloc (id self, SEL _cmd)
{
struct objc_super super;
super.receiver = self;
-#if !defined(__cplusplus) && !__OBJC2__
- super.class = nsobject;
-#else
+#if defined(__cplusplus) || defined(HAVE_OBJC_SUPER_SUPER_CLASS)
super.super_class = nsobject;
+#else
+ super.class = nsobject;
#endif
void (*objc_msgSendSuper_op)(struct objc_super *, SEL) = (void (*)(struct objc_super *, SEL)) objc_msgSendSuper;
objc_msgSendSuper_op (&super, dealloc);
4 changes: 3 additions & 1 deletion patch_mono.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def main(raw_args):
'bcl-profile-platform-override.diff',
'mono_ios_asl_log_deprecated.diff',
'wasm_m2n_trampolines_hook.diff',
'btls-cmake-args-linux-mingw.diff'
'btls-cmake-args-linux-mingw.diff',
'btls-cmake-arm64.diff',
'xcode_13_14_fix.diff',
]

if os.path.isfile(os.path.join(mono_source_root, 'mono/tools/offsets-tool/offsets-tool.py')):
Expand Down

0 comments on commit 8767196

Please sign in to comment.