Skip to content

Commit f3caa98

Browse files
committed
Revert "[CMake][compiler-rt] Clean up the use of libcxx and libcxxabi"
This reverts commit 4164cfa since it broke the clang-x86_64-debian-fast builder: https://lab.llvm.org/buildbot/#/builders/109/builds/41339
1 parent 4164cfa commit f3caa98

File tree

8 files changed

+55
-8
lines changed

8 files changed

+55
-8
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,32 @@ add_subdirectory(include)
621621

622622
option(COMPILER_RT_USE_LIBCXX
623623
"Enable compiler-rt to use libc++ from the source tree" ON)
624+
if(COMPILER_RT_USE_LIBCXX)
625+
if(LLVM_ENABLE_PROJECTS_USED)
626+
# Don't use libcxx if LLVM_ENABLE_PROJECTS does not enable it.
627+
set(COMPILER_RT_LIBCXX_PATH ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR})
628+
set(COMPILER_RT_LIBCXXABI_PATH ${LLVM_EXTERNAL_LIBCXXABI_SOURCE_DIR})
629+
else()
630+
foreach(path IN ITEMS ${LLVM_MAIN_SRC_DIR}/projects/libcxx
631+
${LLVM_MAIN_SRC_DIR}/runtimes/libcxx
632+
${LLVM_MAIN_SRC_DIR}/../libcxx
633+
${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR})
634+
if(IS_DIRECTORY ${path})
635+
set(COMPILER_RT_LIBCXX_PATH ${path})
636+
break()
637+
endif()
638+
endforeach()
639+
foreach(path IN ITEMS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi
640+
${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi
641+
${LLVM_MAIN_SRC_DIR}/../libcxxabi
642+
${LLVM_EXTERNAL_LIBCXXABI_SOURCE_DIR})
643+
if(IS_DIRECTORY ${path})
644+
set(COMPILER_RT_LIBCXXABI_PATH ${path})
645+
break()
646+
endif()
647+
endforeach()
648+
endif()
649+
endif()
624650

625651
set(COMPILER_RT_LLD_PATH ${LLVM_MAIN_SRC_DIR}/tools/lld)
626652
if(EXISTS ${COMPILER_RT_LLD_PATH}/ AND LLVM_TOOL_LLD_BUILD)

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,13 @@ endmacro(add_compiler_rt_script src name)
585585
# CFLAGS <list of compile flags>
586586
# USE_TOOLCHAIN)
587587
macro(add_custom_libcxx name prefix)
588+
if(NOT COMPILER_RT_LIBCXX_PATH)
589+
message(FATAL_ERROR "libcxx not found!")
590+
endif()
591+
if(NOT COMPILER_RT_LIBCXXABI_PATH)
592+
message(FATAL_ERROR "libcxxabi not found!")
593+
endif()
594+
588595
cmake_parse_arguments(LIBCXX "USE_TOOLCHAIN" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN})
589596

590597
if(LIBCXX_USE_TOOLCHAIN)

compiler-rt/lib/fuzzer/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ CHECK_CXX_SOURCE_COMPILES("
5959

6060
set(LIBFUZZER_CFLAGS ${COMPILER_RT_COMMON_CFLAGS})
6161

62-
if(OS_NAME MATCHES "Linux|Fuchsia" AND COMPILER_RT_USE_LIBCXX)
62+
if(OS_NAME MATCHES "Linux|Fuchsia" AND
63+
COMPILER_RT_LIBCXX_PATH AND
64+
COMPILER_RT_LIBCXXABI_PATH)
6365
list(APPEND LIBFUZZER_CFLAGS -D_LIBCPP_ABI_VERSION=Fuzzer)
6466
append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ LIBFUZZER_CFLAGS)
6567
elseif(TARGET cxx-headers OR HAVE_LIBCXX)
@@ -132,7 +134,9 @@ add_compiler_rt_runtime(clang_rt.fuzzer_interceptors
132134
CFLAGS ${LIBFUZZER_CFLAGS}
133135
PARENT_TARGET fuzzer)
134136

135-
if(OS_NAME MATCHES "Linux|Fuchsia" AND COMPILER_RT_USE_LIBCXX)
137+
if(OS_NAME MATCHES "Linux|Fuchsia" AND
138+
COMPILER_RT_LIBCXX_PATH AND
139+
COMPILER_RT_LIBCXXABI_PATH)
136140
macro(partially_link_libcxx name dir arch)
137141
get_target_flags_for_arch(${arch} target_cflags)
138142
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)

compiler-rt/lib/fuzzer/tests/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ else()
3030
list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lpthread)
3131
endif()
3232

33-
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND COMPILER_RT_USE_LIBCXX)
33+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
34+
COMPILER_RT_LIBCXX_PATH AND
35+
COMPILER_RT_LIBCXXABI_PATH)
3436
list(APPEND LIBFUZZER_UNITTEST_CFLAGS -nostdinc++ -fno-exceptions)
3537
list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -nostdlib++ -fno-exceptions)
3638
endif()
@@ -58,7 +60,9 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
5860
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
5961
FOLDER "Compiler-RT Runtime tests")
6062

61-
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND COMPILER_RT_USE_LIBCXX)
63+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
64+
COMPILER_RT_LIBCXX_PATH AND
65+
COMPILER_RT_LIBCXXABI_PATH)
6266
file(GLOB libfuzzer_headers ../*.h)
6367
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build ${libfuzzer_headers})
6468
set(LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)

compiler-rt/lib/msan/tests/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ macro(add_msan_tests_for_arch arch kind cflags)
130130
endmacro()
131131

132132
# We should only build MSan unit tests if we can build instrumented libcxx.
133-
if(COMPILER_RT_CAN_EXECUTE_TESTS AND COMPILER_RT_USE_LIBCXX)
133+
if(COMPILER_RT_CAN_EXECUTE_TESTS AND
134+
COMPILER_RT_LIBCXX_PATH AND
135+
COMPILER_RT_LIBCXXABI_PATH)
134136
foreach(arch ${MSAN_SUPPORTED_ARCH})
135137
get_target_flags_for_arch(${arch} TARGET_CFLAGS)
136138
set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/../libcxx_msan_${arch})

compiler-rt/lib/tsan/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ else()
2424
endif()
2525

2626
# Build libcxx instrumented with TSan.
27-
if(COMPILER_RT_USE_LIBCXX AND
27+
if(COMPILER_RT_LIBCXX_PATH AND
28+
COMPILER_RT_LIBCXXABI_PATH AND
2829
COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang" AND
2930
NOT ANDROID)
3031
set(libcxx_tsan_deps)

compiler-rt/test/msan/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ if(NOT COMPILER_RT_STANDALONE_BUILD)
4545
list(APPEND MSAN_TEST_DEPS msan)
4646
endif()
4747

48-
if(COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_USE_LIBCXX)
48+
if(COMPILER_RT_INCLUDE_TESTS AND
49+
COMPILER_RT_LIBCXX_PATH AND
50+
COMPILER_RT_LIBCXXABI_PATH)
4951
configure_lit_site_cfg(
5052
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
5153
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py)

compiler-rt/test/tsan/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ endif()
77
if(NOT COMPILER_RT_STANDALONE_BUILD)
88
list(APPEND TSAN_TEST_DEPS tsan)
99
endif()
10-
if(COMPILER_RT_USE_LIBCXX AND
10+
if(COMPILER_RT_LIBCXX_PATH AND
11+
COMPILER_RT_LIBCXXABI_PATH AND
1112
COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang"
1213
AND NOT APPLE AND NOT ANDROID)
1314
list(APPEND TSAN_TEST_DEPS libcxx_tsan)

0 commit comments

Comments
 (0)