@@ -800,6 +800,21 @@ endif()
800800# Should we cross-compile the standard library for Android?
801801is_sdk_requested(ANDROID swift_build_android)
802802if (swift_build_android AND NOT "${SWIFT_ANDROID_NDK_PATH} " STREQUAL "" )
803+ # Get the prebuilt suffix to create the correct toolchain path when using the NDK
804+ if ("${CMAKE_SYSTEM_NAME} " STREQUAL "Darwin" )
805+ set (_swift_android_prebuilt_suffix "darwin-x86_64" )
806+ elseif ("${CMAKE_SYSTEM_NAME} " STREQUAL "Linux" )
807+ set (_swift_android_prebuilt_suffix "linux-x86_64" )
808+ endif ()
809+
810+ set (SWIFT_ANDROID_PREBUILT_PATH
811+ "${SWIFT_ANDROID_NDK_PATH} /toolchains/arm-linux-androideabi-${SWIFT_ANDROID_NDK_GCC_VERSION} /prebuilt/${_swift_android_prebuilt_suffix} " )
812+
813+ # Resolve the correct linker based on the file name of CMAKE_LINKER (being 'ld' or 'ld.gold' the options)
814+ get_filename_component (SWIFT_ANDROID_LINKER_NAME "${CMAKE_LINKER} " NAME )
815+ set (SWIFT_SDK_ANDROID_ARCH_armv7_LINKER
816+ "${SWIFT_ANDROID_NDK_PATH} /toolchains/arm-linux-androideabi-${SWIFT_ANDROID_NDK_GCC_VERSION} /prebuilt/${_swift_android_prebuilt_suffix} /bin/arm-linux-androideabi-${SWIFT_ANDROID_LINKER_NAME} " )
817+
803818 configure_sdk_unix(ANDROID "Android" "android" "android" "armv7" "armv7-none-linux-androideabi" "${SWIFT_ANDROID_SDK_PATH} " )
804819
805820 if (NOT ("${CMAKE_SYSTEM_NAME} " STREQUAL "Darwin" OR "${CMAKE_SYSTEM_NAME} " STREQUAL "Linux" ))
@@ -809,14 +824,6 @@ if(swift_build_android AND NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
809824 set (SWIFT_PRIMARY_VARIANT_SDK_default "ANDROID" )
810825 set (SWIFT_PRIMARY_VARIANT_ARCH_default "armv7" )
811826 endif ()
812-
813- if ("${CMAKE_SYSTEM_NAME} " STREQUAL "Darwin" )
814- set (_swift_android_prebuilt_suffix "darwin-x86_64" )
815- elseif ("${CMAKE_SYSTEM_NAME} " STREQUAL "Linux" )
816- set (_swift_android_prebuilt_suffix "linux-x86_64" )
817- endif ()
818- set (SWIFT_ANDROID_PREBUILT_PATH
819- "${SWIFT_ANDROID_NDK_PATH} /toolchains/arm-linux-androideabi-${SWIFT_ANDROID_NDK_GCC_VERSION} /prebuilt/${_swift_android_prebuilt_suffix} " )
820827endif ()
821828
822829# Should we cross-compile the standard library for Windows?
0 commit comments