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

[NativeAOT] Fix iOS library build by linking standard C++ library by default #92114

Merged
merged 2 commits into from
Sep 16, 2023

Conversation

ivanpovazan
Copy link
Member

This PR fixes building an iOS-like NativeAOT libraries by linking standard C++ library by default.

Recently we started statically linking ICU libraries when targeting iOS-like platforms in: #90430
However globalization and ICU support has a dependency on the standard C++ lib which is not included by NativeAOT build integration targets and produces a build error when trying to build NativeAOT iOS library:

Undefined symbols for architecture arm64:
    "std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*))", referenced from:
        void std::__1::call_once<void (&)()>(std::__1::once_flag&, void (&)()) in libicuuc.a(umutex.ao)
        ...

This is not visible when build iOS apps, as we use AppleAppBuilder and Xamarin application bundlers that are taking care of native linking.

NativeAOT with iOS in library mode is not officially supported (this is tracked in: #88737), but this fix is a prerequisite of going in the right direction and unblocking customers who are using the experimental support. The official support for iOS library mode will come in a separate PR.


Fixes: #91997

@ghost
Copy link

ghost commented Sep 15, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR fixes building an iOS-like NativeAOT libraries by linking standard C++ library by default.

Recently we started statically linking ICU libraries when targeting iOS-like platforms in: #90430
However globalization and ICU support has a dependency on the standard C++ lib which is not included by NativeAOT build integration targets and produces a build error when trying to build NativeAOT iOS library:

Undefined symbols for architecture arm64:
    "std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*))", referenced from:
        void std::__1::call_once<void (&)()>(std::__1::once_flag&, void (&)()) in libicuuc.a(umutex.ao)
        ...

This is not visible when build iOS apps, as we use AppleAppBuilder and Xamarin application bundlers that are taking care of native linking.

NativeAOT with iOS in library mode is not officially supported (this is tracked in: #88737), but this fix is a prerequisite of going in the right direction and unblocking customers who are using the experimental support. The official support for iOS library mode will come in a separate PR.


Fixes: #91997

Author: ivanpovazan
Assignees: ivanpovazan
Labels:

area-NativeAOT-coreclr

Milestone: -

@ivanpovazan
Copy link
Member Author

/cc: @steveisok

@ivanpovazan
Copy link
Member Author

/azp run runtime-ioslike

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@steveisok steveisok left a comment

Choose a reason for hiding this comment

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

@ivanpovazan @rolfbjarne this doesn't clash with anything in the iOS sdk, right?

@ivanpovazan
Copy link
Member Author

@ivanpovazan @rolfbjarne this doesn't clash with anything in the iOS sdk, right?

I do not think it should. I manually tested building/running a MAUI iOS sample app by explicitly passing -p:LinkStandardCPlusPlusLibrary=true with the RC1 release and did not have any issues.

@rolfbjarne
Copy link
Member

@ivanpovazan @rolfbjarne this doesn't clash with anything in the iOS sdk, right?

It shouldn't, at most we'd pass the same linker argument twice to the native linker.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

@ivanpovazan
Copy link
Member Author

/backport to release/8.0

@github-actions
Copy link
Contributor

Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/6201366248

@ivanpovazan
Copy link
Member Author

/azp run runtime-ioslike

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ivanpovazan
Copy link
Member Author

The failures are unrelated and are being tracked.

@ivanpovazan ivanpovazan merged commit fa1bf3c into dotnet:main Sep 16, 2023
@ivanpovazan ivanpovazan deleted the fix-naot-ios-lib branch September 18, 2023 09:53
@ghost ghost locked as resolved and limited conversation to collaborators Oct 18, 2023
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.

.NET 8 RC1 fails to NativeAOT compile when targeting ios-arm64
4 participants