[libc-commits] [libc] d37496e - [libc] Fix printf config not working (#66834)
via libc-commits
libc-commits at lists.llvm.org
Tue Sep 19 15:36:18 PDT 2023
Author: michaelrj-google
Date: 2023-09-19T15:36:14-07:00
New Revision: d37496e75a137fa3711d4cdd488c45f39ef9be91
URL: https://github.com/llvm/llvm-project/commit/d37496e75a137fa3711d4cdd488c45f39ef9be91
DIFF: https://github.com/llvm/llvm-project/commit/d37496e75a137fa3711d4cdd488c45f39ef9be91.diff
LOG: [libc] Fix printf config not working (#66834)
The list of printf copts available in config.json wasn't working because
the printf_core subdirectory was included before the printf_copts
variable was defined, making it effectively nothing for the printf
internals. Additionally, the tests weren't respecting the flags so they
would cause the tests to fail. This patch reorders the cmake in src and
adds flag handling in test.
Added:
Modified:
libc/src/stdio/CMakeLists.txt
libc/test/src/stdio/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/src/stdio/CMakeLists.txt b/libc/src/stdio/CMakeLists.txt
index a13321d13722953..f3a75fb965c6e16 100644
--- a/libc/src/stdio/CMakeLists.txt
+++ b/libc/src/stdio/CMakeLists.txt
@@ -26,9 +26,6 @@ if(NOT LIBC_TARGET_ARCHITECTURE_IS_GPU)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/generic)
endif()
-add_subdirectory(printf_core)
-add_subdirectory(scanf_core)
-
add_entrypoint_object(
fflush
SRCS
@@ -286,6 +283,9 @@ add_entrypoint_object(
${printf_copts}
)
+add_subdirectory(printf_core)
+add_subdirectory(scanf_core)
+
add_entrypoint_object(
ftell
SRCS
diff --git a/libc/test/src/stdio/CMakeLists.txt b/libc/test/src/stdio/CMakeLists.txt
index e042a8bd8be68f2..98fa2deb8b0e258 100644
--- a/libc/test/src/stdio/CMakeLists.txt
+++ b/libc/test/src/stdio/CMakeLists.txt
@@ -112,6 +112,16 @@ add_libc_unittest(
LibcMemoryHelpers
)
+if(LIBC_CONF_PRINTF_DISABLE_FLOAT)
+ list(APPEND sprintf_test_copts "-DLIBC_COPT_PRINTF_DISABLE_FLOAT")
+endif()
+if(LIBC_CONF_PRINTF_DISABLE_INDEX_MODE)
+ list(APPEND sprintf_test_copts "-DLIBC_COPT_PRINTF_DISABLE_INDEX_MODE")
+endif()
+if(LIBC_CONF_PRINTF_DISABLE_WRITE_INT)
+ list(APPEND sprintf_test_copts "-DLIBC_COPT_PRINTF_DISABLE_WRITE_INT")
+endif()
+
add_fp_unittest(
sprintf_test
UNIT_TEST_ONLY
@@ -123,6 +133,8 @@ add_fp_unittest(
libc.src.stdio.sprintf
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.platform_defs
+ COMPILE_OPTIONS
+ ${sprintf_test_copts}
)
add_libc_unittest(
More information about the libc-commits
mailing list