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

213 lines
10 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 "")
2021-07-04 19:15:47 +02:00
+elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID" AND NOT "${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "armv7")
2021-01-14 16:12:45 +01:00
+ set(SWIFT_USE_LINKER_default "lld")
else()
set(SWIFT_USE_LINKER_default "gold")
endif()
2021-07-04 19:15:47 +02:00
@@ -463,7 +463,7 @@ set(SWIFT_BUILD_HOST_DISPATCH FALSE)
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
# Only build libdispatch for the host if the host tools are being built and
# specifically if these two libraries that depend on it are built.
- if(SWIFT_INCLUDE_TOOLS AND (SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT))
2021-09-27 13:46:31 +02:00
+ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Android AND SWIFT_INCLUDE_TOOLS AND (SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT))
2021-07-04 19:15:47 +02:00
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
endif()
@@ -976,7 +976,8 @@ if (LLVM_ENABLE_DOXYGEN)
2021-09-27 13:46:31 +02:00
message(STATUS "Doxygen: enabled")
2021-07-04 19:15:47 +02:00
endif()
2021-09-27 13:46:31 +02:00
-if(SWIFT_ENABLE_DISPATCH)
+# Use the Termux libdispatch when cross-compiling instead.
+if(SWIFT_ENABLE_DISPATCH AND ${CMAKE_HOST_SYSTEM_NAME} STREQUAL Android)
include(Libdispatch)
2021-07-04 19:15:47 +02:00
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()
2021-07-04 19:15:47 +02:00
diff --git a/swift/stdlib/public/Concurrency/CMakeLists.txt b/swift/stdlib/public/Concurrency/CMakeLists.txt
index 3313f56c8a6..59804ff6228 100644
--- a/swift/stdlib/public/Concurrency/CMakeLists.txt
+++ b/swift/stdlib/public/Concurrency/CMakeLists.txt
@@ -24,20 +24,11 @@ if(SWIFT_CONCURRENCY_USES_DISPATCH)
2021-07-04 19:15:47 +02:00
# FIXME: we can't rely on libdispatch having been built for the
# target at this point in the process. Currently, we're relying
# on soft-linking.
- list(APPEND swift_concurrency_link_libraries
- dispatch)
+ #list(APPEND swift_concurrency_link_libraries
+ # dispatch)
endif()
endif()
-# Linux requires us to link an atomic library to use atomics.
-# Frustratingly, in many cases this isn't necessary because the
-# sequence is inlined, but we have some code that's just subtle
-# enough to turn into runtime calls.
-if(SWIFT_HOST_VARIANT STREQUAL "android")
- list(APPEND SWIFT_RUNTIME_CONCURRENCY_SWIFT_LINK_FLAGS
- -latomic)
-endif()
-
add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
../CompatibilityOverride/CompatibilityOverride.cpp
Actor.cpp
2021-07-04 19:15:47 +02:00
@@ -87,6 +87,6 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
-Xfrontend -enable-experimental-concurrency
-Xfrontend -define-availability
-Xfrontend \"SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0\"
- LINK_FLAGS "${SWIFT_RUNTIME_CONCURRENCY_SWIFT_LINK_FLAGS}"
+ LINK_FLAGS "${SWIFT_RUNTIME_CONCURRENCY_SWIFT_LINK_FLAGS};-ldispatch"
INSTALL_IN_COMPONENT stdlib
)
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}"
2021-07-04 19:15:47 +02:00
+ "-DTERMUX_INCLUDE_PATH=${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/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"
2021-07-04 19:15:47 +02:00
+ "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr" absolute_libc_include_path "${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")
+ string(REPLACE "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr"
2021-07-04 19:15:47 +02:00
+ "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr" 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}"
2021-07-04 19:15:47 +02:00
+ "-DTERMUX_INCLUDE_PATH=${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/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
@@ -96,7 +96,7 @@ function(_add_target_variant_c_compile_link_flags)
if("${CFLAGS_SDK}" STREQUAL "ANDROID")
# lld can handle targeting the android build. However, if lld is not
# enabled, then fallback to the linker included in the android NDK.
- if(NOT SWIFT_USE_LINKER STREQUAL "lld")
+ if(NOT SWIFT_USE_LINKER STREQUAL "lld" OR "${CFLAGS_ARCH}" STREQUAL "x86_64")
swift_android_tools_path(${CFLAGS_ARCH} tools_path)
list(APPEND result "-B" "${tools_path}")
endif()
@@ -397,6 +397,10 @@ function(_add_target_variant_link_flags)
2021-01-14 16:12:45 +01:00
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")
+ list(APPEND library_search_directories "${SWIFT_SDK_ANDROID_ARCH_${arch}_PATH}/../${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}/lib/armv7-a")
2021-01-14 16:12:45 +01:00
+ 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()
2021-07-04 19:15:47 +02:00
diff --git a/swift/stdlib/public/runtime/CMakeLists.txt b/swift/stdlib/public/runtime/CMakeLists.txt
index 86bb4b9666b..cf293f9f36f 100644
--- a/swift/stdlib/public/runtime/CMakeLists.txt
+++ b/swift/stdlib/public/runtime/CMakeLists.txt
@@ -227,7 +227,7 @@ foreach(sdk ${SWIFT_SDKS})
endif()
set(libpthread -lpthread)
set(android_libraries)
- if(sdk STREQUAL ANDROID)
+ if(${sdk} STREQUAL ANDROID)
set(android_libraries -llog)
set(libpthread)
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