File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1096,6 +1096,10 @@ function(_add_swift_library_single target name)
1096
1096
set_target_properties ("${target} "
1097
1097
PROPERTIES
1098
1098
INSTALL_RPATH "$ORIGIN:/usr/lib/swift/cygwin" )
1099
+ elseif ("${SWIFTLIB_SINGLE_SDK} " STREQUAL "ANDROID" )
1100
+ # CMake generates incorrect rule `$SONAME_FLAG $INSTALLNAME_DIR$SONAME` for Android build on macOS cross-compile host.
1101
+ # Proper linker flags constructed manually. See below variable `swiftlib_link_flags_all`.
1102
+ set_target_properties ("${target} " PROPERTIES NO_SONAME TRUE )
1099
1103
endif ()
1100
1104
1101
1105
set_target_properties ("${target} " PROPERTIES BUILD_WITH_INSTALL_RPATH YES )
@@ -1882,6 +1886,16 @@ function(add_swift_target_library name)
1882
1886
NOT ${name} STREQUAL swiftRemoteMirror )
1883
1887
list (APPEND swiftlib_link_flags_all "-Wl,-z,defs" )
1884
1888
endif ()
1889
+ # Setting back linker flags which are not supported when making Android build on macOS cross-compile host.
1890
+ if (SWIFTLIB_SHARED )
1891
+ if (sdk IN_LIST SWIFT_APPLE_PLATFORMS )
1892
+ list (APPEND swiftlib_link_flags_all "-dynamiclib -Wl,-headerpad_max_install_names" )
1893
+ elseif (sdk STREQUAL ANDROID )
1894
+ list (APPEND swiftlib_link_flags_all "-shared" )
1895
+ # TODO: Instead of `lib${name}.so` find variable or target property which already have this value.
1896
+ list (APPEND swiftlib_link_flags_all "-Wl,-soname,lib${name} .so" )
1897
+ endif ()
1898
+ endif ()
1885
1899
1886
1900
set (sdk_supported_archs
1887
1901
${SWIFT_SDK_${sdk}_ARCHITECTURES}
Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ macro(swift_common_standalone_build_config_llvm product)
114
114
# add_swift_host_library and add_swift_target_library within AddSwift.cmake.
115
115
string (REGEX REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} " )
116
116
string (REGEX REPLACE "-Wl,-z,nodelete" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} " )
117
+ # Android build on macOS cross-compile host don't support `-Wl,-headerpad_max_install_names` and `-dynamiclib` as a linker flags.
118
+ string (REGEX REPLACE "-Wl,-headerpad_max_install_names" "" CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} " )
119
+ string (REGEX REPLACE "-dynamiclib" "" CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} " )
117
120
118
121
set (PACKAGE_VERSION "${LLVM_PACKAGE_VERSION} " )
119
122
string (REGEX REPLACE "([0-9]+)\\ .[0-9]+(\\ .[0-9]+)?" "\\ 1" PACKAGE_VERSION_MAJOR
You can’t perform that action at this time.
0 commit comments