Index: cmake/Modules/AddCompilerRT.cmake =================================================================== --- cmake/Modules/AddCompilerRT.cmake +++ cmake/Modules/AddCompilerRT.cmake @@ -459,6 +459,53 @@ DESTINATION ${COMPILER_RT_INSTALL_PATH}/bin) endmacro(add_compiler_rt_script src name) +# Builds internal version of libc++. +# Can be used to build private libc++ to be linked to other libraries. +# add_internal_libcxx( +# DEPS +# CFLAGS ) +macro(add_internal_libcxx name prefix) + if(NOT COMPILER_RT_LIBCXX_PATH) + message(FATAL_ERROR "libcxx not found!") + endif() + + cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN}) + foreach(flag ${LIBCXX_CFLAGS}) + set(flagstr "${flagstr} ${flag}") + endforeach() + set(LIBCXX_CFLAGS ${flagstr}) + + ExternalProject_Add(${name} + PREFIX ${prefix} + SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH} + CMAKE_ARGS -DCMAKE_MAKE_PROGRAM:STRING=${CMAKE_MAKE_PROGRAM} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_C_FLAGS=${LIBCXX_CFLAGS} + -DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS} + -DCMAKE_BUILD_TYPE=Release + -DLLVM_PATH=${LLVM_MAIN_SRC_DIR} + -DLIBCXX_STANDALONE_BUILD=On + ${LIBCXX_CMAKE_ARGS} + INSTALL_COMMAND "" + LOG_BUILD 1 + LOG_CONFIGURE 1 + ) + set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL TRUE) + + ExternalProject_Add_Step(${name} force-reconfigure + DEPENDERS configure + ALWAYS 1 + ) + + ExternalProject_Add_Step(${name} clobber + COMMAND ${CMAKE_COMMAND} -E remove_directory + COMMAND ${CMAKE_COMMAND} -E make_directory + COMMENT "Clobberring ${name} build directory..." + DEPENDERS configure + ) +endmacro() + # Builds custom version of libc++ and installs it in . # Can be used to build sanitized versions of libc++ for running unit tests. # add_custom_libcxx( Index: lib/fuzzer/CMakeLists.txt =================================================================== --- lib/fuzzer/CMakeLists.txt +++ lib/fuzzer/CMakeLists.txt @@ -95,9 +95,9 @@ foreach(arch ${FUZZER_SUPPORTED_ARCH}) get_target_flags_for_arch(${arch} TARGET_CFLAGS) set(LIBCXX_${arch}_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_fuzzer_${arch}) - add_custom_libcxx(libcxx_fuzzer_${arch} ${LIBCXX_${arch}_PREFIX} + add_internal_libcxx(libcxx_fuzzer_${arch} ${LIBCXX_${arch}_PREFIX} CFLAGS ${TARGET_CFLAGS} - -D_LIBCPP_ABI_VERSION=__Fuzzer + -D_LIBCPP_ABI_VERSION=Fuzzer -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=1 -fvisibility=hidden CMAKE_ARGS -DLIBCXX_ENABLE_EXCEPTIONS=OFF