termux-packages/packages/swift/swift-cmake.patch

136 lines
6.4 KiB
Diff
Raw Normal View History

diff --git a/swift/CMakeLists.txt b/swift/CMakeLists.txt
2021-01-14 16:12:45 +01:00
index b7503ecdd6..c643c2c9a5 100644
--- a/swift/CMakeLists.txt
+++ b/swift/CMakeLists.txt
2021-01-14 16:12:45 +01:00
@@ -165,6 +165,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUA
set(SWIFT_USE_LINKER_default "lld")
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_USE_LINKER_default "")
+elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID")
+ set(SWIFT_USE_LINKER_default "lld")
else()
set(SWIFT_USE_LINKER_default "gold")
endif()
2021-01-14 16:12:45 +01:00
diff --git a/swift/localization/CMakeLists.txt b/swift/localization/CMakeLists.txt
index 07a3585a66c..461a98b6856 100644
--- a/swift/localization/CMakeLists.txt
+++ b/swift/localization/CMakeLists.txt
@@ -1,3 +1,4 @@
+if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
set(diagnostic_witness "${CMAKE_BINARY_DIR}/share/swift/diagnostics/generated")
2021-01-14 16:12:45 +01:00
add_custom_command(
@@ -32,3 +33,4 @@ swift_install_in_component(
PATTERN "*.db"
PATTERN "*.yaml"
)
+endif()
diff --git a/swift/stdlib/public/Platform/CMakeLists.txt b/swift/stdlib/public/Platform/CMakeLists.txt
2020-09-07 18:23:03 +02:00
index 8ded40c5791..c811000b1d1 100644
--- a/swift/stdlib/public/Platform/CMakeLists.txt
+++ b/swift/stdlib/public/Platform/CMakeLists.txt
2020-09-07 18:23:03 +02:00
@@ -97,6 +97,7 @@ foreach(sdk ${SWIFT_SDKS})
OUTPUT "${glibc_modulemap_out}"
FLAGS
"-DCMAKE_SDK=${sdk}"
+ "-DTERMUX_INCLUDE_PATH=@TERMUX_PREFIX@/include"
"-DGLIBC_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}"
"-DGLIBC_ARCH_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}")
2020-09-07 18:23:03 +02:00
@@ -106,18 +107,19 @@ foreach(sdk ${SWIFT_SDKS})
# with its own native sysroot, create a native modulemap without a sysroot
# prefix. This is the one we'll install instead.
if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}" STREQUAL "/" AND
- NOT (${sdk} STREQUAL ANDROID AND NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL ""))
+ (${sdk} STREQUAL ANDROID AND NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL ""))
set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/glibc.modulemap")
- string(REPLACE "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}"
- "" absolute_libc_include_path "${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")
- string(REPLACE "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}"
- "" absolute_libc_arch_include_path ${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY})
+ string(REPLACE "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr"
+ "@TERMUX_PREFIX@" absolute_libc_include_path "${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")
+ string(REPLACE "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr"
+ "@TERMUX_PREFIX@" absolute_libc_arch_include_path ${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY})
handle_gyb_source_single(glibc_modulemap_native_target
SOURCE "${glibc_modulemap_source}"
OUTPUT "${glibc_sysroot_relative_modulemap_out}"
FLAGS "-DCMAKE_SDK=${sdk}"
+ "-DTERMUX_INCLUDE_PATH=@TERMUX_PREFIX@/include"
"-DGLIBC_INCLUDE_PATH=${absolute_libc_include_path}"
"-DGLIBC_ARCH_INCLUDE_PATH=${absolute_libc_arch_include_path}")
2021-01-14 16:12:45 +01:00
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
index 38191b01a64..1f851d3409c 100644
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
@@ -397,6 +397,9 @@ function(_add_target_variant_link_flags)
list(APPEND result "-Wl,-Bsymbolic")
elseif("${LFLAGS_SDK}" STREQUAL "ANDROID")
list(APPEND link_libraries "dl" "log")
+ if(LFLAGS_ARCH STREQUAL "armv7")
+ list(APPEND link_libraries "atomic")
+ endif()
# We need to add the math library, which is linked implicitly by libc++
list(APPEND result "-lm")
2020-09-07 18:23:03 +02:00
diff --git a/swift/stdlib/public/SwiftShims/CMakeLists.txt b/swift/stdlib/public/SwiftShims/CMakeLists.txt
index 23ac72bcda5..23aecfc9bc5 100644
--- a/swift/stdlib/public/SwiftShims/CMakeLists.txt
+++ b/swift/stdlib/public/SwiftShims/CMakeLists.txt
2020-11-13 07:58:40 +01:00
@@ -207,13 +207,13 @@ endif()
2020-09-07 18:23:03 +02:00
swift_install_symlink_component(clang-resource-dir-symlink
LINK_NAME clang
- TARGET ../clang/${CLANG_VERSION}
+ TARGET ../clang/$ENV{TERMUX_CLANG_VERSION}
DESTINATION "lib/swift")
2020-11-13 07:58:40 +01:00
if(SWIFT_BUILD_STATIC_STDLIB)
swift_install_symlink_component(clang-resource-dir-symlink
LINK_NAME clang
- TARGET ../clang/${CLANG_VERSION}
+ TARGET ../clang/$ENV{TERMUX_CLANG_VERSION}
DESTINATION "lib/swift_static")
endif()
diff --git a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake b/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
2020-09-07 18:23:03 +02:00
index 7a77e125f95..7eddfea2054 100644
--- a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
+++ b/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
2020-09-07 18:23:03 +02:00
@@ -79,6 +79,9 @@ function(add_sourcekit_default_compiler_flags target)
endif()
target_compile_options(${target} PRIVATE
2021-01-14 16:12:45 +01:00
-fblocks)
2020-09-07 18:23:03 +02:00
+ # Look in Termux sysroot for dispatch/dispatch.h from libdispatch
+ target_include_directories("${target}" SYSTEM PRIVATE
+ ${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include)
2021-01-14 16:12:45 +01:00
endfunction()
# Add a new SourceKit library.
2020-09-07 18:23:03 +02:00
@@ -165,7 +168,7 @@ macro(add_sourcekit_library name)
endif()
endif()
2020-09-07 18:23:03 +02:00
- if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID")
if(SOURCEKITLIB_SHARED)
set_target_properties(${name} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
2021-01-14 16:12:45 +01:00
set_target_properties(${name} PROPERTIES INSTALL_RPATH "$ORIGIN/../lib/swift/linux")
2020-09-07 18:23:03 +02:00
diff --git a/swift/tools/libSwiftSyntaxParser/CMakeLists.txt b/swift/tools/libSwiftSyntaxParser/CMakeLists.txt
index 42dda212164..2338df9072a 100644
--- a/swift/tools/libSwiftSyntaxParser/CMakeLists.txt
+++ b/swift/tools/libSwiftSyntaxParser/CMakeLists.txt
@@ -13,6 +13,9 @@ add_swift_host_library(libSwiftSyntaxParser SHARED
if(NOT SWIFT_BUILT_STANDALONE AND NOT CMAKE_C_COMPILER_ID MATCHES Clang)
add_dependencies(libSwiftSyntaxParser clang)
endif()
+# Look in Termux sysroot for Block.h from libdispatch
+target_include_directories(libSwiftSyntaxParser SYSTEM PRIVATE
+ ${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include)
target_link_libraries(libSwiftSyntaxParser PRIVATE
swiftParse)
set_target_properties(libSwiftSyntaxParser