diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 0c1fdae04cf955..a0d79858a896ad 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -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. diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index df7311f8ec6d9d..40a1cfda060e6f 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -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") diff --git a/libc/config/config.json b/libc/config/config.json index b73c47b1a14bc7..d6ef891b9f260f 100644 --- a/libc/config/config.json +++ b/libc/config/config.json @@ -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." + } } } diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst index a177550647bd91..8f8c44caa11539 100644 --- a/libc/docs/configure.rst +++ b/libc/docs/configure.rst @@ -25,6 +25,9 @@ See the main ``config/config.json``, and the platform and architecture specific overrides in ``config//config.json`` and ``config///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.