From 99cc28b705e850933ac5bcd14abeb63425e51484 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Sat, 9 Jul 2022 04:27:16 +0000 Subject: [PATCH] Revert "[CMake] Use explicit header path when using in-tree libc++ for tests" This reverts commit 61b410cb8b9af0aa265e730a3070b3154d869803 as this appears to have broken some sanitizer tests. --- compiler-rt/CMakeLists.txt | 28 ++++++++----------- compiler-rt/lib/memprof/tests/CMakeLists.txt | 1 - .../lib/scudo/standalone/tests/CMakeLists.txt | 1 - compiler-rt/lib/tsan/tests/CMakeLists.txt | 1 - 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 8f9bd931f725..405583a7de02 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -521,17 +521,6 @@ string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} list(APPEND COMPILER_RT_COMMON_CFLAGS ${stdlib_flag}) list(APPEND COMPILER_RT_COMMON_LINK_FLAGS ${stdlib_flag}) -# TODO: There's a lot of duplication across lib/*/tests/CMakeLists.txt files, -# move some of the common flags to COMPILER_RT_UNITTEST_CFLAGS. - -# Unittests need access to C++ standard library. -string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag}") - -# When cross-compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help in compilation -# and linking of unittests. -string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}") -set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS}) - if(COMPILER_RT_USE_LLVM_UNWINDER) if (COMPILER_RT_ENABLE_STATIC_UNWINDER) set(unwinder_target unwind_static) @@ -594,11 +583,7 @@ if (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libc++") else() set(cxx_target cxx_shared) endif() - list(APPEND SANITIZER_TEST_CXX_LIBRARIES "$<$:$>") - list(APPEND SANITIZER_TEST_CXX_CFLAGS "$<$:-isystem$,$-isystem>>") - # We are using the in tree libc++ so avoid including the default one. - append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_UNITTEST_CFLAGS) - append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_UNITTEST_LINK_FLAGS) + list(APPEND SANITIZER_TEST_CXX_LIBRARIES "$<$>:$>") else() append_list_if(COMPILER_RT_HAS_LIBCXX -lc++ SANITIZER_TEST_CXX_LIBRARIES) endif() @@ -606,6 +591,17 @@ elseif (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libstdc++") append_list_if(COMPILER_RT_HAS_LIBSTDCXX -lstdc++ SANITIZER_TEST_CXX_LIBRARIES) endif() +# TODO: There's a lot of duplication across lib/*/tests/CMakeLists.txt files, +# move some of the common flags to COMPILER_RT_UNITTEST_CFLAGS. + +# Unittests need access to C++ standard library. +string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag}") + +# When cross-compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help in compilation +# and linking of unittests. +string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}") +set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS}) + # Unittests support. set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest) set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc) diff --git a/compiler-rt/lib/memprof/tests/CMakeLists.txt b/compiler-rt/lib/memprof/tests/CMakeLists.txt index 702bd2ef4343..9dcad644d098 100644 --- a/compiler-rt/lib/memprof/tests/CMakeLists.txt +++ b/compiler-rt/lib/memprof/tests/CMakeLists.txt @@ -4,7 +4,6 @@ include(CompilerRTLink) set(MEMPROF_UNITTEST_CFLAGS ${COMPILER_RT_UNITTEST_CFLAGS} - ${SANITIZER_TEST_CXX_CFLAGS} ${COMPILER_RT_GTEST_CFLAGS} ${COMPILER_RT_GMOCK_CFLAGS} -I${COMPILER_RT_SOURCE_DIR}/lib/ diff --git a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt index 837da9bb6a6a..b6b60a2c8ada 100644 --- a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt @@ -6,7 +6,6 @@ set_target_properties(ScudoUnitTests PROPERTIES set(SCUDO_UNITTEST_CFLAGS ${COMPILER_RT_UNITTEST_CFLAGS} - ${SANITIZER_TEST_CXX_CFLAGS} ${COMPILER_RT_GTEST_CFLAGS} -I${COMPILER_RT_SOURCE_DIR}/include -I${COMPILER_RT_SOURCE_DIR}/lib diff --git a/compiler-rt/lib/tsan/tests/CMakeLists.txt b/compiler-rt/lib/tsan/tests/CMakeLists.txt index e5fc94fd4751..91702c913592 100644 --- a/compiler-rt/lib/tsan/tests/CMakeLists.txt +++ b/compiler-rt/lib/tsan/tests/CMakeLists.txt @@ -6,7 +6,6 @@ set_target_properties(TsanUnitTests PROPERTIES set(TSAN_UNITTEST_CFLAGS ${COMPILER_RT_UNITTEST_CFLAGS} - ${SANITIZER_TEST_CXX_CFLAGS} ${COMPILER_RT_GTEST_CFLAGS} -I${COMPILER_RT_SOURCE_DIR}/include -I${COMPILER_RT_SOURCE_DIR}/lib