0
0
mirror of https://github.com/termux/termux-packages.git synced 2024-12-12 14:13:36 +00:00
termux-packages/packages/swift/swift-android-spawn.patch
2024-11-12 13:08:55 +05:30

101 lines
4.8 KiB
Diff

diff --git a/llbuild/lib/llvm/Support/CMakeLists.txt b/llbuild/lib/llvm/Support/CMakeLists.txt
index 8e79e18..a844183 100644
--- a/llbuild/lib/llvm/Support/CMakeLists.txt
+++ b/llbuild/lib/llvm/Support/CMakeLists.txt
@@ -65,5 +65,5 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Android|Darwin|Linux")
- target_link_libraries(llvmSupport PRIVATE curses)
+ target_link_libraries(llvmSupport PRIVATE android-spawn curses)
endif()
diff --git a/llvm-project/clang/tools/driver/CMakeLists.txt b/llvm-project/clang/tools/driver/CMakeLists.txt
index dd34c12880..ffd68d908b 100644
--- a/llvm-project/clang/tools/driver/CMakeLists.txt
+++ b/llvm-project/clang/tools/driver/CMakeLists.txt
@@ -97,6 +97,7 @@ if (APPLE)
set(TOOL_INFO_VERSION)
set(TOOL_INFO_BUILD_VERSION)
endif()
+target_link_libraries(clang PRIVATE "android-spawn")
if(CLANG_ORDER_FILE AND
(LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
diff --git a/sourcekit-lsp/Utilities/build-script-helper.py b/sourcekit-lsp/Utilities/build-script-helper.py
index a64795c..d48876d 100755
--- a/sourcekit-lsp/Utilities/build-script-helper.py
+++ b/sourcekit-lsp/Utilities/build-script-helper.py
@@ -124,6 +124,7 @@ def get_swiftpm_options(swift_exec: str, args: argparse.Namespace) -> List[str]:
if 'ANDROID_DATA' in os.environ or (args.cross_compile_host and re.match(
'android-', args.cross_compile_host)):
swiftpm_args += [
+ '-Xlinker', '-landroid-spawn',
'-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android',
# SwiftPM will otherwise try to compile against GNU strerror_r on
# Android and fail.
diff --git a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
index 016bf294..cd534f16 100644
--- a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
+++ b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
@@ -162,6 +162,10 @@ if(NOT BUILD_SHARED_LIBS)
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend _FoundationICU>")
target_compile_options(Foundation PRIVATE
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>")
+ if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
+ target_compile_options(Foundation PRIVATE
+ "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend android-spawn>")
+ endif()
endif()
set_target_properties(Foundation PROPERTIES
@@ -174,6 +174,12 @@
target_link_libraries(Foundation PUBLIC
swiftDispatch)
endif()
+ if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
+ target_link_libraries(Foundation PRIVATE android-spawn)
+ list(GET CMAKE_FIND_ROOT_PATH 0 SPAWN_DIR)
+ target_include_directories(Foundation PUBLIC ${SPAWN_DIR}/usr/include)
+ target_link_directories(Foundation PUBLIC ${SPAWN_DIR}/usr/lib)
+ endif()
if(LINKER_SUPPORTS_BUILD_ID)
target_link_options(Foundation PRIVATE "LINKER:--build-id=sha1")
diff --git a/swift-driver/Utilities/build-script-helper.py b/swift-driver/Utilities/build-script-helper.py
index 18f22fb0..bc2b1308 100755
--- a/swift-driver/Utilities/build-script-helper.py
+++ b/swift-driver/Utilities/build-script-helper.py
@@ -103,6 +103,7 @@ def get_swiftpm_options(args):
if 'ANDROID_DATA' in os.environ or (args.cross_compile_hosts and re.match(
'android-', args.cross_compile_hosts[0])):
swiftpm_args += [
+ '-Xlinker', '-landroid-spawn',
'-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android',
# SwiftPM will otherwise try to compile against GNU strerror_r on
# Android and fail.
diff --git a/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt b/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
index bbc43d98..bc5ee576 100644
--- a/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
+++ b/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
@@ -53,7 +53,7 @@ target_link_libraries(TSCBasic PUBLIC
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
if(Foundation_FOUND)
target_link_libraries(TSCBasic PUBLIC
- Foundation)
+ Foundation android-spawn)
endif()
endif()
target_link_libraries(TSCBasic PRIVATE
diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap
index 085056de..1ded1a90 100755
--- a/swiftpm/Utilities/bootstrap
+++ b/swiftpm/Utilities/bootstrap
@@ -827,6 +827,7 @@ def get_swiftpm_flags(args):
# Don't use GNU strerror_r on Android.
if '-android' in args.build_target:
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-U_GNU_SOURCE"])
+ build_flags.extend(["-Xlinker", "-landroid-spawn"])
cross_compile_hosts = args.cross_compile_hosts
if cross_compile_hosts: