Skip to content

Commit

Permalink
use config.json instead
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu committed Mar 29, 2024
1 parent 943b234 commit da20563
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 0 additions & 4 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ set(LIBC_NAMESPACE ${default_namespace}
CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
)

# Codegen options.
option(LLVM_LIBC_KEEP_FRAME_POINTER "Keep frame pointers in LLVM libc" ON)
option(LLVM_LIBC_ENABLE_STACK_PROTECTOR "Enable stack protector for LLVM libc" ON)

if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD)
if(NOT LIBC_HDRGEN_EXE)
# We need to set up hdrgen first since other targets depend on it.
Expand Down
4 changes: 2 additions & 2 deletions libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ function(_get_common_compile_options output_var flags)
if (LIBC_CC_SUPPORTS_PATTERN_INIT)
list(APPEND compile_options "-ftrivial-auto-var-init=pattern")
endif()
if (LLVM_LIBC_KEEP_FRAME_POINTER)
if (LIBC_CONF_KEEP_FRAME_POINTER)
list(APPEND compile_options "-fno-omit-frame-pointer")
if (LIBC_TARGET_ARCHITECTURE_IS_X86)
list(APPEND compile_options "-mno-omit-leaf-frame-pointer")
endif()
endif()
if (LLVM_LIBC_ENABLE_STACK_PROTECTOR)
if (LIBC_CONF_ENABLE_STACK_PROTECTOR)
list(APPEND compile_options "-fstack-protector-strong")
endif()
list(APPEND compile_options "-Wall")
Expand Down
10 changes: 10 additions & 0 deletions libc/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@
"value": false,
"doc": "Inserts prefetch for write instructions (PREFETCHW) for memset on x86 to recover performance when hardware prefetcher is disabled."
}
},
"codegen": {
"LIBC_CONF_KEEP_FRAME_POINTER": {
"value": true,
"doc": "Keep frame pointer in functions for better debugging experience."
},
"LIBC_CONF_ENABLE_STRONG_STACK_PROTECTOR": {
"value": true,
"doc": "Enable -fstack-protector-strong to defend against stack smashing attack."
}
}
}
3 changes: 3 additions & 0 deletions libc/docs/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ See the main ``config/config.json``, and the platform and architecture specific
overrides in ``config/<platform>/config.json`` and ``config/<platform>/<arch>/config.json,``
to learn about the defaults for your platform and target.

* **"codegen" options**
- ``LIBC_CONF_ENABLE_STRONG_STACK_PROTECTOR``: Enable -fstack-protector-strong to defend against stack smashing attack.
- ``LIBC_CONF_KEEP_FRAME_POINTER``: Keep frame pointer in functions for better debugging experience.
* **"printf" options**
- ``LIBC_CONF_PRINTF_DISABLE_FIXED_POINT``: Disable printing fixed point values in printf and friends.
- ``LIBC_CONF_PRINTF_DISABLE_FLOAT``: Disable printing floating point values in printf and friends.
Expand Down

0 comments on commit da20563

Please sign in to comment.