-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add support for building CoreCLR for MacCatalyst/iOS simulator #109928
base: main
Are you sure you want to change the base?
Conversation
@@ -494,7 +494,7 @@ if new_level is -1, the nesting level will not be modified | |||
--*/ | |||
int DBG_change_entrylevel(int new_level); | |||
|
|||
#ifdef __APPLE__ | |||
#ifdef TARGET_OSX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is TARGET_OSX
a subset of TARGET_APPLE
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is.
src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c
Outdated
Show resolved
Hide resolved
src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c
Outdated
Show resolved
Hide resolved
@@ -228,6 +228,9 @@ endif(CLR_CMAKE_TARGET_WIN32) | |||
|
|||
# add the install targets | |||
install_clr(TARGETS coreclr DESTINATIONS . sharedFramework COMPONENT runtime) | |||
if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS) | |||
install_clr(TARGETS coreclr_static DESTINATIONS . sharedFramework COMPONENT runtime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to install this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS generally restricts linking to static libraries or dynamic frameworks distributed with the app itself. The aim was to include statically built CoreCLR in the runtime pack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if that means that the single file is the only deployment mechanism on iOS. If it is the case, then I am not sure what would be the scenario where developers would explicitly use the static version of coreclr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linking with a static library typically results in smaller apps, which is why we've always linked Mono statically by default.
Linking dynamically can make the build a little bit faster (from past experience in Xamarin, we never ported this to .NET when we migrated due to time constraints).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The single file is a host statically linked to all the native libraries including coreclr. The scenario when the developers would need static coreclr library would be when they want to use their own host. Thinking about it more, I guess distributing the static coreclr version actually makes sense to enable such scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that sounds like what we want.
Note that .dylib won't do (Apple doesn't allow them in iOS apps), each dynamic library has to be made into a .framework (which works).
FWIW Apple has recommended using no more than 6-8 .frameworks because otherwise it affects startup performance.
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
0eae3aa
to
ec579a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
@filipnavara can you please resolve the conflicts so that we can merge the change in? |
Done. |
@filipnavara there are some test failures, I think that I've seen some of them in the previous runs already. Could you please take a look to see if they could possibly be related to this change? |
I don't think any of that is related to this PR but it may be worth re-running the affected pipelines. |
Issue was filed for the MonoCrossAOT build errors - #111474. It happened in an unrelated PR. |
@filipnavara Could you please resolve the conflict? |
Done |
Re-open and rebase of #98127
Build instructions:
./build.sh clr+clr.runtime+libs+packs -os [iossimulator/maccatalyst] -arch [x64/arm64] -cross -c Release
./dotnet.sh publish src/mono/sample/iOS/Program.csproj -c Release /p:TargetOS=maccatalyst /p:TargetArchitecture=arm64 /p:DeployAndRun=true /p:UseMonoRuntime=false /p:RunAOTCompilation=false /p:MonoForceInterpreter=false
Related work:
KnownRuntimeFramework
to use thisNotably, this doesn't include CI scripts to build this or the runtime packs. I am open to suggestions on how to better split this into more digestible/reviewable chunks.