forked from SwiftAndroid/swift
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: Changes to allow libicu be statically linked as well as libc…
…++_static This merges with prior FindICU.cmake changes which allow for ICU to be static libraries. This change is needed for Android because dynamically linking libicu is not reliable on Android. There are multiple problems: - libICU is sometimes an internal/private component on Android. In some cases it appears that tryiing to LoadLibrary on libICU will silently skip because the OS already has one loaded. If the symbol names don't match, you get unresolved symbol errors at runtime resulting from a crash without a good understanding why. (This happened to me on my Nexus 7 2013 with 5.0.2). And if the symbols match, but the versions are different, you may have even tougher problems. - If your application needs ICU, you now run the risk of having conflicting versions of ICU. This is a particular risk for middleware where the user may have not built Swift themselves. - Dealing with loading the ICU dependencies is annoying on Android because you must write Java code to load all the libraries, and in the correct order. And your build process must also be aware of all the depenencies so all the .so's get packaged. So static linking ICU solves all these problems. But additionally, the issue of linking the C++ standard library becomes an issue. Again, there are similar issues with dynamically linking because Android doesn't provide a pre-installed system-wide one we can rely on. Additionally: - Android actually provides 3 or 4 different C++ standard libraries you can pick from, all of which are incompatible with each other. - Every new NDK release risks a new version of each of the standard libraries which breaks binary compatibility. If the user is just using the Swift compiler and doesn't think about these issues, this may cause hard problems. - Also, statically linking ICU caused building command line executables (tests) to fail with unresolved symbols. Statically linking C++ fixes this problem and the original behavior is preserved. So static linking solves these problems too. Two new switches are needed to build for Android: --android-icu-data-include /path/to/include --android-icu-data /path/to/libicudata
- Loading branch information
Showing
7 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters