Skip to content

Commit b9836e6

Browse files
authored
Merge pull request #9869 from johnno1962a/master
Ensure fatalError message logged on Android
2 parents 72af643 + ed38b57 commit b9836e6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,10 @@ function(_add_variant_link_flags)
359359
endif()
360360
elseif("${LFLAGS_SDK}" STREQUAL "ANDROID")
361361
list(APPEND result
362-
"-ldl"
362+
"-ldl" "-llog" "-latomic" "-licudata" "-licui18n" "-licuuc"
363363
"${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so")
364364
list(APPEND library_search_directories
365+
"${SWIFT_ANDROID_PREBUILT_PATH}/arm-linux-androideabi/lib/armv7-a"
365366
"${SWIFT_ANDROID_PREBUILT_PATH}/lib/gcc/arm-linux-androideabi/${SWIFT_ANDROID_NDK_GCC_VERSION}.x")
366367
else()
367368
# If lto is enabled, we need to add the object path flag so that the LTO code
@@ -1500,6 +1501,12 @@ function(add_swift_library name)
15001501
if("${lib}" STREQUAL "ICU_UC")
15011502
list(APPEND swiftlib_private_link_libraries_targets
15021503
"${SWIFT_${sdk}_ICU_UC}")
1504+
# temporary fix for atomic needing to be
1505+
# after object files for libswiftCore.so
1506+
if("${sdk}" STREQUAL "ANDROID")
1507+
list(APPEND swiftlib_private_link_libraries_targets
1508+
"-latomic")
1509+
endif()
15031510
elseif("${lib}" STREQUAL "ICU_I18N")
15041511
list(APPEND swiftlib_private_link_libraries_targets
15051512
"${SWIFT_${sdk}_ICU_I18N}")

stdlib/public/runtime/Errors.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
#include <execinfo.h>
4747
#endif
4848

49-
#ifdef __APPLE__
49+
#if defined(__APPLE__)
5050
#include <asl.h>
51+
#elif defined(__ANDROID__)
52+
#include <android/log.h>
5153
#endif
5254

5355
namespace FatalErrorFlags {
@@ -228,8 +230,10 @@ reportNow(uint32_t flags, const char *message)
228230
#else
229231
write(STDERR_FILENO, message, strlen(message));
230232
#endif
231-
#ifdef __APPLE__
233+
#if defined(__APPLE__)
232234
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
235+
#elif defined(__ANDROID__)
236+
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message);
233237
#endif
234238
#if SWIFT_SUPPORTS_BACKTRACE_REPORTING
235239
if (flags & FatalErrorFlags::ReportBacktrace) {

0 commit comments

Comments
 (0)