@@ -94,9 +94,12 @@ function(_add_target_variant_c_compile_link_flags)
94
94
endif ()
95
95
96
96
if ("${CFLAGS_SDK} " STREQUAL "ANDROID" )
97
- # Make sure the Android NDK lld is used.
98
- swift_android_tools_path(${CFLAGS_ARCH} tools_path)
99
- list (APPEND result "-B" "${tools_path} " )
97
+ # lld can handle targeting the android build. However, if lld is not
98
+ # enabled, then fallback to the linker included in the android NDK.
99
+ if (NOT SWIFT_USE_LINKER STREQUAL "lld" )
100
+ swift_android_tools_path(${CFLAGS_ARCH} tools_path)
101
+ list (APPEND result "-B" "${tools_path} " )
102
+ endif ()
100
103
endif ()
101
104
102
105
if ("${CFLAGS_SDK} " IN_LIST SWIFT_DARWIN_PLATFORMS)
@@ -402,8 +405,8 @@ function(_add_target_variant_link_flags)
402
405
MACCATALYST_BUILD_FLAVOR "${LFLAGS_MACCATALYST_BUILD_FLAVOR} " )
403
406
if ("${LFLAGS_SDK} " STREQUAL "LINUX" )
404
407
list (APPEND link_libraries "pthread" "dl" )
405
- if ("${LFLAGS_ARCH } " MATCHES "armv6|armv7|i686" )
406
- list (APPEND link_libraries "atomic" )
408
+ if ("${SWIFT_HOST_VARIANT_ARCH } " MATCHES "armv6|armv7|i686" )
409
+ list (APPEND link_libraries PRIVATE "atomic" )
407
410
endif ()
408
411
elseif ("${LFLAGS_SDK} " STREQUAL "FREEBSD" )
409
412
list (APPEND link_libraries "pthread" )
@@ -430,14 +433,8 @@ function(_add_target_variant_link_flags)
430
433
list (APPEND result "-Wl,-Bsymbolic" )
431
434
elseif ("${LFLAGS_SDK} " STREQUAL "ANDROID" )
432
435
list (APPEND link_libraries "dl" "log" )
433
- if ("${LFLAGS_ARCH} " STREQUAL "armv7" )
434
- list (APPEND link_libraries "atomic" )
435
- endif ()
436
436
# We need to add the math library, which is linked implicitly by libc++
437
437
list (APPEND result "-lm" )
438
- if (NOT "${SWIFT_ANDROID_NDK_PATH} " STREQUAL "" )
439
- list (APPEND result "-resource-dir=${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH} _PATH}/../lib64/clang/${SWIFT_ANDROID_NDK_CLANG_VERSION} " )
440
- endif ()
441
438
442
439
# link against the custom C++ library
443
440
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
@@ -447,6 +444,11 @@ function(_add_target_variant_link_flags)
447
444
list (APPEND link_libraries
448
445
${SWIFT_ANDROID_${LFLAGS_ARCH} _ICU_I18N}
449
446
${SWIFT_ANDROID_${LFLAGS_ARCH} _ICU_UC})
447
+
448
+ swift_android_libgcc_for_arch_cross_compile(${LFLAGS_ARCH} ${LFLAGS_ARCH} _LIB)
449
+ foreach (path IN LISTS ${LFLAGS_ARCH} _LIB)
450
+ list (APPEND library_search_directories ${path} )
451
+ endforeach ()
450
452
else ()
451
453
# If lto is enabled, we need to add the object path flag so that the LTO code
452
454
# generator leaves the intermediate object file in a place where it will not
@@ -474,17 +476,10 @@ function(_add_target_variant_link_flags)
474
476
endif ()
475
477
476
478
if (SWIFT_USE_LINKER AND NOT SWIFT_COMPILER_IS_MSVC_LIKE)
477
- # The linker is normally chosen based on the host, but the Android NDK only
478
- # uses lld now.
479
- if ("${LFLAGS_SDK} " STREQUAL "ANDROID" )
480
- set (linker "lld" )
481
- else ()
482
- set (linker "${SWIFT_USE_LINKER} " )
483
- endif ()
484
479
if (CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
485
- list (APPEND result "-fuse-ld=${linker } .exe" )
480
+ list (APPEND result "-fuse-ld=${SWIFT_USE_LINKER } .exe" )
486
481
else ()
487
- list (APPEND result "-fuse-ld=${linker } " )
482
+ list (APPEND result "-fuse-ld=${SWIFT_USE_LINKER } " )
488
483
endif ()
489
484
endif ()
490
485
0 commit comments