Skip to content

Commit bcf800a

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 5154886 commit bcf800a

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
@@ -434,12 +434,14 @@ function(_add_variant_link_flags)
434434
# we need to add the math library, which is linked implicitly by libc++.
435435
list(APPEND result "-nostdlib++" "-lm")
436436
if("${LFLAGS_ARCH}" MATCHES armv7)
437-
list(APPEND result "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so")
437+
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a")
438438
elseif("${LFLAGS_ARCH}" MATCHES aarch64)
439-
list(APPEND result "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so")
439+
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a")
440440
else()
441441
message(SEND_ERROR "unknown architecture (${LFLAGS_ARCH}) for android")
442442
endif()
443+
list(APPEND link_libraries "${android_libcxx_path}/libc++abi.a")
444+
list(APPEND link_libraries "${android_libcxx_path}/libc++_shared.so")
443445
swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
444446
foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
445447
list(APPEND library_search_directories ${path})

0 commit comments

Comments
 (0)