-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from readdle/feature/restore-crash-report-client
Add patch for crash report client
- Loading branch information
Showing
1 changed file
with
146 additions
and
0 deletions.
There are no files selected for viewing
146 changes: 146 additions & 0 deletions
146
patches/release/5.7/swift/0008-Enable-crash-report-client.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
diff --git a/include/swift/Runtime/Debug.h b/include/swift/Runtime/Debug.h | ||
index 54708b1045d..68b4ca6d8fe 100644 | ||
--- a/include/swift/Runtime/Debug.h | ||
+++ b/include/swift/Runtime/Debug.h | ||
@@ -26,6 +26,12 @@ | ||
|
||
#ifdef SWIFT_HAVE_CRASHREPORTERCLIENT | ||
|
||
+#ifdef __APPLE__ | ||
+#define GCR_ANNOTATIONS_VISIBILITY __attribute__ ((visibility("hidden"))) | ||
+#else | ||
+#define GCR_ANNOTATIONS_VISIBILITY __attribute__ ((visibility("default"))) | ||
+#endif | ||
+ | ||
#define CRASHREPORTER_ANNOTATIONS_VERSION 5 | ||
#define CRASHREPORTER_ANNOTATIONS_SECTION "__crash_info" | ||
|
||
@@ -41,7 +47,7 @@ struct crashreporter_annotations_t { | ||
}; | ||
|
||
extern "C" { | ||
-SWIFT_RUNTIME_LIBRARY_VISIBILITY | ||
+GCR_ANNOTATIONS_VISIBILITY | ||
extern struct crashreporter_annotations_t gCRAnnotations; | ||
} | ||
|
||
diff --git a/lib/Demangling/CrashReporter.cpp b/lib/Demangling/CrashReporter.cpp | ||
index ece5fb61c5f..5d9fc82ae61 100644 | ||
--- a/lib/Demangling/CrashReporter.cpp | ||
+++ b/lib/Demangling/CrashReporter.cpp | ||
@@ -26,7 +26,7 @@ | ||
// The layout of this struct is CrashReporter ABI, so there are no ABI concerns | ||
// here. | ||
extern "C" { | ||
-SWIFT_LIBRARY_VISIBILITY | ||
+GCR_ANNOTATIONS_VISIBILITY | ||
struct crashreporter_annotations_t gCRAnnotations __attribute__(( | ||
__section__("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) = { | ||
CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0}; | ||
diff --git a/lib/Demangling/CrashReporter.h b/lib/Demangling/CrashReporter.h | ||
index d9d838047ea..53baaef3430 100644 | ||
--- a/lib/Demangling/CrashReporter.h | ||
+++ b/lib/Demangling/CrashReporter.h | ||
@@ -26,6 +26,12 @@ | ||
|
||
#include <inttypes.h> | ||
|
||
+#ifdef __APPLE__ | ||
+#define GCR_ANNOTATIONS_VISIBILITY __attribute__ ((visibility("hidden"))) | ||
+#else | ||
+#define GCR_ANNOTATIONS_VISIBILITY __attribute__ ((visibility("default"))) | ||
+#endif | ||
+ | ||
#define CRASHREPORTER_ANNOTATIONS_VERSION 5 | ||
#define CRASHREPORTER_ANNOTATIONS_SECTION "__crash_info" | ||
|
||
@@ -41,7 +47,7 @@ struct crashreporter_annotations_t { | ||
}; | ||
|
||
extern "C" { | ||
-SWIFT_LIBRARY_VISIBILITY | ||
+GCR_ANNOTATIONS_VISIBILITY | ||
extern struct crashreporter_annotations_t gCRAnnotations; | ||
} | ||
|
||
diff --git a/lib/Demangling/Errors.cpp b/lib/Demangling/Errors.cpp | ||
index f26be07ac7e..053c64d2758 100644 | ||
--- a/lib/Demangling/Errors.cpp | ||
+++ b/lib/Demangling/Errors.cpp | ||
@@ -35,7 +35,14 @@ | ||
|
||
#if SWIFT_HAVE_CRASHREPORTERCLIENT | ||
#include <atomic> | ||
-#include <malloc/malloc.h> | ||
+ | ||
+#ifdef __APPLE__ | ||
+ #include <malloc/malloc.h> | ||
+ #define MALLOC_SIZE_FUNC malloc_size | ||
+#else | ||
+ #include <malloc.h> | ||
+ #define MALLOC_SIZE_FUNC malloc_usable_size | ||
+#endif | ||
|
||
#include "swift/Runtime/Atomic.h" | ||
|
||
@@ -83,7 +90,7 @@ static void reportOnCrash(uint32_t flags, const char *message) { | ||
std::memory_order_release, | ||
SWIFT_MEMORY_ORDER_CONSUME)); | ||
|
||
- if (oldMessage && malloc_size(oldMessage)) | ||
+ if (oldMessage && MALLOC_SIZE_FUNC(oldMessage)) | ||
free(oldMessage); | ||
#else | ||
// empty | ||
diff --git a/stdlib/public/runtime/CrashReporter.cpp b/stdlib/public/runtime/CrashReporter.cpp | ||
index fd7e891579d..ef6174a50e7 100644 | ||
--- a/stdlib/public/runtime/CrashReporter.cpp | ||
+++ b/stdlib/public/runtime/CrashReporter.cpp | ||
@@ -26,7 +26,7 @@ | ||
// The layout of this struct is CrashReporter ABI, so there are no ABI concerns | ||
// here. | ||
extern "C" { | ||
-SWIFT_LIBRARY_VISIBILITY | ||
+GCR_ANNOTATIONS_VISIBILITY | ||
struct crashreporter_annotations_t gCRAnnotations __attribute__(( | ||
__section__("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) = { | ||
CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0}; | ||
diff --git a/stdlib/public/runtime/Errors.cpp b/stdlib/public/runtime/Errors.cpp | ||
index 1129f20cfeb..4ebecdc46a1 100644 | ||
--- a/stdlib/public/runtime/Errors.cpp | ||
+++ b/stdlib/public/runtime/Errors.cpp | ||
@@ -59,7 +59,11 @@ | ||
|
||
#ifdef SWIFT_HAVE_CRASHREPORTERCLIENT | ||
#include <atomic> | ||
-#include <malloc/malloc.h> | ||
+#ifdef __APPLE__ | ||
+ #include <malloc/malloc.h> | ||
+#else | ||
+ #include <malloc.h> | ||
+#endif | ||
|
||
#include "swift/Runtime/Atomic.h" | ||
#endif // SWIFT_HAVE_CRASHREPORTERCLIENT | ||
diff --git a/utils/build-script-impl b/utils/build-script-impl | ||
index 5714af5e197..778c2428ec3 100755 | ||
--- a/utils/build-script-impl | ||
+++ b/utils/build-script-impl | ||
@@ -1642,12 +1642,11 @@ for host in "${ALL_HOSTS[@]}"; do | ||
) | ||
fi | ||
|
||
- if [[ "${DARWIN_CRASH_REPORTER_CLIENT}" ]] ; then | ||
- swift_cmake_options=( | ||
- "${swift_cmake_options[@]}" | ||
- -DSWIFT_RUNTIME_CRASH_REPORTER_CLIENT:BOOL=$(true_false "${DARWIN_CRASH_REPORTER_CLIENT}") | ||
- ) | ||
- fi | ||
+ # Enable runtime crash reporter client for all platforms | ||
+ swift_cmake_options=( | ||
+ "${swift_cmake_options[@]}" | ||
+ -DSWIFT_RUNTIME_CRASH_REPORTER_CLIENT:BOOL=TRUE | ||
+ ) | ||
|
||
swift_cmake_options=( | ||
"${swift_cmake_options[@]}" |