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

[RKOTLIN-877] Avoid exporting Core's symbols to allow mixing multiple SDKs #1780

Merged
merged 8 commits into from
Jul 6, 2024

Conversation

nhachicha
Copy link
Collaborator

The cinterop KLIB includes compiled core's static libraries that will be used by the linker to build the final app. This PR will avoid exporting Core's symbols so if the user adds another SDK
like Swift to their app then build/link statically the Swift app the two versions of Core will not conflicts

Most of the work was testing with MultiplatformDemo and MultiplatformDemoWithSync while adding a POD dependency to Swift SDK and using two Realms using two version of Core inside the same iOS app.

when building such app the dynamic framweork build from Kotlin/Native should not include any Core symbols like the following:

xcrun dyldinfo  ../shared/build/bin/ios/podDebugFramework/shared.framework/shared -weak_bind  | c++filt
weak binding information:
segment section          address       type     addend symbol
__DATA  __la_symbol_ptr  0x00A3C168    pointer       0 _Konan_DebugBuffer
__DATA  __la_symbol_ptr  0x00A3C170    pointer       0 _Konan_DebugBufferSize
__DATA  __la_symbol_ptr  0x00A3C178    pointer       0 _Konan_DebugObjectToUtf8Array
__DATA_CONST __got            0x0090C1C0    pointer       0 typeinfo for std::length_error
__DATA_CONST __got            0x0090C1C8    pointer       0 typeinfo for std::out_of_range
__DATA_CONST __got            0x0090C1D8    pointer       0 typeinfo for std::overflow_error
__DATA_CONST __const          0x009FB878    pointer       0 typeinfo for std::overflow_error
__DATA_CONST __got            0x0090C1E0    pointer       0 typeinfo for std::invalid_argument
__DATA_CONST __const          0x00A0FCC0    pointer       0 typeinfo for std::invalid_argument
__DATA  __la_symbol_ptr  0x00A3C700    pointer       0 operator delete[](void*)
__DATA  __la_symbol_ptr  0x00A3C708    pointer       0 operator delete(void*)
__DATA  __la_symbol_ptr  0x00A3C710    pointer       0 operator new[](unsigned long)
__DATA  __la_symbol_ptr  0x00A3C718    pointer       0 operator new(unsigned long)
__DATA  __la_symbol_ptr  0x00A3C720    pointer       0 operator new(unsigned long, std::nothrow_t const&)

@nhachicha nhachicha self-assigned this Jun 12, 2024
@cla-bot cla-bot bot added the cla: yes label Jun 12, 2024
@nhachicha nhachicha changed the title Avoid exporting Core's symbols to allow mixing multiple SDKs [RKOTLIN-877] Avoid exporting Core's symbols to allow mixing multiple SDKs Jun 12, 2024
Copy link
Contributor

@clementetb clementetb left a comment

Choose a reason for hiding this comment

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

Awesome, it is great that we have compatibility with other SDKs.

You mention that it was tested by adding the Swift SDK to a sample project. Could we add this project to our examples to track any regression?

Copy link
Contributor

@elle-j elle-j left a comment

Choose a reason for hiding this comment

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

Nice job paving the way! 💪

.github/workflows/pr.yml Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
packages/cinterop/build.gradle.kts Outdated Show resolved Hide resolved
packages/cinterop/build.gradle.kts Outdated Show resolved Hide resolved
@rorbech
Copy link
Contributor

rorbech commented Jun 18, 2024

You mention that it was tested by adding the Swift SDK to a sample project. Could we add this project to our examples to track any regression?

Yeah, sound like something that would be cool to put in the test suite similarly to https://github.com/realm/realm-kotlin/tree/main/examples/realm-java-compatibility

@nhachicha nhachicha merged commit fb796f0 into main Jul 6, 2024
78 checks passed
@nhachicha nhachicha deleted the nh/mixing_sdks branch July 6, 2024 16:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants