vcpkg/ports/folly/fix-abort.patch
Jia Yue Hua 078f136afc
[glog] upgrade to v0.6 (#25312)
* glog upgrade

* tmp

* is glog initialized

* fix glog dependency

* fix glog dependency

* fix folly abort call

* delete buildtrees

* fix folly abort call

* delete useless lines

* fix caffe2 isglog initialized

* make patches shorter

* glog fix typo

* glog fix tab

* Remove cpp patch since we don't need it

* Revert 6b8759a860

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
2022-06-23 15:29:07 -07:00

39 lines
1.4 KiB
Diff

diff --git a/folly/init/Init.cpp b/folly/init/Init.cpp
index 66ca5cc..2302f10 100644
--- a/folly/init/Init.cpp
+++ b/folly/init/Init.cpp
@@ -47,6 +47,24 @@ void init(int* argc, char*** argv, bool removeFlags) {
init(argc, argv, options);
}
+#if FOLLY_USE_SYMBOLIZER
+// Newer versions of glog require the function passed to InstallFailureFunction
+// to be noreturn. But glog spells that in multiple possible ways, depending on
+// platform. But glog's choice of spelling does not match how the
+// noreturn-ability of std::abort is spelled. Some compilers consider this a
+// type mismatch on the function-ptr type. To fix the type mismatch, we wrap
+// std::abort and mimic the condition and the spellings from glog here.
+#if defined(__GNUC__)
+__attribute__((noreturn))
+#else
+[[noreturn]]
+#endif
+static void
+wrapped_abort() {
+ abort();
+}
+#endif
+
void init(int* argc, char*** argv, InitOptions options) {
#if !defined(_WIN32) && !defined(__XROS__)
// Install the handler now, to trap errors received during startup.
@@ -76,7 +94,7 @@ void init(int* argc, char*** argv, InitOptions options) {
#if FOLLY_USE_SYMBOLIZER
// Don't use glog's DumpStackTraceAndExit; rely on our signal handler.
- google::InstallFailureFunction(abort);
+ google::InstallFailureFunction(wrapped_abort);
// Actually install the callbacks into the handler.
folly::symbolizer::installFatalSignalCallbacks();