Skip to content

Commit 81ad8e6

Browse files
[BOLT] Force frame pointers off for runtimes (llvm#148009)
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. NixOS/nixpkgs#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 omission by supplying `-fomit-frame-pointer` during compilation. This fixes some segfaults from stack corruption in binaries rewritten by bolt with `llvm-bolt -instrument`. See also: llvm#147569 Fixes: llvm#148595
1 parent 0a357e9 commit 81ad8e6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bolt/runtime/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ set(BOLT_RT_FLAGS
3535
-fno-exceptions
3636
-fno-rtti
3737
-fno-stack-protector
38-
-fPIC)
38+
-fPIC
39+
# Runtime currently assumes omitted frame pointers for functions marked __attribute((naked)).
40+
# Protect against distros adding -fno-omit-frame-pointer and compiling with GCC.
41+
# Refs: llvm/llvm-project#148595 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77882
42+
-fomit-frame-pointer
43+
)
3944
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
4045
set(BOLT_RT_FLAGS ${BOLT_RT_FLAGS}
4146
-mno-sse

0 commit comments

Comments
 (0)