From 03a8ad13b82c40e748113239bf7f4e3eb06ed492 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Mon, 29 Sep 2025 15:29:10 +0100 Subject: [PATCH] [Build] Enable frame pointers. Frame pointers should be enabled everywhere. rdar://160759746 (cherry picked from commit a8b689a278a045b8ea6bd1f2ddfd3c52369db89d) --- CMakeLists.txt | 2 ++ cmake/modules/EnableFramePointers.cmake | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 cmake/modules/EnableFramePointers.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 626368d01..f9d08a34c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,8 @@ include(DispatchCompilerWarnings) include(DTrace) include(SwiftSupport) +include(EnableFramePointers) + # NOTE(abdulras) this is the CMake supported way to control whether we generate # shared or static libraries. This impacts the behaviour of `add_library` in # what type of library it generates. diff --git a/cmake/modules/EnableFramePointers.cmake b/cmake/modules/EnableFramePointers.cmake new file mode 100644 index 000000000..8573d8dc4 --- /dev/null +++ b/cmake/modules/EnableFramePointers.cmake @@ -0,0 +1,13 @@ +# +# Including this file enables frame pointers, if we know how. +# + +include(CheckCompilerFlag) + +# Check if the compiler supports -fno-omit-frame-pointer +check_compiler_flag(C -fno-omit-frame-pointer SUPPORTS_NO_OMIT_FP) + +# If it does, use it +if (SUPPORTS_NO_OMIT_FP) + add_compile_options($<$:-fno-omit-frame-pointer>) +endif()