0002-absl-debugging-use-execinfo.h-only-when-available.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 445907a8a98e5d14f9c0042aa6849bdad4b0af5b Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Thu, 23 Jul 2020 22:28:55 +0200
  4. Subject: [PATCH] absl/debugging: use <execinfo.h> only when available
  5. Instead of relying on __GLIBC__ or other unreliable detection
  6. mechanism, simply detect if <execinfo.h> is available before using the
  7. stacktrace_generic-inl.inc implementation.
  8. Upstream: https://github.com/abseil/abseil-cpp/pull/746
  9. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  10. ---
  11. absl/debugging/CMakeLists.txt | 7 +++++++
  12. absl/debugging/internal/stacktrace_config.h | 6 +++---
  13. 2 files changed, 10 insertions(+), 3 deletions(-)
  14. diff --git a/absl/debugging/CMakeLists.txt b/absl/debugging/CMakeLists.txt
  15. index 7733615..285c5a8 100644
  16. --- a/absl/debugging/CMakeLists.txt
  17. +++ b/absl/debugging/CMakeLists.txt
  18. @@ -14,6 +14,13 @@
  19. # limitations under the License.
  20. #
  21. +include(CheckIncludeFileCXX)
  22. +
  23. +check_include_file_cxx(execinfo.h HAVE_EXECINFO_H)
  24. +if(HAVE_EXECINFO_H)
  25. + add_definitions(-DHAVE_EXECINFO_H)
  26. +endif()
  27. +
  28. absl_cc_library(
  29. NAME
  30. stacktrace
  31. diff --git a/absl/debugging/internal/stacktrace_config.h b/absl/debugging/internal/stacktrace_config.h
  32. index d4e8480..2e17ca3 100644
  33. --- a/absl/debugging/internal/stacktrace_config.h
  34. +++ b/absl/debugging/internal/stacktrace_config.h
  35. @@ -40,7 +40,7 @@
  36. # elif defined(__aarch64__)
  37. #define ABSL_STACKTRACE_INL_HEADER \
  38. "absl/debugging/internal/stacktrace_aarch64-inl.inc"
  39. -# elif defined(__arm__)
  40. +# elif defined(__arm__) && defined(HAVE_EXECINFO_H)
  41. // Note: When using glibc this may require -funwind-tables to function properly.
  42. #define ABSL_STACKTRACE_INL_HEADER \
  43. "absl/debugging/internal/stacktrace_generic-inl.inc"
  44. @@ -49,10 +49,10 @@
  45. "absl/debugging/internal/stacktrace_unimplemented-inl.inc"
  46. # endif
  47. #else // defined(NO_FRAME_POINTER)
  48. -# if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
  49. +# if (defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)) && defined(HAVE_EXECINFO_H)
  50. #define ABSL_STACKTRACE_INL_HEADER \
  51. "absl/debugging/internal/stacktrace_generic-inl.inc"
  52. -# elif defined(__ppc__) || defined(__PPC__)
  53. +# elif (defined(__ppc__) || defined(__PPC__)) && defined(HAVE_EXECINFO_H)
  54. #define ABSL_STACKTRACE_INL_HEADER \
  55. "absl/debugging/internal/stacktrace_generic-inl.inc"
  56. # else
  57. --
  58. 2.26.2