summaryrefslogtreecommitdiffstats
path: root/cmake/global_flags.linker.gnu.cmake
diff options
context:
space:
mode:
authorrobot-ya-builder <[email protected]>2023-03-17 19:38:27 +0300
committerrobot-ya-builder <[email protected]>2023-03-17 19:38:27 +0300
commit26147c4e01ae75f397d4dd999da238bf2c61c851 (patch)
tree873a652bca08f38df296c77422b40fd404f0481e /cmake/global_flags.linker.gnu.cmake
parent08f6d0d9bb84f493c5dfd3c0d1568445faa26d85 (diff)
External build system generator release 21
Update tools: yexport
Diffstat (limited to 'cmake/global_flags.linker.gnu.cmake')
-rw-r--r--cmake/global_flags.linker.gnu.cmake22
1 files changed, 21 insertions, 1 deletions
diff --git a/cmake/global_flags.linker.gnu.cmake b/cmake/global_flags.linker.gnu.cmake
index 2bb54fbd786..c527053100b 100644
--- a/cmake/global_flags.linker.gnu.cmake
+++ b/cmake/global_flags.linker.gnu.cmake
@@ -1,9 +1,29 @@
add_link_options(
- -nodefaultlibs
-lc
-lm
)
+if (ANDROID)
+ # NDK r23 onwards has stopped using libgcc:
+ # - https://github.com/android/ndk/wiki/Changelog-r23#changes
+ # - https://github.com/android/ndk/issues/1230
+ # LLVM's libunwind is now used instead of libgcc for all architectures rather than just 32-bit Arm.
+ # - https://github.com/android/ndk/issues/1231
+ # LLVM's libclang_rt.builtins is now used instead of libgcc.
+ if (CMAKE_ANDROID_NDK_VERSION GREATER_EQUAL 23)
+ # Use toolchain defaults to link with libunwind/clang_rt.builtins
+ add_link_options("-nostdlib++")
+ else ()
+ # Preserve old behaviour: specify runtime libs manually
+ add_link_options(-nodefaultlibs -lgcc)
+ if (CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
+ add_link_options("-lunwind")
+ endif()
+ endif()
+elseif (CMAKE_SYSTEM_NAME MATCHES "^(Darwin|Linux)$")
+ add_link_options("-nodefaultlibs")
+endif()
+
if (APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
endif()