Move LIBC_CONF_STRING_UNSAFE_WIDE_READ to top-level libc-configuration (#165046)

This options sets a compile option when building sources inside the
string directory, and this option affects string_utils.h. But
string_utils.h is #included from more places than just the string
directory (such as from __support/CPP/string.h), leading to both
narrow-reads in those cases, but more seriously, ODR violations when the
two different string_length implementations are included int he same
program.

Having this option at the top level avoids this problem.
This commit is contained in:
Sterling-Augustine 2025-10-27 14:39:46 -07:00 committed by GitHub
parent 1c837ecaa0
commit 7d1538cd3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 11 deletions

View File

@ -81,6 +81,14 @@ function(_get_compile_options_from_config output_var)
list(APPEND config_options "-DLIBC_QSORT_IMPL=${LIBC_CONF_QSORT_IMPL}")
endif()
if(LIBC_CONF_STRING_UNSAFE_WIDE_READ)
list(APPEND config_options "-DLIBC_COPT_STRING_UNSAFE_WIDE_READ")
endif()
if(LIBC_CONF_MEMSET_X86_USE_SOFTWARE_PREFETCHING)
list(APPEND config_options "-DLIBC_COPT_MEMSET_X86_USE_SOFTWARE_PREFETCHING")
endif()
if(LIBC_TYPES_TIME_T_IS_32_BIT AND LLVM_LIBC_FULL_BUILD)
list(APPEND config_options "-DLIBC_TYPES_TIME_T_IS_32_BIT")
endif()

View File

@ -1,15 +1,5 @@
add_subdirectory(memory_utils)
if(LIBC_CONF_STRING_UNSAFE_WIDE_READ)
list(APPEND string_config_options "-DLIBC_COPT_STRING_UNSAFE_WIDE_READ")
endif()
if(LIBC_CONF_MEMSET_X86_USE_SOFTWARE_PREFETCHING)
list(APPEND string_config_options "-DLIBC_COPT_MEMSET_X86_USE_SOFTWARE_PREFETCHING")
endif()
if(string_config_options)
list(PREPEND string_config_options "COMPILE_OPTIONS")
endif()
add_header_library(
string_utils
HDRS
@ -24,7 +14,6 @@ add_header_library(
libc.src.__support.common
libc.src.__support.macros.attributes
libc.src.string.memory_utils.inline_memcpy
${string_config_options}
)
add_header_library(