[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
This commit is contained in:
Michael Jones 2022-03-08 11:17:11 -08:00
parent 3f66882417
commit bf0ded805a
14 changed files with 78 additions and 27 deletions

View file

@ -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(

View file

@ -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
)

View file

@ -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
)

View file

@ -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
)

View file

@ -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(

View file

@ -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(

View file

@ -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(

View file

@ -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
)

View file

@ -6,8 +6,6 @@ add_object_library(
exhaustive_test.h
SRCS
exhaustive_test.cpp
DEPENDS
libc.src.__support.CPP.standalone_cpp
)
add_fp_unittest(

View file

@ -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(

View file

@ -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

View file

@ -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
)

View file

@ -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)

View file

@ -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
)