Skip to content

[mono] Add HAVE_PTHREAD_JIT_WRITE_PROTECT_NP to cmake config.h.in#51610

Merged
lambdageek merged 2 commits into
dotnet:mainfrom
lambdageek:add-jitwriteprotect
Apr 21, 2021
Merged

[mono] Add HAVE_PTHREAD_JIT_WRITE_PROTECT_NP to cmake config.h.in#51610
lambdageek merged 2 commits into
dotnet:mainfrom
lambdageek:add-jitwriteprotect

Conversation

@lambdageek
Copy link
Copy Markdown
Member

@lambdageek lambdageek commented Apr 21, 2021

Otherwise mono_codeman_enable_write is a no-op

Should fix jiting on macOS arm64

Fixes #49042

Otherwise mono_codeman_enable_write is a no-op

Should fix jiting on Apple ARM64
@lambdageek lambdageek requested a review from marek-safar as a code owner April 21, 2021 04:32
@ghost ghost added the area-Build-mono label Apr 21, 2021
@lambdageek lambdageek requested a review from vargaz April 21, 2021 04:33
@lambdageek

This comment has been minimized.

@lambdageek
Copy link
Copy Markdown
Member Author

To test, on an M1:

$ arch -x86_64 ./build.sh mono+libs -c Debug --arch arm64
$ cd src/libraries/System.Buffers/tests
$ ../../../../dotnet.sh build /t:Test /p:TargetArchitecture=arm64

check_function_exists doesn't look at the headers, only at linking, so
it can't detect functions marked unavailable in Apple headers.
@lambdageek
Copy link
Copy Markdown
Member Author

So interestingly, this seems to mean that JITing on arm64 in MacCatalyst apps is not possible. The pthread_jit_write_protect_np function is marked __API_AVAILABLE(macos(10.16)) __API_UNAVAILABLE(ios, tvos, watchos, bridgeos, driverkit) (pthread.h source here).

So this did not work:

$ arch -x86_64 ./build.sh mono+libs -c Debug --arch arm64 --os maccatalyst
$ cd src/libraries/System.Buffers/tests
$ ../../../../dotnet.sh build /t:Test /p:TargetArchitecture=arm64 /p:TargetOS=maccatalyst

I'm still investigating the crash to see if there's something else going wrong. But at first blush it seems like the write protection bit still needs to be toggled, but the API for doing so is not available.

@lambdageek lambdageek merged commit 776dd1d into dotnet:main Apr 21, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Mono] Bus error when running dotnet exec on osx arm64

3 participants