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

525 lines
25 KiB
Diff

diff --git a/swift/CMakeLists.txt b/swift/CMakeLists.txt
index 7490e1df821..9a5ec99cba0 100644
--- a/swift/CMakeLists.txt
+++ b/swift/CMakeLists.txt
@@ -944,7 +944,7 @@
message(STATUS "Doxygen: enabled")
endif()
-if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
+if((SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT) AND ${SWIFT_HOST_VARIANT_SDK} MATCHES "OSX|WINDOWS")
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND
CMAKE_C_COMPILER_VERSION VERSION_GREATER 3.8
diff --git a/swift/cmake/modules/AddSwift.cmake b/swift/cmake/modules/AddSwift.cmake
index b40bd4d881e..8c51c6b6857 100644
--- a/swift/cmake/modules/AddSwift.cmake
+++ b/swift/cmake/modules/AddSwift.cmake
@@ -123,6 +123,10 @@ function(_add_variant_c_compile_link_flags)
endif()
endif()
+ if("${CFLAGS_SDK}" STREQUAL "ANDROID")
+ set(DEPLOYMENT_VERSION "${SWIFT_SDK_${CFLAGS_SDK}_DEPLOYMENT_VERSION}")
+ endif()
+
# MSVC, clang-cl, gcc don't understand -target.
if(CMAKE_C_COMPILER_ID MATCHES "^Clang|AppleClang$" AND
NOT SWIFT_COMPILER_IS_MSVC_LIKE)
@@ -480,10 +480,10 @@ function(_add_variant_link_flags)
list(APPEND library_search_directories
${CMAKE_BINARY_DIR}/winsdk_lib_${LFLAGS_ARCH}_symlinks)
elseif("${LFLAGS_SDK}" STREQUAL "HAIKU")
- list(APPEND link_libraries "bsd" "atomic")
+ list(APPEND link_libraries "bsd")
list(APPEND result "-Wl,-Bsymbolic")
elseif("${LFLAGS_SDK}" STREQUAL "ANDROID")
- list(APPEND link_libraries "dl" "log" "atomic")
+ list(APPEND link_libraries "dl" "log")
# We need to add the math library, which is linked implicitly by libc++
list(APPEND result "-lm")
@@ -491,11 +491,6 @@ function(_add_variant_link_flags)
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
list(APPEND link_libraries ${cxx_link_libraries})
- # link against the ICU libraries
- list(APPEND link_libraries
- ${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_I18N}
- ${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_UC})
-
swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
list(APPEND library_search_directories ${path})
diff --git a/swift/cmake/modules/SwiftAndroidSupport.cmake b/swift/cmake/modules/SwiftAndroidSupport.cmake
index 9379031947d..91cecf46a37 100644
--- a/swift/cmake/modules/SwiftAndroidSupport.cmake
+++ b/swift/cmake/modules/SwiftAndroidSupport.cmake
@@ -1,8 +1,7 @@
function(swift_android_libcxx_include_paths var)
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
set(${var}
- "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/include"
- "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++abi/include"
+ "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/include/c++/v1"
PARENT_SCOPE)
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
set(${var}
@@ -89,7 +88,7 @@ function(swift_android_cxx_libraries_for_arch arch libraries_var_name)
message(SEND_ERROR "unknown architecture (${arch}) when cross-compiling for Android")
endif()
- set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/${cxx_arch}")
+ set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/lib/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}")
list(APPEND link_libraries ${android_libcxx_path}/libc++abi.a
${android_libcxx_path}/libc++_shared.so)
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
diff --git a/swift/cmake/modules/SwiftConfigureSDK.cmake b/swift/cmake/modules/SwiftConfigureSDK.cmake
index 3a87bfcd80b..89e9827db6c 100644
--- a/swift/cmake/modules/SwiftConfigureSDK.cmake
+++ b/swift/cmake/modules/SwiftConfigureSDK.cmake
@@ -285,7 +285,7 @@ macro(configure_sdk_unix name architectures)
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "arm-linux-androideabi")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "arm")
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm")
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/sysroot")
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NATIVE_SYSROOT}")
else()
@@ -298,7 +298,7 @@ macro(configure_sdk_unix name architectures)
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "aarch64-linux-android")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "aarch64")
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm64")
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/sysroot")
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NATIVE_SYSROOT}")
else()
@@ -339,8 +339,9 @@ macro(configure_sdk_unix name architectures)
"${SWIFT_ANDROID_NDK_PATH}/toolchains/x86_64-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
else()
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
- "${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
+ "${SWIFT_ANDROID_NDK_PATH}")
endif()
+ set(SWIFT_SDK_ANDROID_DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL})
else()
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "/" CACHE STRING "CMAKE_SYSROOT for ${prefix} ${arch}")
diff --git a/swift/lib/Driver/CMakeLists.txt b/swift/lib/Driver/CMakeLists.txt
index 448f5044b70..e665dfcfefe 100644
--- a/swift/lib/Driver/CMakeLists.txt
+++ b/swift/lib/Driver/CMakeLists.txt
@@ -27,42 +27,3 @@ target_link_libraries(swiftDriver PRIVATE
swiftAST
swiftBasic
swiftOption)
-
-# Generate the static-stdlib-args.lnk file used by -static-stdlib option
-# for 'GenericUnix' (eg linux)
-if(SWIFT_BUILD_STATIC_STDLIB)
- set(static_stdlib_lnk_file_list)
- foreach(sdk ${SWIFT_CONFIGURED_SDKS})
- if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF")
- string(TOLOWER "${sdk}" lowercase_sdk)
- if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB)
- set(ICU_STATICLIB "TRUE")
- else()
- set(ICU_STATICLIB "FALSE")
- find_package(ICU REQUIRED COMPONENTS uc i18n)
- get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARIES}" DIRECTORY)
- get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARIES}" DIRECTORY)
- endif()
- set(linkfile "${lowercase_sdk}/static-stdlib-args.lnk")
- add_custom_command_target(swift_static_stdlib_${sdk}_args
- COMMAND
- "${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args"
- "${sdk}"
- "${SWIFTSTATICLIB_DIR}/${linkfile}"
- "${ICU_STATICLIB}"
- "${ICU_UC_LIBDIR}"
- "${ICU_I18N_LIBDIR}"
- OUTPUT
- "${SWIFTSTATICLIB_DIR}/${linkfile}"
- DEPENDS
- "${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args")
-
- list(APPEND static_stdlib_lnk_file_list ${swift_static_stdlib_${sdk}_args})
- swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
- DESTINATION "lib/swift_static/${lowercase_sdk}"
- COMPONENT stdlib)
- endif()
- endforeach()
- add_custom_target(swift_static_lnk_args ALL DEPENDS ${static_stdlib_lnk_file_list})
- add_dependencies(stdlib swift_static_lnk_args)
-endif()
diff --git a/swift/stdlib/CMakeLists.txt b/swift/stdlib/CMakeLists.txt
index 9f3cf240d3d..d2ce14d5f47 100644
--- a/swift/stdlib/CMakeLists.txt
+++ b/swift/stdlib/CMakeLists.txt
@@ -83,6 +83,43 @@ if(SWIFT_BUILD_STATIC_STDLIB)
else()
list(APPEND SWIFT_STDLIB_LIBRARY_BUILD_TYPES STATIC)
endif()
+
+ # Generate the static-stdlib-args.lnk file used by -static-stdlib option
+ # for 'GenericUnix' (eg linux)
+ set(static_stdlib_lnk_file_list)
+ foreach(sdk ${SWIFT_SDKS})
+ if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF")
+ string(TOLOWER "${sdk}" lowercase_sdk)
+ if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB)
+ set(ICU_STATICLIB "TRUE")
+ else()
+ set(ICU_STATICLIB "FALSE")
+ find_package(ICU REQUIRED COMPONENTS uc i18n)
+ get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARIES}" DIRECTORY)
+ get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARIES}" DIRECTORY)
+ endif()
+ set(linkfile "${lowercase_sdk}/static-stdlib-args.lnk")
+ add_custom_command_target(swift_static_stdlib_${sdk}_args
+ COMMAND
+ "${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args"
+ "${sdk}"
+ "${SWIFTSTATICLIB_DIR}/${linkfile}"
+ "${ICU_STATICLIB}"
+ "${ICU_UC_LIBDIR}"
+ "${ICU_I18N_LIBDIR}"
+ OUTPUT
+ "${SWIFTSTATICLIB_DIR}/${linkfile}"
+ DEPENDS
+ "${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args")
+
+ list(APPEND static_stdlib_lnk_file_list ${swift_static_stdlib_${sdk}_args})
+ swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
+ DESTINATION "lib/swift_static/${lowercase_sdk}"
+ COMPONENT stdlib)
+ endif()
+ endforeach()
+ add_custom_target(swift_static_lnk_args ALL DEPENDS ${static_stdlib_lnk_file_list})
+ add_dependencies(stdlib swift_static_lnk_args)
endif()
function(swift_create_stdlib_targets name variant define_all_alias)
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
index a2f682ece68..95e2c6e8a99 100644
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
@@ -85,6 +85,10 @@ function(_add_target_variant_c_compile_link_flags)
endif()
endif()
+ if("${CFLAGS_SDK}" STREQUAL "ANDROID")
+ set(DEPLOYMENT_VERSION "${SWIFT_SDK_${CFLAGS_SDK}_DEPLOYMENT_VERSION}")
+ endif()
+
# MSVC, clang-cl, gcc don't understand -target.
if(CMAKE_C_COMPILER_ID MATCHES "^Clang|AppleClang$" AND
NOT SWIFT_COMPILER_IS_MSVC_LIKE)
@@ -359,11 +359,6 @@ function(_add_target_variant_link_flags)
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
list(APPEND link_libraries ${cxx_link_libraries})
- # link against the ICU libraries
- list(APPEND link_libraries
- ${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_I18N}
- ${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_UC})
-
swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
list(APPEND library_search_directories ${path})
@@ -1767,6 +1762,14 @@ function(add_swift_target_library name)
list(APPEND swiftlib_link_flags_all "-dynamiclib -Wl,-headerpad_max_install_names")
endif()
+ set(SWIFTLIB_${sdk}_SOURCES ${SWIFTLIB_SOURCES})
+ if(name STREQUAL swiftRuntime)
+ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
+ list(REMOVE_ITEM SWIFTLIB_${sdk}_SOURCES ImageInspectionELF.cpp)
+ swift_runtime_static_libraries(${sdk})
+ endif()
+ endif()
+
set(sdk_supported_archs
${SWIFT_SDK_${sdk}_ARCHITECTURES}
${SWIFT_SDK_${sdk}_MODULE_ARCHITECTURES})
@@ -1804,6 +1807,12 @@ function(add_swift_target_library name)
set(swiftlib_module_dependency_targets)
set(swiftlib_private_link_libraries_targets)
+ if(name STREQUAL swiftCore)
+ # This initializes swiftlib_private_link_libraries_targets for swiftCore,
+ # so don't move it away from the variable declaration just above.
+ swift_core_private_libraries(${sdk} ${arch} swiftlib_private_link_libraries_targets)
+ endif()
+
if(NOT BUILD_STANDALONE)
foreach(mod ${swiftlib_module_depends_flattened})
if(DEFINED maccatalyst_build_flavor)
@@ -1920,7 +1929,7 @@ function(add_swift_target_library name)
${SWIFTLIB_STATIC_keyword}
${SWIFTLIB_OBJECT_LIBRARY_keyword}
${SWIFTLIB_INSTALL_WITH_SHARED_keyword}
- ${SWIFTLIB_SOURCES}
+ ${SWIFTLIB_${sdk}_SOURCES}
TARGET_LIBRARY
MODULE_TARGETS ${module_variant_names}
SDK ${sdk}
diff --git a/swift/stdlib/public/Platform/CMakeLists.txt b/swift/stdlib/public/Platform/CMakeLists.txt
index 8ded40c5791..c811000b1d1 100644
--- a/swift/stdlib/public/Platform/CMakeLists.txt
+++ b/swift/stdlib/public/Platform/CMakeLists.txt
@@ -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}")
@@ -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}")
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
@@ -206,7 +206,7 @@ endif()
swift_install_symlink_component(clang-resource-dir-symlink
LINK_NAME clang
- TARGET ../clang/${CLANG_VERSION}
+ TARGET ../clang/$ENV{TERMUX_CLANG_VERSION}
DESTINATION "lib/swift")
# Possibly install Clang headers under Clang's resource directory in case we
diff --git a/swift/stdlib/public/core/CMakeLists.txt b/swift/stdlib/public/core/CMakeLists.txt
index 7ab092655c7..494d4d62aa3 100644
--- a/swift/stdlib/public/core/CMakeLists.txt
+++ b/swift/stdlib/public/core/CMakeLists.txt
@@ -226,11 +226,9 @@ set(SWIFTLIB_GYB_SOURCES
set(GROUP_INFO_JSON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/GroupInfo.json)
set(swift_core_link_flags "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}")
set(swift_core_framework_depends)
-set(swift_core_private_link_libraries)
set(swift_stdlib_compile_flags "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}")
if(SWIFT_PRIMARY_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
list(APPEND swift_core_link_flags "-all_load")
- list(APPEND swift_core_private_link_libraries icucore)
else()
# With the GNU linker the equivalent of -all_load is to tell the linker
# --whole-archive before the archive and --no-whole-archive after (without
@@ -243,35 +241,42 @@ else()
# effort has been completed.
#set(LINK_FLAGS
# -Wl,--whole-archive swiftRuntime -Wl,--no-whole-archive)
- if("${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
- list(APPEND swift_core_private_link_libraries
- ${SWIFT_${SWIFT_PRIMARY_VARIANT_SDK}_${SWIFT_PRIMARY_VARIANT_ARCH}_ICU_UC}
- ${SWIFT_${SWIFT_PRIMARY_VARIANT_SDK}_${SWIFT_PRIMARY_VARIANT_ARCH}_ICU_I18N})
+endif()
+
+function(swift_core_private_libraries sdk arch libraries_var_name)
+ set(private_link_libraries)
+ if(${sdk} IN_LIST SWIFT_APPLE_PLATFORMS)
+ list(APPEND private_link_libraries icucore)
else()
- list(APPEND swift_core_private_link_libraries -licui18nswift -licuucswift -licudataswift)
+
+
+ if(${sdk} STREQUAL ${SWIFT_HOST_VARIANT_SDK} AND NOT "${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
+ list(APPEND private_link_libraries -licui18nswift -licuucswift -licudataswift)
+ else()
+ list(APPEND private_link_libraries ${SWIFT_${sdk}_${arch}_ICU_UC}
+ ${SWIFT_${sdk}_${arch}_ICU_I18N})
+ endif()
endif()
-endif()
-if(SWIFT_PRIMARY_VARIANT_SDK STREQUAL ANDROID)
- # workaround for libatomic needing to be after object files for swiftCore.so
- list(APPEND swift_core_private_link_libraries atomic)
-elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL CYGWIN)
- # TODO(compnerd) cache this variable to permit re-configuration
- execute_process(COMMAND "cygpath" "-u" "$ENV{SYSTEMROOT}" OUTPUT_VARIABLE ENV_SYSTEMROOT)
- list(APPEND swift_core_private_link_libraries "${ENV_SYSTEMROOT}/system32/psapi.dll")
-elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL FREEBSD)
- find_library(EXECINFO_LIBRARY execinfo)
- list(APPEND swift_core_private_link_libraries ${EXECINFO_LIBRARY})
- # workaround for libatomic needing to be after object files for swiftCore.so
- list(APPEND swift_core_private_link_libraries
- ${SWIFTLIB_DIR}/clang/lib/freebsd/libclang_rt.builtins-${SWIFT_PRIMARY_VARIANT_ARCH}.a)
-elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL LINUX)
- if(SWIFT_BUILD_STATIC_STDLIB)
- list(APPEND swift_core_private_link_libraries swiftImageInspectionShared)
+ if(${sdk} STREQUAL CYGWIN)
+ if(${sdk} STREQUAL ${SWIFT_HOST_VARIANT_SDK})
+ # TODO(compnerd) cache this variable to permit re-configuration
+ execute_process(COMMAND "cygpath" "-u" "$ENV{SYSTEMROOT}" OUTPUT_VARIABLE ENV_SYSTEMROOT)
+ list(APPEND private_link_libraries "${ENV_SYSTEMROOT}/system32/psapi.dll")
+ else()
+ message(FATAL_ERROR "CYGWIN cross-compilation doesn't know where to find psapi.dll.")
+ endif()
+ elseif(${sdk} STREQUAL FREEBSD)
+ find_library(EXECINFO_LIBRARY execinfo)
+ list(APPEND private_link_libraries ${EXECINFO_LIBRARY})
+ elseif(${sdk} STREQUAL LINUX AND SWIFT_BUILD_STATIC_STDLIB)
+ list(APPEND private_link_libraries swiftImageInspectionShared)
+ elseif(${sdk} STREQUAL WINDOWS)
+ list(APPEND private_link_libraries shell32;DbgHelp)
endif()
-elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL WINDOWS)
- list(APPEND swift_core_private_link_libraries shell32;DbgHelp)
-endif()
+
+ set(${libraries_var_name} ${private_link_libraries} PARENT_SCOPE)
+endfunction()
option(SWIFT_CHECK_ESSENTIAL_STDLIB
"Check core standard library layering by linking its essential subset"
@@ -312,8 +317,6 @@ add_swift_target_library(swiftCore
${swift_stdlib_compile_flags} -Xcc -DswiftCore_EXPORTS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
LINK_FLAGS
${swift_core_link_flags}
- PRIVATE_LINK_LIBRARIES
- ${swift_core_private_link_libraries}
INCORPORATE_OBJECT_LIBRARIES
swiftRuntime swiftStdlibStubs
FRAMEWORK_DEPENDS
diff --git a/swift/stdlib/public/runtime/CMakeLists.txt b/swift/stdlib/public/runtime/CMakeLists.txt
index 001d97d5174..0b51e56f631 100644
--- a/swift/stdlib/public/runtime/CMakeLists.txt
+++ b/swift/stdlib/public/runtime/CMakeLists.txt
@@ -88,9 +88,7 @@ set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags})
list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS)
list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/include)
-set(sdk "${SWIFT_HOST_VARIANT_SDK}")
-if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
- list(REMOVE_ITEM swift_runtime_sources ImageInspectionELF.cpp)
+function(swift_runtime_static_libraries sdk)
set(static_binary_lnk_file_list)
string(TOLOWER "${sdk}" lowercase_sdk)
@@ -99,6 +97,7 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
LINK_FLAGS ${swift_runtime_linker_flags}
+ TARGET_SDKS ${sdk}
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
INSTALL_IN_COMPONENT stdlib)
@@ -149,7 +148,7 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
DESTINATION "lib/swift_static/${lowercase_sdk}"
COMPONENT stdlib)
add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list})
- foreach(arch IN LISTS SWIFT_SDK_LINUX_ARCHITECTURES)
+ foreach(arch IN LISTS SWIFT_SDK_${sdk}_ARCHITECTURES)
add_dependencies(static_binary_magic ${swift_image_inspection_${arch}_static})
endforeach()
add_dependencies(static_binary_magic ${swift_image_inspection_static_primary_arch})
@@ -159,9 +158,10 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
LINK_FLAGS ${swift_runtime_linker_flags}
+ TARGET_SDKS ${sdk}
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
INSTALL_IN_COMPONENT never_install)
-endif()
+endfunction()
if(SWIFT_STDLIB_USE_NONATOMIC_RC)
set(_RUNTIME_NONATOMIC_FLAGS -DSWIFT_STDLIB_USE_NONATOMIC_RC)
@@ -174,7 +174,7 @@ add_swift_target_library(swiftRuntime OBJECT_LIBRARY
set(ELFISH_SDKS)
set(COFF_SDKS)
-foreach(sdk ${SWIFT_CONFIGURED_SDKS})
+foreach(sdk ${SWIFT_SDKS})
if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF")
list(APPEND ELFISH_SDKS ${sdk})
elseif("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF")
@@ -201,7 +201,7 @@ add_swift_target_library(swiftImageRegistrationObjectCOFF
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
INSTALL_IN_COMPONENT none)
-foreach(sdk ${SWIFT_CONFIGURED_SDKS})
+foreach(sdk ${SWIFT_SDKS})
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
set(arch_suffix "${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
diff --git a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake b/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
index 7a77e125f95..7eddfea2054 100644
--- a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
+++ b/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
@@ -79,6 +79,9 @@ function(add_sourcekit_default_compiler_flags target)
endif()
target_compile_options(${target} PRIVATE
${c_compile_flags} -fblocks)
+ # Look in Termux sysroot for dispatch/dispatch.h from libdispatch
+ target_include_directories("${target}" SYSTEM PRIVATE
+ ${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include)
target_link_options(${target} PRIVATE
${link_flags})
target_link_directories(${target} PRIVATE
@@ -165,7 +168,7 @@ macro(add_sourcekit_library name)
endif()
endif()
- 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)
set_target_properties(${name} PROPERTIES INSTALL_RPATH "$ORIGIN/../lib/swift/linux:/usr/lib/swift/linux")
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
diff --git a/swift/tools/swift-ide-test/CMakeLists.txt b/swift/tools/swift-ide-test/CMakeLists.txt
index 095e97d5f15..dae9946aba8 100644
--- a/swift/tools/swift-ide-test/CMakeLists.txt
+++ b/swift/tools/swift-ide-test/CMakeLists.txt
@@ -13,7 +13,8 @@ target_link_libraries(swift-ide-test
# If libxml2 is available, make it available for swift-ide-test.
if(LibXml2_FOUND)
- include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
+ # No way to not build this, so look in Termux sysroot for iconv.h from libiconv
+ include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR} ${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include)
target_link_libraries(swift-ide-test PRIVATE ${LIBXML2_LIBRARIES})
target_compile_definitions(swift-ide-test PRIVATE SWIFT_HAVE_LIBXML=1)
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "OpenBSD" AND NOT CMAKE_CROSSCOMPILING)