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 mergeable libraries support to dynamic libraries #4381

Merged
merged 5 commits into from
Oct 2, 2024

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Sep 30, 2024

📜 Description

  • Add make_mergable linker flags to supported SDKs

From the ld manual:

man ld | col -b | open -tf
Mergeable Library Options
 -make_mergeable
     Adds additional metadata to a dylib which makes it a mergeable
     library.  It can still be used as a dylib, or can be merged into
     other binaries when they link it with a -merge* option.

Also, users have to build with Xcode >= 15.

When you include your mergeable library in an XCFramework, Xcode adds the key MergeableMetadata to the XCFramework’s Info.plist file to indicate to other projects that your library in the XCFramework is mergeable. You can only use XCFrameworks with mergeable metadata in Xcode 15 and later; in earlier versions, Xcode returns a build error.

💡 Motivation and Context

Users can enable mergable libraries featue for dynamic sentry frameworks.

See https://developer.apple.com/documentation/xcode/configuring-your-project-to-use-mergeable-libraries for more info.

💚 How did you test it?

Closes #3719

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@denrase denrase changed the title enable mergabel librabry for build artifacts Add mergeable libraries support to dynamic libraries Sep 30, 2024
Copy link

github-actions bot commented Sep 30, 2024

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against e0c76f7

@denrase
Copy link
Collaborator Author

denrase commented Sep 30, 2024

Created a new PR which only enables mergeable libraries for the xcframeworks we build for SPM usage. (See #4367 for more info)

Reasons:

  • Setting -Wl,-make_mergeable in the SDK.xcconfig has the side effect that no CI using Xcode < 15 is working anymore.

So we'd need to bump all CI to at least macos-14 and Xcode 15.2. Building with fastlane only worked with macos-14 and Xcode 16.

  • Setting the MERGEABLE_LIBRARY key instead results in failed watchOS builds, even if set to no.
error: Mergeable libraries are not supported for architecture 'armv7k', but MERGEABLE_LIBRARY is assigned at level: project-xcconfig. (in target 'Sentry' from project 'Sentry')

Conditionals are not supported, and we cannot create xcconfig files based on platform.

So this is the least invasive way to add support for mergeable libraries. Still there's the large caviat that users need to use Xcode >= 15, so we need to consider this before merging.

@denrase denrase marked this pull request as ready for review September 30, 2024 14:47
@denrase denrase requested a review from brustolin October 1, 2024 09:26
Copy link
Contributor

@brustolin brustolin left a comment

Choose a reason for hiding this comment

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

Thanks @denrase, LGTM

@denrase denrase merged commit fd458ae into main Oct 2, 2024
20 checks passed
@denrase denrase deleted the feat/mergable-librabry-for-build-artifacts-only branch October 2, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable "mergeable library" feature
2 participants