Skip to content

Commit 6175385

Browse files
committed
[android] Link with static C++ ABI for Android.
Normally, the C++ shared library would have link against the C++ ABI shared library, but the Android NDK does not distribute the later, so one need to link manually against the static C++ ABI from the NDK.
1 parent ee39236 commit 6175385

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,14 @@ function(_add_variant_link_flags)
432432
# we need to add the math library, which is linked implicitly by libc++.
433433
list(APPEND result "-nostdlib++" "-lm")
434434
if("${LFLAGS_ARCH}" MATCHES armv7)
435-
list(APPEND result "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so")
435+
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a")
436436
elseif("${LFLAGS_ARCH}" MATCHES aarch64)
437-
list(APPEND result "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so")
437+
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a")
438438
else()
439439
message(SEND_ERROR "unknown architecture (${LFLAGS_ARCH}) for android")
440440
endif()
441+
list(APPEND link_libraries "${android_libcxx_path}/libc++abi.a")
442+
list(APPEND link_libraries "${android_libcxx_path}/libc++_shared.so")
441443
swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
442444
foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
443445
list(APPEND library_search_directories ${path})

0 commit comments

Comments
 (0)