Skip to content

MonoVM's arm64 binaries for macOS don't have Apple Silicon support #52635

@rolfbjarne

Description

@rolfbjarne

Description

libcorelib.dylib for microsoft.netcore.app.runtime.mono.osx-arm64 wasn't built with HAVE_PTHREAD_JIT_WRITE_PROTECT_NP set, which is required for Apple Silicon:

$ otool -p _mono_codeman_enable_write -vVt packages/microsoft.netcore.app.runtime.mono.osx-arm64/6.0.0-preview.5.21218.1/runtimes/osx-arm64/native/libcoreclr.dylib| head -6
packages/microsoft.netcore.app.runtime.mono.osx-arm64/6.0.0-preview.5.21218.1/runtimes/osx-arm64/native/libcoreclr.dylib:
(__TEXT,__text) section
_mono_codeman_enable_write:
00000000000e18a4	ret
_mono_codeman_disable_write:
00000000000e18a8	ret

void
mono_codeman_enable_write (void)
{
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
if (__builtin_available (macOS 11, *)) {
int level = GPOINTER_TO_INT (mono_native_tls_get_value (write_level_tls_id));
level ++;
mono_native_tls_set_value (write_level_tls_id, GINT_TO_POINTER (level));
pthread_jit_write_protect_np (0);
}
#elif defined(HOST_MACCAT) && defined(__aarch64__)
/* JITing in Catalyst apps is not allowed on Apple Silicon. */
g_assert_not_reached ();
#endif
}

Compare with libmonosgen-2.0.dylib:

$ otool -p _mono_codeman_enable_write -vVt builds/downloads/mac-release-Darwin-b4a385816ed4f1398d0184c38f19f560e868fd80/mac-libs/libmonosgen-2.0.dylib| head -6 
../../builds/downloads/mac-release-Darwin-b4a385816ed4f1398d0184c38f19f560e868fd80/mac-libs/libmonosgen-2.0.dylib:
(__TEXT,__text) section
_mono_codeman_enable_write:
000000000028421c	stp	x20, x19, [sp, #-0x20]!
0000000000284220	stp	x29, x30, [sp, #0x10]
0000000000284224	add	x29, sp, #0x10
[...]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions