Skip to content

[libc][NFC] Do not add libc test framework and -fno-rtti to C tests. #84837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function(_get_common_compile_options output_var flags)
set(${output_var} ${compile_options} PARENT_SCOPE)
endfunction()

function(_get_common_test_compile_options output_var flags)
function(_get_common_test_compile_options output_var c_test flags)
_get_compile_options_from_flags(compile_flags ${flags})

set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${compile_flags})
Expand All @@ -122,7 +122,9 @@ function(_get_common_test_compile_options output_var flags)
list(APPEND compile_options "-fno-exceptions")
list(APPEND compile_options "-fno-unwind-tables")
list(APPEND compile_options "-fno-asynchronous-unwind-tables")
list(APPEND compile_options "-fno-rtti")
if(NOT ${c_test})
list(APPEND compile_options "-fno-rtti")
endif()
endif()

if(LIBC_COMPILER_HAS_FIXED_POINT)
Expand Down
15 changes: 10 additions & 5 deletions libc/cmake/modules/LLVMLibCTestRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function(create_libc_unittest fq_target_name)

cmake_parse_arguments(
"LIBC_UNITTEST"
"NO_RUN_POSTBUILD" # Optional arguments
"NO_RUN_POSTBUILD;C_TEST" # Optional arguments
"SUITE;CXX_STANDARD" # Single value arguments
"SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;LINK_LIBRARIES;FLAGS" # Multi-value arguments
${ARGN}
Expand All @@ -126,11 +126,14 @@ function(create_libc_unittest fq_target_name)
endif()

get_fq_deps_list(fq_deps_list ${LIBC_UNITTEST_DEPENDS})
list(APPEND fq_deps_list libc.src.__support.StringUtil.error_to_string
libc.test.UnitTest.ErrnoSetterMatcher)
if(NOT LIBC_UNITTEST_C_TEST)
list(APPEND fq_deps_list libc.src.__support.StringUtil.error_to_string
libc.test.UnitTest.ErrnoSetterMatcher)
endif()
list(REMOVE_DUPLICATES fq_deps_list)

_get_common_test_compile_options(compile_options "${LIBC_UNITTEST_FLAGS}")
_get_common_test_compile_options(compile_options "${LIBC_UNITTEST_C_TEST}"
"${LIBC_UNITTEST_FLAGS}")
list(APPEND compile_options ${LIBC_UNITTEST_COMPILE_OPTIONS})

if(SHOW_INTERMEDIATE_OBJECTS)
Expand Down Expand Up @@ -214,7 +217,9 @@ function(create_libc_unittest fq_target_name)
)

# LibcUnitTest should not depend on anything in LINK_LIBRARIES.
list(APPEND link_libraries LibcDeathTestExecutors.unit LibcTest.unit)
if(NOT LIBC_UNITTEST_C_TEST)
list(APPEND link_libraries LibcDeathTestExecutors.unit LibcTest.unit)
endif()

target_link_libraries(${fq_build_target_name} PRIVATE ${link_libraries})

Expand Down
1 change: 1 addition & 0 deletions libc/test/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if(LLVM_LIBC_FULL_BUILD AND libc.include.stdbit IN_LIST TARGET_PUBLIC_HEADERS)
)
add_libc_test(
stdbit_c_test
C_TEST
UNIT_TEST_ONLY
SUITE
libc_include_tests
Expand Down