summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/Modules/AddCompilerRT.cmake81
-rw-r--r--lib/fuzzer/CMakeLists.txt6
-rw-r--r--lib/fuzzer/tests/CMakeLists.txt2
-rw-r--r--lib/msan/tests/CMakeLists.txt2
-rw-r--r--lib/tsan/CMakeLists.txt2
-rw-r--r--test/fuzzer/lit.cfg6
-rw-r--r--test/tsan/lit.cfg2
7 files changed, 70 insertions, 31 deletions
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index f81eb3342..2383670a9 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -477,56 +477,97 @@ macro(add_custom_libcxx name prefix)
foreach(flag ${LIBCXX_CFLAGS})
set(flagstr "${flagstr} ${flag}")
endforeach()
- set(LIBCXX_CFLAGS ${flagstr})
+ set(LIBCXX_C_FLAGS ${flagstr})
+ set(LIBCXX_CXX_FLAGS ${flagstr})
if(LIBCXX_USE_TOOLCHAIN)
set(compiler_args -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER}
-DCMAKE_CXX_COMPILER=${COMPILER_RT_TEST_CXX_COMPILER})
if(NOT COMPILER_RT_STANDALONE_BUILD)
- set(force_deps DEPENDS clang)
+ set(toolchain_deps $<TARGET_FILE:clang>)
+ set(force_deps DEPENDS $<TARGET_FILE:clang>)
endif()
else()
set(compiler_args -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
endif()
+ set(STAMP_DIR ${prefix}-stamps/)
+ set(BINARY_DIR ${prefix}-bins/)
+
+ add_custom_target(${name}-clear
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
+ COMMENT "Clobbering ${name} build and stamp directories"
+ USES_TERMINAL
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp
+ DEPENDS ${LIBCXX_DEPS} ${toolchain_deps}
+ COMMAND ${CMAKE_COMMAND} -E touch ${BINARY_DIR}/CMakeCache.txt
+ COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_DIR}/${name}-mkdir
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp
+ COMMENT "Clobbering bootstrap build and stamp directories"
+ )
+
+ add_custom_target(${name}-clobber
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp)
+
if(CMAKE_SYSROOT)
set(sysroot_arg -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
endif()
ExternalProject_Add(${name}
- DEPENDS ${LIBCXX_DEPS}
+ DEPENDS ${name}-clobber ${LIBCXX_DEPS}
PREFIX ${prefix}
SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH}
+ STAMP_DIR ${STAMP_DIR}
+ BINARY_DIR ${BINARY_DIR}
CMAKE_ARGS -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
${compiler_args}
${sysroot_arg}
- -DCMAKE_C_FLAGS=${LIBCXX_CFLAGS}
- -DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS}
+ -DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
+ -DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+ -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
- -DLIBCXX_STANDALONE_BUILD=On
+ -DLLVM_BINARY_DIR=${prefix}
+ -DLLVM_LIBRARY_OUTPUT_INTDIR=${prefix}/lib
+ -DLIBCXX_STANDALONE_BUILD=ON
${LIBCXX_CMAKE_ARGS}
- STEP_TARGETS configure build install
- LOG_BUILD 1
- LOG_CONFIGURE 1
- LOG_INSTALL 1
+ INSTALL_COMMAND ""
+ STEP_TARGETS configure build
+ BUILD_ALWAYS 1
+ USES_TERMINAL_CONFIGURE 1
+ USES_TERMINAL_BUILD 1
+ USES_TERMINAL_INSTALL 1
EXCLUDE_FROM_ALL TRUE
)
- ExternalProject_Add_Step(${name} force-reconfigure
- DEPENDERS configure
- ALWAYS 1
- )
+ if (CMAKE_GENERATOR MATCHES "Make")
+ set(run_clean "$(MAKE)" "-C" "${BINARY_DIR}" "clean")
+ else()
+ set(run_clean ${CMAKE_COMMAND} --build ${BINARY_DIR} --target clean
+ --config "$<CONFIGURATION>")
+ endif()
- ExternalProject_Add_Step(${name} clobber
- COMMAND ${CMAKE_COMMAND} -E remove_directory <BINARY_DIR>
- COMMAND ${CMAKE_COMMAND} -E make_directory <BINARY_DIR>
- COMMENT "Clobberring ${name} build directory..."
- DEPENDERS configure
+ ExternalProject_Add_Step(${name} clean
+ COMMAND ${run_clean}
+ COMMENT "Cleaning ${name}..."
+ DEPENDEES configure
${force_deps}
+ WORKING_DIRECTORY ${BINARY_DIR}
+ EXCLUDE_FROM_MAIN 1
+ USES_TERMINAL 1
)
+ ExternalProject_Add_StepTargets(${name} clean)
+
+ if(LIBCXX_USE_TOOLCHAIN)
+ add_dependencies(${name}-clean ${name}-clobber)
+ set_target_properties(${name}-clean PROPERTIES
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp)
+ endif()
endmacro()
function(rt_externalize_debuginfo name)
diff --git a/lib/fuzzer/CMakeLists.txt b/lib/fuzzer/CMakeLists.txt
index 3cc941be0..5ddf93c3c 100644
--- a/lib/fuzzer/CMakeLists.txt
+++ b/lib/fuzzer/CMakeLists.txt
@@ -86,7 +86,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND COMPILER_RT_LIBCXX_PATH)
set(cxx_${arch}_merge_dir "${CMAKE_CURRENT_BINARY_DIR}/cxx_${arch}_merge.dir")
file(MAKE_DIRECTORY ${cxx_${arch}_merge_dir})
add_custom_command(TARGET clang_rt.${name}-${arch} POST_BUILD
- COMMAND ${CMAKE_LINKER} --whole-archive "$<TARGET_LINKER_FILE:clang_rt.${name}-${arch}>" --no-whole-archive ${dir}/src/libcxx_fuzzer_${arch}-build/lib/libc++.a -r -o ${name}.o
+ COMMAND ${CMAKE_LINKER} --whole-archive "$<TARGET_LINKER_FILE:clang_rt.${name}-${arch}>" --no-whole-archive ${dir}/lib/libc++.a -r -o ${name}.o
COMMAND ${CMAKE_OBJCOPY} --localize-hidden ${name}.o
COMMAND ${CMAKE_COMMAND} -E remove "$<TARGET_LINKER_FILE:clang_rt.${name}-${arch}>"
COMMAND ${CMAKE_AR} qcs "$<TARGET_LINKER_FILE:clang_rt.${name}-${arch}>" ${name}.o
@@ -104,9 +104,9 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND COMPILER_RT_LIBCXX_PATH)
-fvisibility=hidden
CMAKE_ARGS -DLIBCXX_ENABLE_EXCEPTIONS=OFF
-DLIBCXX_CXX_ABI=none)
- target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${COMPILER_RT_LIBCXX_PATH}/include)
+ target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-build)
- target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem ${COMPILER_RT_LIBCXX_PATH}/include)
+ target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-build)
partially_link_libcxx(fuzzer_no_main ${LIBCXX_${arch}_PREFIX} ${arch})
partially_link_libcxx(fuzzer ${LIBCXX_${arch}_PREFIX} ${arch})
diff --git a/lib/fuzzer/tests/CMakeLists.txt b/lib/fuzzer/tests/CMakeLists.txt
index ef8478635..7f5b7f0c4 100644
--- a/lib/fuzzer/tests/CMakeLists.txt
+++ b/lib/fuzzer/tests/CMakeLists.txt
@@ -40,7 +40,7 @@ foreach(arch ${FUZZER_SUPPORTED_ARCH})
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND COMPILER_RT_LIBCXX_PATH)
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build)
set(LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${COMPILER_RT_LIBCXX_PATH}/include)
- set(LIBFUZZER_TEST_RUNTIME_LINK_FLAGS ${LIBCXX_${arch}_PREFIX}/src/libcxx_fuzzer_${arch}-build/lib/libc++.a)
+ set(LIBFUZZER_TEST_RUNTIME_LINK_FLAGS ${LIBCXX_${arch}_PREFIX}/lib/libc++.a)
endif()
set(FuzzerTestObjects)
diff --git a/lib/msan/tests/CMakeLists.txt b/lib/msan/tests/CMakeLists.txt
index 84e05a9c8..e9f4e34bf 100644
--- a/lib/msan/tests/CMakeLists.txt
+++ b/lib/msan/tests/CMakeLists.txt
@@ -109,7 +109,7 @@ macro(add_msan_tests_for_arch arch kind cflags)
DEPS ${MSAN_INST_LOADABLE_OBJECTS})
set(MSAN_TEST_OBJECTS ${MSAN_INST_TEST_OBJECTS} ${MSAN_INST_GTEST})
- set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-install
+ set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-build
${MSAN_LOADABLE_SO})
if(NOT COMPILER_RT_STANDALONE_BUILD)
list(APPEND MSAN_TEST_DEPS msan)
diff --git a/lib/tsan/CMakeLists.txt b/lib/tsan/CMakeLists.txt
index ed11aebf5..11ec9d8cf 100644
--- a/lib/tsan/CMakeLists.txt
+++ b/lib/tsan/CMakeLists.txt
@@ -214,7 +214,7 @@ if(COMPILER_RT_LIBCXX_PATH AND
DEPS ${TSAN_RUNTIME_LIBRARIES}
CFLAGS ${TARGET_CFLAGS} -fsanitize=thread
USE_TOOLCHAIN)
- list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-install)
+ list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-build)
endforeach()
add_custom_target(libcxx_tsan DEPENDS ${libcxx_tsan_deps})
diff --git a/test/fuzzer/lit.cfg b/test/fuzzer/lit.cfg
index 8a1d3eeb9..0789cbc91 100644
--- a/test/fuzzer/lit.cfg
+++ b/test/fuzzer/lit.cfg
@@ -7,8 +7,6 @@ config.test_format = lit.formats.ShTest(True)
config.suffixes = ['.test']
config.test_source_root = os.path.dirname(__file__)
-config.environment['LD_LIBRARY_PATH'] = config.llvm_library_dir
-
# Choose between lit's internal shell pipeline runner and a real shell. If
# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
@@ -54,9 +52,9 @@ config.substitutions.append(('%libfuzzer_src', libfuzzer_src_root))
def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True):
compiler_cmd = config.c_compiler
if config.clang and config.stdlib == 'libc++':
- link_cmd = '-stdlib=libc++'
+ link_cmd = '-stdlib=libc++ -Wl,-rpath=%s' % config.llvm_library_dir
elif config.clang and config.stdlib == 'static-libc++':
- link_cmd = '-stdlib=libc++ -lc++abi -static-libstdc++'
+ link_cmd = '-stdlib=libc++ -lc++abi -static-libstdc++ -Wl,-rpath=%s' % config.llvm_library_dir
else:
link_cmd = '-lc++' if any(x in config.target_triple for x in ('darwin', 'freebsd')) else '-lstdc++'
std_cmd = '--driver-mode=g++ -std=c++11' if is_cpp else ''
diff --git a/test/tsan/lit.cfg b/test/tsan/lit.cfg
index fdd3559ba..0128d958b 100644
--- a/test/tsan/lit.cfg
+++ b/test/tsan/lit.cfg
@@ -56,7 +56,7 @@ clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + ["-std=c++11"]
if config.has_libcxx and config.host_os != 'Darwin':
# FIXME: Dehardcode this path somehow.
libcxx_path = os.path.join(config.compiler_rt_obj_root, "lib",
- "tsan", "libcxx_tsan_" + config.target_arch)
+ "tsan", "libcxx_tsan_%s" % config.target_arch)
libcxx_incdir = os.path.join(libcxx_path, "include", "c++", "v1")
libcxx_libdir = os.path.join(libcxx_path, "lib")
libcxx_so = os.path.join(libcxx_libdir, "libc++.so")