File tree Expand file tree Collapse file tree 8 files changed +55
-8
lines changed Expand file tree Collapse file tree 8 files changed +55
-8
lines changed Original file line number Diff line number Diff line change @@ -621,6 +621,32 @@ add_subdirectory(include)
621
621
622
622
option (COMPILER_RT_USE_LIBCXX
623
623
"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 ()
624
650
625
651
set (COMPILER_RT_LLD_PATH ${LLVM_MAIN_SRC_DIR} /tools/lld )
626
652
if (EXISTS ${COMPILER_RT_LLD_PATH} / AND LLVM_TOOL_LLD_BUILD )
Original file line number Diff line number Diff line change @@ -585,6 +585,13 @@ endmacro(add_compiler_rt_script src name)
585
585
# CFLAGS <list of compile flags>
586
586
# USE_TOOLCHAIN)
587
587
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
+
588
595
cmake_parse_arguments (LIBCXX "USE_TOOLCHAIN" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN} )
589
596
590
597
if (LIBCXX_USE_TOOLCHAIN )
Original file line number Diff line number Diff line change @@ -59,7 +59,9 @@ CHECK_CXX_SOURCE_COMPILES("
59
59
60
60
set (LIBFUZZER_CFLAGS ${COMPILER_RT_COMMON_CFLAGS} )
61
61
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 )
63
65
list (APPEND LIBFUZZER_CFLAGS -D_LIBCPP_ABI_VERSION=Fuzzer )
64
66
append_list_if (COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ LIBFUZZER_CFLAGS )
65
67
elseif (TARGET cxx-headers OR HAVE_LIBCXX )
@@ -132,7 +134,9 @@ add_compiler_rt_runtime(clang_rt.fuzzer_interceptors
132
134
CFLAGS ${LIBFUZZER_CFLAGS}
133
135
PARENT_TARGET fuzzer )
134
136
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 )
136
140
macro (partially_link_libcxx name dir arch )
137
141
get_target_flags_for_arch (${arch} target_cflags )
138
142
if (CMAKE_CXX_COMPILER_ID MATCHES Clang )
Original file line number Diff line number Diff line change 30
30
list (APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lpthread )
31
31
endif ()
32
32
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 )
34
36
list (APPEND LIBFUZZER_UNITTEST_CFLAGS -nostdinc++ -fno-exceptions )
35
37
list (APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -nostdlib++ -fno-exceptions )
36
38
endif ()
@@ -58,7 +60,9 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
58
60
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
59
61
FOLDER "Compiler-RT Runtime tests" )
60
62
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 )
62
66
file (GLOB libfuzzer_headers ../*.h )
63
67
set (LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build ${libfuzzer_headers} )
64
68
set (LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1 )
Original file line number Diff line number Diff line change @@ -130,7 +130,9 @@ macro(add_msan_tests_for_arch arch kind cflags)
130
130
endmacro ()
131
131
132
132
# 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 )
134
136
foreach (arch ${MSAN_SUPPORTED_ARCH} )
135
137
get_target_flags_for_arch (${arch} TARGET_CFLAGS )
136
138
set (LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR} /../libcxx_msan_${arch} )
Original file line number Diff line number Diff line change 24
24
endif ()
25
25
26
26
# 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
28
29
COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang" AND
29
30
NOT ANDROID )
30
31
set (libcxx_tsan_deps )
Original file line number Diff line number Diff line change @@ -45,7 +45,9 @@ if(NOT COMPILER_RT_STANDALONE_BUILD)
45
45
list (APPEND MSAN_TEST_DEPS msan )
46
46
endif ()
47
47
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 )
49
51
configure_lit_site_cfg (
50
52
${CMAKE_CURRENT_SOURCE_DIR} /Unit/lit.site.cfg.py.in
51
53
${CMAKE_CURRENT_BINARY_DIR} /Unit/lit.site.cfg.py )
Original file line number Diff line number Diff line change 7
7
if (NOT COMPILER_RT_STANDALONE_BUILD )
8
8
list (APPEND TSAN_TEST_DEPS tsan )
9
9
endif ()
10
- if (COMPILER_RT_USE_LIBCXX AND
10
+ if (COMPILER_RT_LIBCXX_PATH AND
11
+ COMPILER_RT_LIBCXXABI_PATH AND
11
12
COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang"
12
13
AND NOT APPLE AND NOT ANDROID )
13
14
list (APPEND TSAN_TEST_DEPS libcxx_tsan )
You can’t perform that action at this time.
0 commit comments