Skip to content

Commit 8a681ba

Browse files
author
Siva Chandra Reddy
committed
[libc] Remove common_libc_tuners.cmake and move options into config.json.
The name has been changed to adhere to the config option naming format. The necessary build changes to use the new option have also been made.
1 parent e504194 commit 8a681ba

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

libc/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ add_compile_definitions(LIBC_NAMESPACE=${LIBC_NAMESPACE})
6464
# Flags to pass down to the compiler while building the libc functions.
6565
set(LIBC_COMPILE_OPTIONS_DEFAULT "" CACHE STRING "Architecture to tell clang to optimize for (e.g. -march=... or -mcpu=...)")
6666

67-
include(common_libc_tuners.cmake)
68-
6967
list(APPEND LIBC_COMPILE_OPTIONS_DEFAULT ${LIBC_COMMON_TUNE_OPTIONS})
7068

7169
# Check --print-resource-dir to find the compiler resource dir if this flag

libc/cmake/modules/LLVMLibCObjectRules.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ function(create_entrypoint_object fq_target_name)
672672
target_compile_options(${internal_target_name} BEFORE PRIVATE ${common_compile_options})
673673
target_include_directories(${internal_target_name} PRIVATE ${include_dirs})
674674
add_dependencies(${internal_target_name} ${full_deps_list})
675+
target_link_libraries(${internal_target_name} ${full_deps_list})
675676

676677
add_library(
677678
${fq_target_name}
@@ -685,6 +686,7 @@ function(create_entrypoint_object fq_target_name)
685686
target_compile_options(${fq_target_name} BEFORE PRIVATE ${common_compile_options} -DLIBC_COPT_PUBLIC_PACKAGING)
686687
target_include_directories(${fq_target_name} PRIVATE ${include_dirs})
687688
add_dependencies(${fq_target_name} ${full_deps_list})
689+
target_link_libraries(${fq_target_name} ${full_deps_list})
688690
endif()
689691

690692
set_target_properties(

libc/common_libc_tuners.cmake

Lines changed: 0 additions & 14 deletions
This file was deleted.

libc/config/config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@
1616
"value": true,
1717
"doc": "Use large table for better printf long double performance."
1818
}
19+
},
20+
"string": {
21+
"LIBC_CONF_STRING_UNSAFE_WIDE_READ": {
22+
"value": false,
23+
"doc": "Read more than a byte at a time to perform byte-string operations like strlen."
24+
}
1925
}
2026
}

libc/docs/configure.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ to learn about the defaults for your platform and target.
3030
- ``LIBC_CONF_PRINTF_DISABLE_INDEX_MODE``: Disable index mode in the printf format string.
3131
- ``LIBC_CONF_PRINTF_DISABLE_WRITE_INT``: Disable handling of %n in printf format string.
3232
- ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE``: Use large table for better printf long double performance.
33+
* **"string" options**
34+
- ``LIBC_CONF_STRING_UNSAFE_WIDE_READ``: Read more than a byte at a time to perform byte-string operations like strlen.

libc/src/string/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
add_subdirectory(memory_utils)
22

3+
if(LIBC_CONF_STRING_UNSAFE_WIDE_READ)
4+
list(APPEND string_config_options "-DLIBC_COPT_STRING_UNSAFE_WIDE_READ")
5+
endif()
6+
if(string_config_options)
7+
list(PREPEND string_config_options "COMPILE_OPTIONS")
8+
endif()
9+
310
add_header_library(
411
string_utils
512
HDRS
@@ -10,6 +17,7 @@ add_header_library(
1017
libc.include.stdlib
1118
libc.src.__support.common
1219
libc.src.__support.CPP.bitset
20+
${string_config_options}
1321
)
1422

1523
add_header_library(

libc/src/string/string_utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ LIBC_INLINE size_t string_length_byte_read(const char *src) {
8888
// Returns the length of a string, denoted by the first occurrence
8989
// of a null terminator.
9090
LIBC_INLINE size_t string_length(const char *src) {
91-
#ifdef LIBC_COPT_UNSAFE_STRING_WIDE_READ
91+
#ifdef LIBC_COPT_STRING_UNSAFE_WIDE_READ
9292
// Unsigned int is the default size for most processors, and on x86-64 it
9393
// performs better than larger sizes when the src pointer can't be assumed to
9494
// be aligned to a word boundary, so it's the size we use for reading the
@@ -143,7 +143,7 @@ LIBC_INLINE void *find_first_character_byte_read(const unsigned char *src,
143143
// 'src'. If 'ch' is not found, returns nullptr.
144144
LIBC_INLINE void *find_first_character(const unsigned char *src,
145145
unsigned char ch, size_t max_strlen) {
146-
#ifdef LIBC_COPT_UNSAFE_STRING_WIDE_READ
146+
#ifdef LIBC_COPT_STRING_UNSAFE_WIDE_READ
147147
// If the maximum size of the string is small, the overhead of aligning to a
148148
// word boundary and generating a bitmask of the appropriate size may be
149149
// greater than the gains from reading larger chunks. Based on some testing,

0 commit comments

Comments
 (0)