diff --git a/libc/config/baremetal/config.json b/libc/config/baremetal/config.json index a65eaa8911e6c4..53f232e31cc8a4 100644 --- a/libc/config/baremetal/config.json +++ b/libc/config/baremetal/config.json @@ -8,6 +8,9 @@ }, "LIBC_CONF_PRINTF_DISABLE_WRITE_INT": { "value": true + }, + "LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE": { + "value": false } } } diff --git a/libc/config/config.json b/libc/config/config.json index cd68b81028bff7..134cf06a73b3ab 100644 --- a/libc/config/config.json +++ b/libc/config/config.json @@ -11,6 +11,10 @@ "LIBC_CONF_PRINTF_DISABLE_WRITE_INT": { "value": false, "doc": "Disable handling of %n in printf format string." + }, + "LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE": { + "value": true, + "doc": "Use large table for better printf long double performance." } } } diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst index 9b4d6034129351..a667316bd39915 100644 --- a/libc/docs/configure.rst +++ b/libc/docs/configure.rst @@ -29,3 +29,4 @@ to learn about the defaults for your platform and target. - ``LIBC_CONF_PRINTF_DISABLE_FLOAT``: Disable printing floating point values in printf and friends. - ``LIBC_CONF_PRINTF_DISABLE_INDEX_MODE``: Disable index mode in the printf format string. - ``LIBC_CONF_PRINTF_DISABLE_WRITE_INT``: Disable handling of %n in printf format string. + - ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE``: Use large table for better printf long double performance. diff --git a/libc/src/stdio/CMakeLists.txt b/libc/src/stdio/CMakeLists.txt index 740ec106da2e4d..de28b5c02071bf 100644 --- a/libc/src/stdio/CMakeLists.txt +++ b/libc/src/stdio/CMakeLists.txt @@ -363,6 +363,9 @@ endif() if(LIBC_CONF_PRINTF_DISABLE_WRITE_INT) list(APPEND printf_copts "-DLIBC_COPT_PRINTF_DISABLE_WRITE_INT") endif() +if(LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE) + list(APPEND printf_copts "-DLIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE") +endif() if(LLVM_LIBC_FULL_BUILD) list(APPEND printf_deps diff --git a/libc/src/stdio/printf_core/CMakeLists.txt b/libc/src/stdio/printf_core/CMakeLists.txt index 0b3766b55e8d4b..7087d28ede66e8 100644 --- a/libc/src/stdio/printf_core/CMakeLists.txt +++ b/libc/src/stdio/printf_core/CMakeLists.txt @@ -92,7 +92,6 @@ add_object_library( libc.src.__support.integer_to_string libc.src.__support.float_to_string COMPILE_OPTIONS - -DLIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE ${printf_copts} )