[libc++abi] Make sure we link in CrashReporterClient.a when it's present
authorLouis Dionne <ldionne@apple.com>
Tue, 2 Jun 2020 16:21:01 +0000 (12:21 -0400)
committerLouis Dionne <ldionne@apple.com>
Tue, 2 Jun 2020 16:23:53 +0000 (12:23 -0400)
When building the system libc++abi for Apple, we use CrashReporterClient
to provide better crash logs when calling abort(). This is exemplified by
the fact that we test for the presence of <CrashReporterClient.h> in
abort_message.cpp.

However, we must link against CrashReporterClient.a in order to get that
functionality, otherwise we get a linking error.

libcxxabi/src/CMakeLists.txt

index 7b837a4..d5251ac 100644 (file)
@@ -135,6 +135,17 @@ if ( APPLE )
       add_link_flags("-Wl,-rpath,${LIBDIR}")
     endif()
   endif()
+
+  # Make sure we link in CrashReporterClient if we find it -- it's used by
+  # abort() on Apple platforms when building the system dylib.
+  find_library(CrashReporterClient NAMES libCrashReporterClient.a
+                                   PATHS "${CMAKE_OSX_SYSROOT}/usr/local/lib")
+  if (CrashReporterClient)
+    message(STATUS "Linking with CrashReporterClient at ${CrashReporterClient}")
+    add_library_flags("${CrashReporterClient}")
+  else()
+    message(STATUS "Could not find CrashReporterClient, not linking against it")
+  endif()
 endif()
 
 split_list(LIBCXXABI_COMPILE_FLAGS)