[libc-commits] [libc] bf0ded8 - [libc][NFC] split standalone_cpp into single headers

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Mar 8 11:56:13 PST 2022


Author: Michael Jones
Date: 2022-03-08T11:56:08-08:00
New Revision: bf0ded805ad0ee977d3462e3face546fad93d0ed

URL: https://github.com/llvm/llvm-project/commit/bf0ded805ad0ee977d3462e3face546fad93d0ed
DIFF: https://github.com/llvm/llvm-project/commit/bf0ded805ad0ee977d3462e3face546fad93d0ed.diff

LOG: [libc][NFC] split standalone_cpp into single headers

Previously, the entire support/CPP folder was in one header library,
which meant that a lot of headers were included where they shouldn't be.
This patch splits each header into its own target, as well as adjusting
each place they were included to only include what is used.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D121237

Added: 
    

Modified: 
    libc/fuzzing/math/CMakeLists.txt
    libc/src/__support/CMakeLists.txt
    libc/src/__support/CPP/CMakeLists.txt
    libc/src/__support/FPUtil/CMakeLists.txt
    libc/src/string/CMakeLists.txt
    libc/src/string/memory_utils/CMakeLists.txt
    libc/test/src/__support/CPP/CMakeLists.txt
    libc/test/src/math/CMakeLists.txt
    libc/test/src/math/exhaustive/CMakeLists.txt
    libc/test/src/stdlib/CMakeLists.txt
    libc/test/src/string/memory_utils/CMakeLists.txt
    libc/test/utils/UnitTest/CMakeLists.txt
    libc/utils/MPFRWrapper/CMakeLists.txt
    libc/utils/UnitTest/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/fuzzing/math/CMakeLists.txt b/libc/fuzzing/math/CMakeLists.txt
index b1e130eca73ab..8027cc121efaa 100644
--- a/libc/fuzzing/math/CMakeLists.txt
+++ b/libc/fuzzing/math/CMakeLists.txt
@@ -46,7 +46,7 @@ add_libc_fuzzer(
     libc.src.math.truncf
     libc.src.math.truncl
     libc.src.__support.FPUtil.fputil
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.type_traits
 )
 
 add_libc_fuzzer(

diff  --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 892011035127a..64837795196bd 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -23,7 +23,7 @@ add_header_library(
     .ctype_utils
     libc.include.errno
     libc.src.errno.errno
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.limits
 )
 
 add_header_library(
@@ -44,7 +44,7 @@ add_header_library(
     .high_precision_decimal
     libc.include.errno
     libc.src.errno.errno
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.limits
     libc.src.__support.FPUtil.fputil
 )
 

diff  --git a/libc/src/__support/CPP/CMakeLists.txt b/libc/src/__support/CPP/CMakeLists.txt
index dc1f131fc2a98..dfc28ea4aead1 100644
--- a/libc/src/__support/CPP/CMakeLists.txt
+++ b/libc/src/__support/CPP/CMakeLists.txt
@@ -1,15 +1,56 @@
-# TODO(michaelrj): separate the standalone_cpp library into individual targets.
 add_header_library(
-  standalone_cpp
+  array
   HDRS
     Array.h
+)
+
+add_header_library(
+  array_ref
+  HDRS
     ArrayRef.h
+)
+
+
+add_header_library(
+  bit
+  HDRS
     Bit.h
+)
+
+
+add_header_library(
+  bitset
+  HDRS
     Bitset.h
+)
+
+add_header_library(
+  functional
+  HDRS
     Functional.h
+)
+
+add_header_library(
+  limits
+  HDRS
     Limits.h
+)
+
+add_header_library(
+  string_view
+  HDRS
     StringView.h
+)
+
+add_header_library(
+  type_traits
+  HDRS
     TypeTraits.h
+)
+
+add_header_library(
+  utility
+  HDRS
     Utility.h
 )
 

diff  --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index a7acf3da70469..f1cd0b587d963 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -1,3 +1,4 @@
+#TODO(michaelrj): separate the fputil library into individual targets.
 add_header_library(
   fputil
   HDRS
@@ -19,7 +20,8 @@ add_header_library(
     libc.include.errno
     libc.include.fenv
     libc.src.__support.common
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.type_traits
+    libc.src.__support.CPP.bit
     libc.src.errno.errno
 )
 

diff  --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index ac29785574434..b763bda47cbb3 100644
--- a/libc/src/string/CMakeLists.txt
+++ b/libc/src/string/CMakeLists.txt
@@ -5,7 +5,7 @@ add_header_library(
   HDRS
     string_utils.h
   DEPENDS
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.bitset
 )
 
 add_entrypoint_object(
@@ -210,7 +210,7 @@ add_entrypoint_object(
   HDRS
     strspn.h
   DEPENDS
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.bitset
 )
 
 add_entrypoint_object(

diff  --git a/libc/src/string/memory_utils/CMakeLists.txt b/libc/src/string/memory_utils/CMakeLists.txt
index ca5cfdbd8db33..6cd45ddc42ace 100644
--- a/libc/src/string/memory_utils/CMakeLists.txt
+++ b/libc/src/string/memory_utils/CMakeLists.txt
@@ -1,3 +1,4 @@
+#TODO(michaelrj): split out the implementations from memory_utils
 add_header_library(
   memory_utils
   HDRS
@@ -8,7 +9,7 @@ add_header_library(
     memcpy_implementations.h
     memset_implementations.h
   DEPS
-    standalone_cpp
+    libc.src.__support.CPP.bit
 )
 
 add_header_library(

diff  --git a/libc/test/src/__support/CPP/CMakeLists.txt b/libc/test/src/__support/CPP/CMakeLists.txt
index 87bf81c88ae12..3464f68ccaddf 100644
--- a/libc/test/src/__support/CPP/CMakeLists.txt
+++ b/libc/test/src/__support/CPP/CMakeLists.txt
@@ -7,7 +7,7 @@ add_libc_unittest(
   SRCS
     bitset_test.cpp
   DEPENDS
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.bitset
 )
 
 add_libc_unittest(
@@ -17,7 +17,7 @@ add_libc_unittest(
   SRCS
     stringview_test.cpp
   DEPENDS
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.string_view
 )
 
 add_libc_unittest(
@@ -27,7 +27,7 @@ add_libc_unittest(
   SRCS
     limits_test.cpp
   DEPENDS
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.limits
 )
 
 add_libc_unittest(
@@ -37,7 +37,7 @@ add_libc_unittest(
   SRCS
     arrayref_test.cpp
   DEPENDS
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.array_ref
 )
 
 add_libc_unittest(
@@ -57,7 +57,7 @@ add_libc_unittest(
   SRCS
     integer_sequence_test.cpp
   DEPENDS
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.utility
 )
 
 add_libc_unittest(

diff  --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 0ca9cb55c74e6..68a9aed825a9f 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -12,7 +12,7 @@ add_fp_unittest(
   DEPENDS
     libc.include.errno
     libc.src.math.cosf
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.array
     libc.src.__support.FPUtil.fputil
 )
 
@@ -40,7 +40,7 @@ add_fp_unittest(
   DEPENDS
     libc.include.errno
     libc.src.math.sinf
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.array
     libc.src.__support.FPUtil.fputil
 )
 
@@ -68,7 +68,7 @@ add_fp_unittest(
   DEPENDS
     libc.include.errno
     libc.src.math.sincosf
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.array
     libc.src.__support.FPUtil.fputil
 )
 

diff  --git a/libc/test/src/math/exhaustive/CMakeLists.txt b/libc/test/src/math/exhaustive/CMakeLists.txt
index f02c3f7d4744a..2507bdfe90a2f 100644
--- a/libc/test/src/math/exhaustive/CMakeLists.txt
+++ b/libc/test/src/math/exhaustive/CMakeLists.txt
@@ -6,8 +6,6 @@ add_object_library(
     exhaustive_test.h
   SRCS
     exhaustive_test.cpp
-  DEPENDS
-    libc.src.__support.CPP.standalone_cpp
 )
 
 add_fp_unittest(

diff  --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 8534692b342b1..0cdb69bcc59d6 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -226,7 +226,8 @@ if(LLVM_LIBC_FULL_BUILD)
       libc.src.stdlib._Exit
       libc.src.stdlib.exit
       libc.src.stdlib.atexit
-      libc.src.__support.CPP.standalone_cpp
+      libc.src.__support.CPP.array
+      libc.src.__support.CPP.utility
   )
 
   # add_libc_unittest(

diff  --git a/libc/test/src/string/memory_utils/CMakeLists.txt b/libc/test/src/string/memory_utils/CMakeLists.txt
index 31276f128b14b..5705190c45e9b 100644
--- a/libc/test/src/string/memory_utils/CMakeLists.txt
+++ b/libc/test/src/string/memory_utils/CMakeLists.txt
@@ -8,7 +8,8 @@ add_libc_unittest(
     utils_test.cpp
   DEPENDS
     libc.src.string.memory_utils.memory_utils
-    libc.src.__support.CPP.standalone_cpp
+    libc.src.__support.CPP.array
+    libc.src.__support.CPP.array_ref
   COMPILE_OPTIONS
     ${LIBC_COMPILE_OPTIONS_NATIVE}
     -ffreestanding

diff  --git a/libc/test/utils/UnitTest/CMakeLists.txt b/libc/test/utils/UnitTest/CMakeLists.txt
index d677260d11557..d6031895e4153 100644
--- a/libc/test/utils/UnitTest/CMakeLists.txt
+++ b/libc/test/utils/UnitTest/CMakeLists.txt
@@ -7,5 +7,7 @@ add_libc_unittest(
   SRCS
     testfilter_test.cpp
   DEPENDS
-    libc.src.__support.CPP.standalone_cpp
+    # TODO(michaelrj): Remove this dependancy. It's only here because all unit 
+    # tests must have at least one dependancy.
+    libc.src.__support.CPP.bit 
 )

diff  --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt
index 95968669c17a0..70d598d3c5a98 100644
--- a/libc/utils/MPFRWrapper/CMakeLists.txt
+++ b/libc/utils/MPFRWrapper/CMakeLists.txt
@@ -6,7 +6,13 @@ if(LIBC_TESTS_CAN_USE_MPFR)
   add_compile_options(
     -O3
   )
-  add_dependencies(libcMPFRWrapper libc.src.__support.CPP.standalone_cpp libc.src.__support.FPUtil.fputil LibcUnitTest)
+  add_dependencies(
+    libcMPFRWrapper 
+    libc.src.__support.CPP.string_view 
+    libc.src.__support.CPP.type_traits 
+    libc.src.__support.FPUtil.fputil 
+    LibcUnitTest
+  )
   if(EXISTS ${LLVM_LIBC_MPFR_INSTALL_PATH})
     target_include_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/include)
     target_link_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/lib)

diff  --git a/libc/utils/UnitTest/CMakeLists.txt b/libc/utils/UnitTest/CMakeLists.txt
index 9d53d39a01e0d..e7890409bdffd 100644
--- a/libc/utils/UnitTest/CMakeLists.txt
+++ b/libc/utils/UnitTest/CMakeLists.txt
@@ -5,7 +5,7 @@ add_library(
   LibcTest.h
 )
 target_include_directories(LibcUnitTest PUBLIC ${LIBC_SOURCE_DIR})
-add_dependencies(LibcUnitTest libc.src.__support.CPP.standalone_cpp)
+add_dependencies(LibcUnitTest libc.src.__support.CPP.type_traits)
 target_link_libraries(LibcUnitTest PUBLIC libc_test_utils)
 
 add_library(
@@ -14,7 +14,7 @@ add_library(
 )
 
 target_include_directories(LibcUnitTestMain PUBLIC ${LIBC_SOURCE_DIR})
-add_dependencies(LibcUnitTestMain LibcUnitTest libc.src.__support.CPP.standalone_cpp)
+add_dependencies(LibcUnitTestMain LibcUnitTest)
 target_link_libraries(LibcUnitTestMain PUBLIC LibcUnitTest libc_test_utils)
 
 add_library(
@@ -29,7 +29,6 @@ target_link_libraries(LibcFPTestHelpers LibcUnitTest)
 add_dependencies(
   LibcFPTestHelpers
   LibcUnitTest
-  libc.src.__support.CPP.standalone_cpp
   libc.src.__support.FPUtil.fputil
 )
 
@@ -43,5 +42,5 @@ target_link_libraries(LibcMemoryHelpers LibcUnitTest)
 add_dependencies(
   LibcMemoryHelpers
   LibcUnitTest
-  libc.src.__support.CPP.standalone_cpp
+  libc.src.__support.CPP.array_ref
 )


        


More information about the libc-commits mailing list