diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index 5dd80da545ea7..eae85ea302804 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -359,9 +359,10 @@ function(_add_variant_link_flags) endif() elseif("${LFLAGS_SDK}" STREQUAL "ANDROID") list(APPEND result - "-ldl" + "-ldl" "-llog" "-latomic" "-licudata" "-licui18n" "-licuuc" "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so") list(APPEND library_search_directories + "${SWIFT_ANDROID_PREBUILT_PATH}/arm-linux-androideabi/lib/armv7-a" "${SWIFT_ANDROID_PREBUILT_PATH}/lib/gcc/arm-linux-androideabi/${SWIFT_ANDROID_NDK_GCC_VERSION}.x") else() # If lto is enabled, we need to add the object path flag so that the LTO code @@ -1504,6 +1505,12 @@ function(add_swift_library name) if("${lib}" STREQUAL "ICU_UC") list(APPEND swiftlib_private_link_libraries_targets "${SWIFT_${sdk}_ICU_UC}") + # temporary fix for atomic needing to be + # after object files for libswiftCore.so + if("${sdk}" STREQUAL "ANDROID") + list(APPEND swiftlib_private_link_libraries_targets + "-latomic") + endif() elseif("${lib}" STREQUAL "ICU_I18N") list(APPEND swiftlib_private_link_libraries_targets "${SWIFT_${sdk}_ICU_I18N}") diff --git a/stdlib/public/runtime/Errors.cpp b/stdlib/public/runtime/Errors.cpp index 2ccd48bebfe52..c50035632ac92 100644 --- a/stdlib/public/runtime/Errors.cpp +++ b/stdlib/public/runtime/Errors.cpp @@ -46,8 +46,10 @@ #include #endif -#ifdef __APPLE__ +#if defined(__APPLE__) #include +#elif defined(__ANDROID__) +#include #endif namespace FatalErrorFlags { @@ -228,8 +230,10 @@ reportNow(uint32_t flags, const char *message) #else write(STDERR_FILENO, message, strlen(message)); #endif -#ifdef __APPLE__ +#if defined(__APPLE__) asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message); +#elif defined(__ANDROID__) + __android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message); #endif #if SWIFT_SUPPORTS_BACKTRACE_REPORTING if (flags & FatalErrorFlags::ReportBacktrace) {