Skip to content

Allow cross-compile Android while compiling libicu in Linux. #20083

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1834,8 +1834,13 @@ function(add_swift_target_library name)

foreach(lib ${SWIFTLIB_PRIVATE_LINK_LIBRARIES})
if("${lib}" STREQUAL "ICU_UC")
list(APPEND swiftlib_private_link_libraries_targets
"${SWIFT_${sdk}_${arch}_ICU_UC}")
if("${sdk}" STREQUAL "ANDROID" OR "${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
list(APPEND swiftlib_private_link_libraries_targets
"${SWIFT_${sdk}_${arch}_ICU_UC}")
else()
list(APPEND swiftlib_private_link_libraries_targets -licuucswift -licudataswift)
endif()

# temporary fix for atomic needing to be
# after object files for libswiftCore.so
if("${sdk}" STREQUAL "ANDROID")
Expand All @@ -1848,8 +1853,12 @@ function(add_swift_target_library name)
"${SWIFTLIB_DIR}/clang/lib/freebsd/libclang_rt.builtins-${arch}.a")
endif()
elseif("${lib}" STREQUAL "ICU_I18N")
list(APPEND swiftlib_private_link_libraries_targets
"${SWIFT_${sdk}_${arch}_ICU_I18N}")
if("${sdk}" STREQUAL "ANDROID" OR "${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
list(APPEND swiftlib_private_link_libraries_targets
"${SWIFT_${sdk}_${arch}_ICU_I18N}")
else()
list(APPEND swiftlib_private_link_libraries_targets -licui18nswift)
endif()
elseif(TARGET "${lib}${VARIANT_SUFFIX}")
list(APPEND swiftlib_private_link_libraries_targets
"${lib}${VARIANT_SUFFIX}")
Expand Down
7 changes: 1 addition & 6 deletions stdlib/public/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,7 @@ else()
# effort has been completed.
#set(LINK_FLAGS
# -Wl,--whole-archive swiftRuntime -Wl,--no-whole-archive)
if("${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
list(APPEND swift_core_private_link_libraries
ICU_UC ICU_I18N)
else()
list(APPEND swift_core_private_link_libraries -licui18nswift -licuucswift -licudataswift)
endif()
list(APPEND swift_core_private_link_libraries ICU_UC ICU_I18N)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think ICU_UC and ICU_I18N are actually the correct variables I think it should be ICU_UC_LIBRARIES and ICU_I18N_LIBRARIES

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to my explanation above, this is just following the previous code. The code uses those values (they are not variables) as sigils for linking the ICU libraries. When those sigils are found in AddSwift.cmake, the right thing is done: for most SDKs ${SWIFT_${sdk}_${arch}_ICU_UC} and similar are used, but if one provided ${SWIFT_PATH_TO_LIBICU_BUILD}, the normal -licuuc flags are used (since the path will be in the library search path).


if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
Expand Down