termux-packages/packages/swift/swift-corelibs-libdispatch-...

44 lines
1.9 KiB
Diff
Raw Normal View History

2021-01-14 16:12:45 +01:00
From 0f8ab3e42a4a052dec0e4b66c252fd83e8e5ba7c Mon Sep 17 00:00:00 2001
Date: Wed, 2 Dec 2020 18:33:48 +0530
Subject: [PATCH] [android] Put in fixes for librt and armv7-a
Android doesn't have a separate librt, it's just part of libc. Also, the static
build wasn't working for armv7-a, because the test executables wouldn't link
with the multiple definition errors listed in android/ndk#176, so use the
workaround given there.
diff --git a/swift-corelibs-libdispatch/CMakeLists.txt b/swift-corelibs-libdispatch/CMakeLists.txt
index 75c419c13..36da01122 100644
--- a/swift-corelibs-libdispatch/CMakeLists.txt
+++ b/swift-corelibs-libdispatch/CMakeLists.txt
@@ -113,7 +113,9 @@ if(__BUILTIN_TRAP)
set(HAVE_NORETURN_BUILTIN_TRAP 1)
endif()
-find_package(LibRT)
+if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
+ find_package(LibRT)
+endif()
check_function_exists(_pthread_workqueue_init HAVE__PTHREAD_WORKQUEUE_INIT)
check_function_exists(getprogname HAVE_GETPROGNAME)
diff --git a/swift-corelibs-libdispatch/tests/CMakeLists.txt b/swift-corelibs-libdispatch/tests/CMakeLists.txt
index a27603559..0176a062b 100644
--- a/swift-corelibs-libdispatch/tests/CMakeLists.txt
+++ b/swift-corelibs-libdispatch/tests/CMakeLists.txt
@@ -88,6 +88,14 @@ function(add_unit_test name)
target_compile_options(${name} PRIVATE -fblocks)
target_compile_options(${name} PRIVATE -Wall -Wno-deprecated-declarations)
endif()
+ # Without this flag, cross-compiling static test executables for Android armv7
+ # fails with the multiple definition errors seen in android/ndk#176, so I
+ # pulled in this workaround noted there. The tests build and run with this
+ # flag applied.
+ if(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL Android AND
+ CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
+ target_link_options(${name} PRIVATE "LINKER:--allow-multiple-definition")
+ endif()
target_link_libraries(${name}
PRIVATE
dispatch