Skip to content

[ios/tvos] ARM64 simulator JIT Hack and CMAKE_SYSTEM_VARIANT iOSSimulator#52764

Closed
lambdageek wants to merge 9 commits into
dotnet:mainfrom
lambdageek:add-iossimulator-arm64-jit-hack
Closed

[ios/tvos] ARM64 simulator JIT Hack and CMAKE_SYSTEM_VARIANT iOSSimulator#52764
lambdageek wants to merge 9 commits into
dotnet:mainfrom
lambdageek:add-iossimulator-arm64-jit-hack

Conversation

@lambdageek

@lambdageek lambdageek commented May 14, 2021

Copy link
Copy Markdown
Member

On iossimulator-arm64 and tvossimulator-arm64, use the pthread_jit_write_protect_np function to toggle the W^X bit for the current thread.

Unfortunately, the above function is marked as __API_UNAVAILABLE on ios, tvos, watchos in the apple headers. But in the simulator frameworks it is still present and usable. So we declare our own prototype of the function and avoid the clang error.


This reverts commit 89a816f, but for iOS and tvOS simulators, not for Catalyst.

That commit in turn reverted a9f1207

(ie this current commit is the same as a9f1207 but for ios simulator instead of catalyst)


Build system changes:

Set CMAKE_SYSTEM_VARIANT to "iOSSimulator" or "tvOSSimulator".

In Mono, set CMAKE_DARWIN_SIMULATOR

@lambdageek

Copy link
Copy Markdown
Member Author

/cc @steveisok

@steveisok steveisok self-requested a review May 14, 2021 15:40

@CoffeeFlux CoffeeFlux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repeated reversions are confusing: can you just give me a quick description of what configurations require the hack and why?

Comment thread src/mono/mono/utils/write-protect.h Outdated
On iossimulator-arm64 and tvossimulator-arm64, use the
pthread_jit_write_protect_np function to toggle the W^X bit for the current
thread.

Unfortunately, the above function is marked as __API_UNAVAILABLE on ios, tvos,
watchos in the apple headers.  But in the simulator frameworks it is still
present and usable.  So we declare our own prototype of the function and avoid
the clang error.

---

This reverts commit 89a816f, but for IOS
simulator, not for Catalyst.

That commit in turn reverted a9f1207

(ie this current commit is the same as a9f1207 but for ios simulator instead of catalyst)
For Mono, set HOST_DARWIN_SIMULATOR in cmake and C
@lambdageek lambdageek force-pushed the add-iossimulator-arm64-jit-hack branch from 53de876 to b2153bf Compare May 14, 2021 17:50
@lambdageek

Copy link
Copy Markdown
Member Author

The repeated reversions are confusing: can you just give me a quick description of what configurations require the hack and why?

Updated the commit message and the PR description. We're only enabling this for iossimulator-arm64 and tvossimulator-arm64. The reasoning being is that those are meant to run just on the local development machine, so there is no risk of running afoul of any App Store rules.

Comment thread src/mono/mono/utils/mono-codeman.c Outdated
Comment thread eng/native/build-commons.sh Outdated
Comment thread eng/native/build-commons.sh Outdated
Comment thread src/mono/mono/utils/write-protect.c Outdated
apparently it wants to see literally `if (__builtin_available(...))`
Comment thread src/mono/mono/utils/mono-codeman.c Outdated
@lambdageek

Copy link
Copy Markdown
Member Author

We don't need this anymore. #53197 added a no-exec mode to the code manager so that cross-compilers don't need to use the pthread write_protect function. And #51536 will use the "JustInterp" (--aot=interp / MONO_AOT_MODE_INTERP) to run the apps - which does not require JITable pages for trampolines, etc.

@lambdageek lambdageek closed this Jun 4, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jul 4, 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.

5 participants