From 8d5cb4db1f5769cbc8a3f95e8fd38f1eedc23c79 Mon Sep 17 00:00:00 2001 From: Peter Waller Date: Thu, 10 Jul 2025 18:09:55 +0100 Subject: [PATCH] [BOLT] Force frame pointers off for runtimes Distributions are making the choice to turn frame pointers on by default. Nixpkgs recently turned them on, and the method they use to do so implies that everything is built with them on by default. https://github.com/NixOS/nixpkgs/pull/399014 Assuming that a well behaved distribution doing this puts '-fno-omit-frame-pointer' at the beginning of the compiler invocation, we can still re-enable it by supplying -fomit-frame-pointer thereafter. See also: #147569 --- bolt/runtime/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bolt/runtime/CMakeLists.txt b/bolt/runtime/CMakeLists.txt index 87cc44812da11..b9c22a4604f1f 100644 --- a/bolt/runtime/CMakeLists.txt +++ b/bolt/runtime/CMakeLists.txt @@ -35,7 +35,12 @@ set(BOLT_RT_FLAGS -fno-exceptions -fno-rtti -fno-stack-protector - -fPIC) + -fPIC + # Runtime currently assumes omitted frame pointers for functions marked __attribute((naked)). + # Protect against distros adding -fno-omit-frame-pointer and compiling with GCC. + # Refs: llvm/llvm-project#147569 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77882 + -fomit-frame-pointer +) if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") set(BOLT_RT_FLAGS ${BOLT_RT_FLAGS} -mno-sse