From 8845e0d10efb03a6a13df560097bc4c748c675a7 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Fri, 1 Nov 2024 09:11:48 -0700 Subject: [PATCH] [libc][cmake] disable include tests in overlay mode This avoids -Wmacro-redefinition diagnostics observed when building the libc_include_tests ninja target. For example, the signbit_test will attempt to include BOTH our math-macros.h (via math-function-macros.h), and the system's math.h (via hdr/math_macros.h). While it's nice that we can get some coverage of the headers we will provide to end users of fullbuilds in CI of overlay builds, it's not worth chasing each individual conflict and disabling some include tests as conflicts arise. Disable the include tests unless `-DLLVM_LIBC_FULL_BUILD=ON` is specified. --- libc/test/CMakeLists.txt | 3 +- libc/test/include/CMakeLists.txt | 84 +++++++++++++++----------------- 2 files changed, 42 insertions(+), 45 deletions(-) diff --git a/libc/test/CMakeLists.txt b/libc/test/CMakeLists.txt index b5c989aa1d433..1a0780faff512 100644 --- a/libc/test/CMakeLists.txt +++ b/libc/test/CMakeLists.txt @@ -18,7 +18,6 @@ if(LIBC_TARGET_OS_IS_GPU) endif() endif() -add_subdirectory(include) add_subdirectory(src) add_subdirectory(utils) @@ -26,6 +25,8 @@ if(NOT LLVM_LIBC_FULL_BUILD) return() endif() +add_subdirectory(include) + if(NOT ${LIBC_TARGET_OS} STREQUAL "linux" AND NOT ${LIBC_TARGET_OS} STREQUAL "gpu") # Integration tests are currently only available for linux and the GPU. diff --git a/libc/test/include/CMakeLists.txt b/libc/test/include/CMakeLists.txt index 0d882eb49a738..146e43e580670 100644 --- a/libc/test/include/CMakeLists.txt +++ b/libc/test/include/CMakeLists.txt @@ -36,50 +36,46 @@ add_libc_test( -Wno-gnu-statement-expression-from-macro-expansion ) -# stdbit_test only tests our generated stdbit.h, which is not generated in -# overlay mode. -if(LLVM_LIBC_FULL_BUILD AND libc.include.stdbit IN_LIST TARGET_PUBLIC_HEADERS) - add_libc_test( - stdbit_test - SUITE - libc_include_tests - HDRS - stdbit_stub.h - SRCS - stdbit_test.cpp - DEPENDS - libc.include.llvm-libc-macros.stdbit_macros - libc.include.llvm_libc_common_h - libc.include.stdbit - # Intentionally do not depend on libc.src.stdbit.*. The include test is - # simply testing the macros provided by stdbit.h, not the implementation - # of the underlying functions which the type generic macros may dispatch - # to. - ) - add_libc_test( - stdbit_c_test - C_TEST - UNIT_TEST_ONLY - SUITE - libc_include_tests - HDRS - stdbit_stub.h - SRCS - stdbit_test.c - COMPILE_OPTIONS - -Wall - -Werror - DEPENDS - libc.include.llvm-libc-macros.stdbit_macros - libc.include.llvm_libc_common_h - libc.include.stdbit - libc.src.assert.__assert_fail - # Intentionally do not depend on libc.src.stdbit.*. The include test is - # simply testing the macros provided by stdbit.h, not the implementation - # of the underlying functions which the type generic macros may dispatch - # to. - ) -endif() +add_libc_test( + stdbit_test + SUITE + libc_include_tests + HDRS + stdbit_stub.h + SRCS + stdbit_test.cpp + DEPENDS + libc.include.llvm-libc-macros.stdbit_macros + libc.include.llvm_libc_common_h + libc.include.stdbit + # Intentionally do not depend on libc.src.stdbit.*. The include test is + # simply testing the macros provided by stdbit.h, not the implementation + # of the underlying functions which the type generic macros may dispatch + # to. +) +add_libc_test( + stdbit_c_test + C_TEST + UNIT_TEST_ONLY + SUITE + libc_include_tests + HDRS + stdbit_stub.h + SRCS + stdbit_test.c + COMPILE_OPTIONS + -Wall + -Werror + DEPENDS + libc.include.llvm-libc-macros.stdbit_macros + libc.include.llvm_libc_common_h + libc.include.stdbit + libc.src.assert.__assert_fail + # Intentionally do not depend on libc.src.stdbit.*. The include test is + # simply testing the macros provided by stdbit.h, not the implementation + # of the underlying functions which the type generic macros may dispatch + # to. +) add_libc_test( stdckdint_test