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

Add iOS build configurations #33292

Merged
merged 14 commits into from
Mar 11, 2020
Merged

Add iOS build configurations #33292

merged 14 commits into from
Mar 11, 2020

Conversation

akoeplinger
Copy link
Member

This adds support for iOS using the Mono runtime to the build system.

I'm only adding the build integration right now, CI support will be done separately.

if(CLR_CMAKE_TARGET_OS STREQUAL iOS)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_IOS 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL iOS)
Copy link
Member

Choose a reason for hiding this comment

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

I'd expect iOS to set CLR_CMAKE_TARGET_DARWIN too. Not sure whether it would make the rest of the diff with if conditions smaller or larger though.

Copy link
Member

Choose a reason for hiding this comment

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

Yes please, at least on cmake side, we are consistent with Darwin naming. It's only the code and RIDs where the (obsolete) osx name is used. 😁

Copy link
Member Author

@akoeplinger akoeplinger Mar 6, 2020

Choose a reason for hiding this comment

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

This was a conscious decision because CLR_CMAKE_TARGET_DARWIN really means macOS in the rest of the build scripts. We could rename it to CLR_CMAKE_TARGET_OSX?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do the renaming in a follow-up PR.

# Manually set results from check_c_source_runs() since it's not possible to actually run it during CMake configure checking
unset(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP)
unset(HAVE_CLOCK_MONOTONIC) # only exists on iOS 10+
unset(HAVE_CLOCK_REALTIME) # only exists on iOS 10+
Copy link
Member

Choose a reason for hiding this comment

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

What's the minimum target iOS? 9 stopped getting patches 3 years ago (modulo one patch for GPS rollover last year). Even 10 looks to be out of support other than the GPS fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

The minimum target that Xamarin supports today is iOS 7 for devices and iOS 8 for the simulator so I replicated that here. We're discussing with PM but it looks like we won't be able to meaningfully bump the minimum version, definitely not to 10.

# Conflicts:
#	src/libraries/pkg/Directory.Build.props
#	src/mono/netcore/nuget/Directory.Build.props
It is only used for interacting with OpenSSL which isn't useful on iOS.
@marek-safar
Copy link
Contributor

@ViktorHofer any objections?

@ViktorHofer
Copy link
Member

I hadn't yet that time to review the PR. Please wait until #33242 is in (should be in ~1 hour) on which I was working the last few days to avoid conflicts. I will now review the PR.

# Conflicts:
#	eng/native/configuretools.cmake
#	src/installer/corehost/CMakeLists.txt
#	src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj
@akoeplinger
Copy link
Member Author

Sure. I'll need to push another merge anyway due to conflicts so I can wait for that PR to land.

@ViktorHofer ViktorHofer requested a review from a team March 10, 2020 14:21
@ViktorHofer
Copy link
Member

@ViktorHofer any objections?

a lot's going on today. I just requested review from dotnet/runtime-infrastructure as well. I peeked into the changes and the RuntimeFlavor one in Subsets.props is questionable. Please don't merge the change yet before me and the infra teams has taken a closer look. Thanks for your understanding.

@akoeplinger
Copy link
Member Author

I peeked into the changes and the RuntimeFlavor one in Subsets.props is questionable.

@ViktorHofer let me know if what I proposed in #33292 (comment) makes more sense, thanks.

@directhex
Copy link
Contributor

I'm branching off this to try and get the AzDO YAML going. Will rebase as and when.

Comment on lines 1 to 3
if(NOT CLR_CMAKE_CONFIGURE_PLATFORM_INCLUDED)
message(FATAL_ERROR "configuretools.cmake needs to be included after configureplatforms.cmake")
endif()
Copy link
Member

@am11 am11 Mar 10, 2020

Choose a reason for hiding this comment

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

Could we instead:

Suggested change
if(NOT CLR_CMAKE_CONFIGURE_PLATFORM_INCLUDED)
message(FATAL_ERROR "configuretools.cmake needs to be included after configureplatforms.cmake")
endif()
include(${CMAKE_CURRENT_LIST_DIR}/configureplatform.cmake)

and remove three occurrences of include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake) under :/src/? This way we would only use configuretools.cmake as an entrypoint cmake for eng/native (and rest of the files will become internal detail, which however may get refactored in the future).

Copy link
Member

@am11 am11 Mar 10, 2020

Choose a reason for hiding this comment

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

or perhaps for all call sites, we can add an explicit :/eng/native/entrypoint.cmake enlisting:

include(${CMAKE_CURRENT_LIST_DIR}/functions.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/configureplatform.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/configuretools.cmake)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I think this makes sense. I'd prefer if we do it in a separate PR though :)

Copy link
Member

Choose a reason for hiding this comment

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

I have addressed it as part of Android fixes #32800.

@steveisok
Copy link
Member

@dotnet/runtime-infrastructure Can one or more of you give this a review? I'd like to have this merged today if possible.

@@ -66,6 +66,7 @@

<_subsetCategory Condition="'$(SubsetCategory)' != ''">$(SubsetCategory.ToLowerInvariant())</_subsetCategory>
<_subsetCategory Condition="'$(SubsetCategory)' == ''">$(DefaultSubsetCategories)</_subsetCategory>
<_subsetCategory Condition="'$(SubsetCategory)' == '' and '$(TargetOS)' == 'iOS'">libraries-mono</_subsetCategory>
Copy link
Member

Choose a reason for hiding this comment

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

Should we error if SubsetCategory is not empty and contains either installer or coreclr when TargetOS is iOS?

Copy link
Member Author

Choose a reason for hiding this comment

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

I feel like if you manually override subset category that way you deserve to get the failures :)

Copy link
Member

Choose a reason for hiding this comment

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

I get that, but it is good to help developers get readable failures? Sometimes because of the lack of those validations we get a lot of questions, why this doesn't work, why am I getting this error, etc? We already have a target that does validation for the subset categories, if I remember correctly.

Copy link
Member

@ViktorHofer ViktorHofer Mar 11, 2020

Choose a reason for hiding this comment

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

I think it's ok to set RuntimeFlavor based on the passed in SubsetCategory but I don't think that SubsetCategory should be inferred from TargetOS. The SubsetCategory can also contain values like mono, or mono-coreclr-libraries-installer therefore I think it's necessary to be intentional here and require the category to be passed in.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ViktorHofer why not? coreclr or installer are not valid subset categories when you have TargetOS=iOS so having a default when nothing is set explicitly makes a lot of sense.

Copy link
Member

Choose a reason for hiding this comment

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

I thought about this more. I'm fine with providing a default value for the subset categories when a configuration is passed in that isn't supported on one of those categories but I would not want to exclude installer which brings me back to my question: Why did you choose mono-libraries and not mono-libraries-installer?

Copy link
Member Author

@akoeplinger akoeplinger Mar 11, 2020

Choose a reason for hiding this comment

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

@ViktorHofer installer doesn't make sense at all, there won't be an installer for the iOS bits (nuget only). The default of mono-libraries is everything that we want to build by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can move the change to set DefaultSubsetCategories for TargetOS==iOS instead if that helps making it clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

I discussed this with Viktor offline and there was some misunderstanding. installer is not just for building the .deb/.msi/.pkg installers but also does other things like creating runtime packs and ref packs. So we might eventually need it for iOS too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding the subset validation: Viktor and me took a look and it seems a little more complicated to add than expected. We'll do it in a separate PR.

eng/native/naming.props Outdated Show resolved Hide resolved
<watchOS64_32VersionMin>5.1</watchOS64_32VersionMin>
<macOSVersionMin>10.13</macOSVersionMin>

<!-- Version of the OS SDK we target -->
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, why are these set to empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

Some Apple tools embed certain pieces of metadata differently depending on whether you build against /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk or /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk (the former is a symlink to the latter).

On CI we want to build with the explicit version so we pass in the versions installed on the bots. Locally we don't really care about that and hardcoding the version in the file would just mean you need to change it whenever Xcode is updated, so we rely on the symlink there.

I know MSBuild doesn't require you to declare properties if they're empty but I felt it serves as a good documentation that they're used/available.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. Thanks for explaining.

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

Other than a few comments/questions, the infra changes LGTM.

@akoeplinger
Copy link
Member Author

dotnet-runtime-perf failures are due to #33082.

@akoeplinger akoeplinger merged commit a54d391 into dotnet:master Mar 11, 2020
@akoeplinger akoeplinger deleted the add-ios branch March 11, 2020 23:55
@steveisok steveisok mentioned this pull request Mar 11, 2020
24 tasks
@@ -0,0 +1,272 @@
/*
* Copyright (c) 2000-2008 Apple Inc. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we discussed with @richlander and we'll take care of that.

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

discussed various additions to this PR offline with @akoeplinger, like the necessity of the installer subset at a later point for the runtime pack to build. The subset validation as well should be enabled later. LGTM. Thanks!

akoeplinger pushed a commit that referenced this pull request Mar 17, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
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.