From 7e67bd49f845377242903a6f0016a3546aac0055 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 14 Jun 2019 22:06:39 -0700 Subject: [PATCH 1/2] build: allow passing Swift specific link flags This mirrors the `CMAKE_SWIFT_FLAGS` allowing control over the flags passed to the linker. This is needed until the libraries are built with a newer CMake which supports Swift properly. This enables cross-compiling libdispatch for Android on Windows. --- cmake/modules/SwiftSupport.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/SwiftSupport.cmake b/cmake/modules/SwiftSupport.cmake index 031627c9c..ead1958b8 100644 --- a/cmake/modules/SwiftSupport.cmake +++ b/cmake/modules/SwiftSupport.cmake @@ -9,7 +9,7 @@ function(add_swift_target target) cmake_parse_arguments(AST "${options}" "${single_value_options}" "${multiple_value_options}" ${ARGN}) set(compile_flags ${CMAKE_SWIFT_FLAGS}) - set(link_flags) + set(link_flags ${CMAKE_SWIFT_LINK_FLAGS}) if(AST_TARGET) list(APPEND compile_flags -target;${AST_TARGET}) From 05a60bad53af55532fb0d0b18b72be6f3b53fc53 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 14 Jun 2019 22:12:54 -0700 Subject: [PATCH 2/2] build: spell the linker suffix properly on Windows Windows requires that the .exe suffix be present to use the tools from the Android NDK. --- src/CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c2fa8fa64..38b69fd73 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -116,9 +116,17 @@ if(ENABLE_SWIFT) POSITION_INDEPENDENT_CODE YES) if(USE_LLD_LINKER) - set(use_ld_flag -use-ld=lld) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) + set(use_ld_flag -use-ld=lld.exe) + else() + set(use_ld_flag -use-ld=lld) + endif() elseif(USE_GOLD_LINKER) - set(use_ld_flag -use-ld=gold) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) + set(use_ld_flag -use-ld=gold.exe) + else() + set(use_ld_flag -use-ld=gold) + endif() endif() add_swift_library(swiftDispatch