-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
Conversation
…a install". Disables "lipo / fat binary" routines to avoid build error for Android builds.
@swift-ci Please test |
I'm not sure I understand this. The lipo path is already severed on any non-MachO target, all it does is a copy. The path is still present for uniformity. |
In current implementation four files ( That's why I disabled LIPO routines for Android.
|
Here is some information: ABI Management on the Android Platform
So, this PR eliminate unneeded LIPO routines since Android organises fat APKs in a way so that each library resides under a directory whose name matches a corresponding ABI. |
Ah, I see what you mean. The architecture variant support is currently broken and laying it out that way doesn’t really make things easier to rework. I would rather that you work to remove the copy operation in https://github.com/apple/swift/blob/master/cmake/modules/AddSwift.cmake#L635 instead. |
Ok. I will try to leave LIPO routines untouched. Instead will try to avoid copy operation. |
I removed copy operation in LIPO routines. In two places we still need to check for |
CC: @drodriguez |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the diff is very difficult to figure out if something will work or not.
Many people have tried this, and we have fail for one or other reason. My last try is at #19432. There's a lot more pieces there. I will have to remember what each one was doing. One thing that I think might not work for free is that the Swift compiler only looks in lib/foo.so
, and not in lib/{arch}/foo.so
. That's why the copy still has to happen, and the install copied the “fat” file. In the mentioned PR there's also changes in the compiler to take that movement into account, but worst part is that other projects hardcode lib/
, and need to be changed in a compatible way too (I did some of those PRs, and I think I remember one being accepted, but later being reverted).
I don’t think that old PR will apply cleanly anymore, but maybe you want to review it and incorporate ideas from it into this. Maybe applying it only to Android is a way, but if you want to catch all the little problems, I might suggest using Linux as the test bed. It might uncover a lot of things.
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${source_binaries}" "${LIPO_OUTPUT}" | ||
CUSTOM_TARGET_NAME "${LIPO_TARGET}" | ||
OUTPUT "${LIPO_OUTPUT}" | ||
DEPENDS ${source_targets}) |
There was a problem hiding this comment.
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.
@@ -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. |
There was a problem hiding this comment.
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.
@@ -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}) |
There was a problem hiding this comment.
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.
Thank you! The PR #19432 contains changes which helps to solve problem in general. This PR addressed only small thing, only for concrete platform (Android). Due CMake configuration complexity (for Swift and CoreLibs) it might take me a lot of time to understand and apply changes from #19432. What I can do (for this PR) is following:
|
I would be happy if you can confirm that the Swift compiler will look in the per-architecture directories for the linking phase. I know it does for the compiling phase, but some of the changes in #19432 were related to teach the compiler where to find the linker dependencies. If you have questions about the changes there, don’t hesitate to ask me. PS: If you don’t have a Linux box at hand, do not worry about it. I mention it was the easier way because it is if you have the box already. In other case, it is more hassle, if you keep your changes gated to Android, it should not affect the Linux builds at all. |
Thats why this PR completely disables LIPO-routines for Android.
Here is a current implementation of function for making FAT-binary (
cmake/modules/AddSwift.cmake
)cmake_install.cmake
files. For example below the fileswift/android/libswiftSwiftOnoneSupport.dylib
used instead ofswift/android/armv7/libswiftSwiftOnoneSupport.so