Skip to content

Ensure fatalError message logged on Android #9869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}")
Expand Down
8 changes: 6 additions & 2 deletions stdlib/public/runtime/Errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
#include <execinfo.h>
#endif

#ifdef __APPLE__
#if defined(__APPLE__)
#include <asl.h>
#elif defined(__ANDROID__)
#include <android/log.h>
#endif

namespace FatalErrorFlags {
Expand Down Expand Up @@ -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) {
Expand Down