File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
utils/bazel/llvm-project-overlay/libc Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ set(LIBC_NAMESPACE ${default_namespace}
47
47
CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
48
48
)
49
49
50
+ # Codegen options.
51
+ option (LLVM_LIBC_KEEP_FRAME_POINTER "Keep frame pointers in LLVM libc" ON )
52
+ option (LLVM_LIBC_ENABLE_STACK_PROTECTOR "Enable stack protector for LLVM libc" ON )
53
+
50
54
if (LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD )
51
55
if (NOT LIBC_HDRGEN_EXE )
52
56
# We need to set up hdrgen first since other targets depend on it.
Original file line number Diff line number Diff line change @@ -60,6 +60,15 @@ function(_get_common_compile_options output_var flags)
60
60
if (LIBC_CC_SUPPORTS_PATTERN_INIT )
61
61
list (APPEND compile_options "-ftrivial-auto-var-init=pattern" )
62
62
endif ()
63
+ if (LLVM_LIBC_KEEP_FRAME_POINTER )
64
+ list (APPEND compile_options "-fno-omit-frame-pointer" )
65
+ if (LIBC_TARGET_ARCHITECTURE_IS_X86 )
66
+ list (APPEND compile_options "-mno-omit-leaf-frame-pointer" )
67
+ endif ()
68
+ endif ()
69
+ if (LLVM_LIBC_ENABLE_STACK_PROTECTOR )
70
+ list (APPEND compile_options "-fstack-protector-strong" )
71
+ endif ()
63
72
list (APPEND compile_options "-Wall" )
64
73
list (APPEND compile_options "-Wextra" )
65
74
# -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
Original file line number Diff line number Diff line change @@ -78,15 +78,20 @@ def libc_function(
78
78
its deps.
79
79
**kwargs: Other attributes relevant for a cc_library. For example, deps.
80
80
"""
81
-
81
+ # x86 targets have -mno-omit-leaf-frame-pointer.
82
+ copts = selects .with_or ({
83
+ PLATFORM_CPU_X86_64 : ["-mno-omit-leaf-frame-pointer" ],
84
+ "//conditions:default" : []
85
+ })
82
86
# We use the explicit equals pattern here because append and += mutate the
83
87
# original list, where this creates a new list and stores it in deps.
84
- copts = copts or []
85
88
copts = copts + [
86
89
"-O3" ,
87
90
"-fno-builtin" ,
88
91
"-fno-lax-vector-conversions" ,
89
92
"-ftrivial-auto-var-init=pattern" ,
93
+ "-fno-omit-frame-pointer" ,
94
+ "-fstack-protector-strong" ,
90
95
]
91
96
92
97
# We compile the code twice, the first target is suffixed with ".__internal__" and contains the
You can’t perform that action at this time.
0 commit comments