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

[release/7.0] Disable objc_msgSend stubs in clang for compatibility with Xcode 13 #91117

Merged

Conversation

akoeplinger
Copy link
Member

Backport of #89932 and #90217 to release/7.0

Customer Impact

As soon as we're updating the macOS build machine image used to build dotnet/runtime to one that uses Xcode 14 the native build of Objective-C code will start emitting objc_msgSend stubs. This causes the native libraries to fail during linking with the linker in Xcode 13, effectively preventing Mac/iOS/tvOS apps from working. Note that this can happen automatically if AzDO updates the macOS build images.

The fix is to disable the objc_msgSend stubs via a compiler flag, following what xamarin-macios did a while ago: xamarin/xamarin-macios#16231

Testing

CI and local testing

Risk

Low. The PR adds an additional compiler flag to every .m Objective-C file to prevent the new Xcode 14 behavior.

@akoeplinger akoeplinger added Servicing-consider Issue for next servicing release review os-mac-os-x macOS aka OSX area-Infrastructure os-ios Apple iOS os-tvos Apple tvOS labels Aug 25, 2023
@akoeplinger akoeplinger added this to the 7.0.x milestone Aug 25, 2023
@ghost ghost assigned akoeplinger Aug 25, 2023
@ghost
Copy link

ghost commented Aug 25, 2023

Tagging subscribers to 'os-ios': @steveisok, @akoeplinger, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #89932 and #90217 to release/7.0

Customer Impact

As soon as we're updating the macOS build machine image used to build dotnet/runtime to one that uses Xcode 14 the native build of Objective-C code will start emitting objc_msgSend stubs. This causes the native libraries to fail during linking with the linker in Xcode 13, effectively preventing Mac/iOS/tvOS apps from working. Note that this can happen automatically if AzDO updates the macOS build images.

The fix is to disable the objc_msgSend stubs via a compiler flag, following what xamarin-macios did a while ago: xamarin/xamarin-macios#16231

Testing

CI and local testing

Risk

Low. The PR adds an additional compiler flag to every .m Objective-C file to prevent the new Xcode 14 behavior.

Author: akoeplinger
Assignees: -
Labels:

Servicing-consider, os-mac-os-x, area-Infrastructure, os-ios, os-tvos

Milestone: 7.0.x

if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS)
# Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand.
# We disable this by passing -fno-objc-msgsend-selector-stubs to clang.
# We can probably remove this flag once we require developers to use Xcode 14.
Copy link
Member

Choose a reason for hiding this comment

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

For my knowledge - Do we have any documentation highlighting minimum supported Xcode versions?

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 found https://learn.microsoft.com/en-us/xamarin/cross-platform/get-started/requirements#macos-requirements but that seems to be a bit outdated and doesn't really mention the Xcode version directly.

The code seems to check for Xcode 6.0 but that is probably way older than is reasonable:
https://github.com/rolfbjarne/xamarin-macios/blob/577af1046738e919e15962b917e065f5589366ef/tools/mtouch/mtouch.cs#L123

@akoeplinger
Copy link
Member Author

Approved by tactics over email. Failures are known issues.

@akoeplinger akoeplinger added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Aug 29, 2023
@akoeplinger akoeplinger merged commit 483490d into dotnet:release/7.0-staging Aug 29, 2023
176 of 185 checks passed
@akoeplinger akoeplinger deleted the objc_msgsend-7.0 branch August 29, 2023 09:08
@ghost ghost locked as resolved and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure os-ios Apple iOS os-mac-os-x macOS aka OSX os-tvos Apple tvOS Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants