Skip to content

[Android] Fixes wrong paths to so-files. Disables LIPO-routines for Android. #25682

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
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
40 changes: 23 additions & 17 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,6 @@ function(_add_swift_lipo_target)
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
OUTPUT "${LIPO_OUTPUT}"
DEPENDS ${source_targets})
else()
# We don't know how to create fat binaries for other platforms.
add_custom_command_target(unused_var
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${source_binaries}" "${LIPO_OUTPUT}"
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
OUTPUT "${LIPO_OUTPUT}"
DEPENDS ${source_targets})
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: One thing I did here is adding a precondition. If someone were to add a new call to _add_swift_lipo_target, CMake will refuse to generate for any SDK which is not Darwin.

endif()
endfunction()

Expand Down Expand Up @@ -2006,7 +1999,7 @@ function(add_swift_target_library name)
endif()
endif()

if(NOT SWIFTLIB_OBJECT_LIBRARY)
if(NOT SWIFTLIB_OBJECT_LIBRARY AND sdk IN_LIST SWIFT_APPLE_PLATFORMS)
# Add dependencies on the (not-yet-created) custom lipo target.
Copy link
Contributor

Choose a reason for hiding this comment

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

You obviously do not have to add dependencies to the lipo targets, but you need to add dependencies to the architecture specific targets. A full CMake build might even fail if some dependent tries to be built before a dependency, but partial builds will be specially affected.

foreach(DEP ${SWIFTLIB_LINK_LIBRARIES})
if (NOT "${DEP}" STREQUAL "icucore")
Expand Down Expand Up @@ -2081,15 +2074,17 @@ function(add_swift_target_library name)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND SWIFTLIB_SHARED)
set(codesign_arg CODESIGN)
endif()
precondition(THIN_INPUT_TARGETS)
_add_swift_lipo_target(SDK
${sdk}
TARGET
${lipo_target}
OUTPUT
${UNIVERSAL_LIBRARY_NAME}
${codesign_arg}
${THIN_INPUT_TARGETS})
if(sdk IN_LIST SWIFT_APPLE_PLATFORMS)
precondition(THIN_INPUT_TARGETS)
_add_swift_lipo_target(SDK
${sdk}
TARGET
${lipo_target}
OUTPUT
${UNIVERSAL_LIBRARY_NAME}
${codesign_arg}
${THIN_INPUT_TARGETS})
endif()

# Cache universal libraries for dependency purposes
set(UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}
Expand Down Expand Up @@ -2128,6 +2123,17 @@ function(add_swift_target_library name)
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${SWIFT_PRIMARY_VARIANT_ARCH}"
COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}"
PERMISSIONS ${file_permissions})
elseif(sdk STREQUAL ANDROID)
foreach(arch ${SWIFT_SDK_ANDROID_ARCHITECTURES})
Copy link
Contributor

@drodriguez drodriguez Jun 25, 2019

Choose a reason for hiding this comment

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

@compnerd: do you remember why on the Windows branch you went with the primary variant architecture, instead of installing all of them? Below, around L2144 you do copy all architectures for the import libraries, for example.

There might be a way of doing all non Darwin SDKs in the same way (Linux might also benefit from multi-architectures). One can use ${sdk_supported_archs} or ${SWIFT_SDK_${sdk}_ARCHITECTURES} for the architecture list.

if(SWIFTLIB_SHARED)
set(UNIVERSAL_LIBRARY_NAME "${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}/${CMAKE_SHARED_LIBRARY_PREFIX}${name}.so")
endif()
swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${arch}"
COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}"
PERMISSIONS ${file_permissions}
"${optional_arg}")
endforeach()
else()
swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}"
Expand Down