Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed

Conversation

lambdageek
Copy link
Member

@lambdageek lambdageek commented May 14, 2021

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
Member Author

/cc @steveisok

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

@CoffeeFlux CoffeeFlux left a comment

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?

src/mono/mono/utils/write-protect.h Outdated Show resolved Hide resolved
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
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.

eng/native/build-commons.sh Outdated Show resolved Hide resolved
eng/native/build-commons.sh Outdated Show resolved Hide resolved
src/mono/mono/utils/write-protect.c Outdated Show resolved Hide resolved
apparently it wants to see literally `if (__builtin_available(...))`
@lambdageek
Copy link
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.

None yet

5 participants