Skip to content

Android Intel 32/64 bit (i.e. Android Simulator) support. #25098

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

Merged
Merged
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
4 changes: 4 additions & 0 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ function(_add_variant_link_flags)
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a")
elseif("${LFLAGS_ARCH}" MATCHES aarch64)
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a")
elseif("${LFLAGS_ARCH}" MATCHES i686)
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/x86")
elseif("${LFLAGS_ARCH}" MATCHES x86_64)
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/x86_64")
else()
message(SEND_ERROR "unknown architecture (${LFLAGS_ARCH}) for android")
endif()
Expand Down
4 changes: 4 additions & 0 deletions cmake/modules/SwiftAndroidSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ function(swift_android_lib_for_arch arch var)
list(APPEND paths "${_prebuilt}/${_host}/lib/armv7-a")
elseif(arch STREQUAL aarch64)
list(APPEND paths "${_prebuilt}/${_host}/lib64")
elseif(arch STREQUAL i686)
list(APPEND paths "${_prebuilt}/${_host}/lib")
elseif(arch STREQUAL x86_64)
list(APPEND paths "${_prebuilt}/${_host}/lib64")
else()
message(SEND_ERROR "unknown architecture (${arch}) for android")
endif()
Expand Down
20 changes: 19 additions & 1 deletion cmake/modules/SwiftConfigureSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ macro(configure_sdk_unix name architectures)
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "aarch64")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm64")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "aarch64-unknown-linux-android")
elseif("${arch}" STREQUAL "i686")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "i686-linux-android")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "i686")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-x86")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "i686-unknown-linux-android")
elseif("${arch}" STREQUAL "x86_64")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "x86_64-linux-android")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "x86_64")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-x86_64")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "x86_64-unknown-linux-android")
Copy link
Member

Choose a reason for hiding this comment

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

I know that you are trying to match the surrounding code, but no point in the ${arch} substitution here, just spell it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't get .)

I am building swift with the following architectures:

-DSWIFT_SDK_ANDROID_ARCHITECTURES="armv7;aarch64;i686;x86_64"

Without changes above cmake will raise error:

CMake Error at cmake/modules/SwiftConfigureSDK.cmake:190 (message):
  unknown arch for android SDK: i686

Or you mean that triples x86_64-unknown-linux-android and i686-unknown-linux-android is not something expected?

Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think he means that instead of SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE you can write SWIFT_SDK_ANDROID_ARCH_x86_64_TRIPLE.

Personally, I prefer the ${arch} in the middle because it is easier for copy/pasting in new architectures, and also because it avoids typos in the name of the variables.

else()
message(FATAL_ERROR "unknown arch for android SDK: ${arch}")
endif()
Expand All @@ -196,8 +206,16 @@ macro(configure_sdk_unix name architectures)
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
set(_swift_android_prebuilt_build "linux-x86_64")
endif()
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
if("${arch}" STREQUAL "i686")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
"${SWIFT_ANDROID_NDK_PATH}/toolchains/x86-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
elseif("${arch}" STREQUAL "x86_64")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
"${SWIFT_ANDROID_NDK_PATH}/toolchains/x86_64-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
else()
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
Copy link
Member

Choose a reason for hiding this comment

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

Can we not use ${SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING}-${SWIFT_ANDROID_NDK_GCC_VERSION} instead?

Copy link
Contributor Author

@vgorloff vgorloff May 29, 2019

Choose a reason for hiding this comment

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

This is what I getting:

  • arm-4.9 NOT matching $NDK/toolchains value arm-linux-androideabi-4.9
  • aarch64-4.9 NOT matching $NDK/toolchains value arm-linux-androideabi-4.9
  • i686-4.9 NOT matching $NDK/toolchains value x86-4.9
  • x86_64-4.9 is matching $NDK/toolchains value x86_64-4.9

So, expression ${SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING}-${SWIFT_ANDROID_NDK_GCC_VERSION} not resolving to proper real path in $NDK/toolchains.

Details of cmake log:

>>>
message(${SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING}-${SWIFT_ANDROID_NDK_GCC_VERSION})
arm-4.9
<<<
>>>
message(${SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING}-${SWIFT_ANDROID_NDK_GCC_VERSION})
aarch64-4.9
<<<
>>>
message(${SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING}-${SWIFT_ANDROID_NDK_GCC_VERSION})
i686-4.9
<<<
>>>
message(${SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING}-${SWIFT_ANDROID_NDK_GCC_VERSION})
x86_64-4.9
<<<

"${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
endif()
else()
if(NOT SWIFT_SDK_${prefix}_ARCH_${arch}_PATH)
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "/")
Expand Down