[compiler-rt] 458ead6 - [compiler-rt] Use the runtimes build for custom libc++
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 8 12:53:18 PST 2021
Author: Petr Hosek
Date: 2021-12-08T12:52:48-08:00
New Revision: 458ead66dc378ee5b9cbeb453a9cb7c3de768b2e
URL: https://github.com/llvm/llvm-project/commit/458ead66dc378ee5b9cbeb453a9cb7c3de768b2e
DIFF: https://github.com/llvm/llvm-project/commit/458ead66dc378ee5b9cbeb453a9cb7c3de768b2e.diff
LOG: [compiler-rt] Use the runtimes build for custom libc++
Some of the compiler-rt runtimes use custom instrumented libc++ build.
Use the runtimes build for building this custom libc++.
Differential Revision: https://reviews.llvm.org/D114922
Added:
Modified:
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/lib/fuzzer/CMakeLists.txt
compiler-rt/lib/msan/tests/CMakeLists.txt
Removed:
compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
################################################################################
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index db65791af3ea2..b69833cbcc09b 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -565,13 +565,9 @@ macro(add_custom_libcxx name prefix)
-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"
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${prefix}
+ COMMENT "Clobbering ${name} build directories"
USES_TERMINAL
)
set_target_properties(${name}-clear PROPERTIES FOLDER "Compiler-RT Misc")
@@ -579,10 +575,9 @@ macro(add_custom_libcxx name prefix)
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 ${prefix}/CMakeCache.txt
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp
- COMMENT "Clobbering bootstrap build and stamp directories"
+ COMMENT "Clobbering bootstrap build directories"
)
add_custom_target(${name}-clobber
@@ -629,10 +624,9 @@ macro(add_custom_libcxx name prefix)
ExternalProject_Add(${name}
DEPENDS ${name}-clobber ${LIBCXX_DEPS}
- PREFIX ${prefix}
- SOURCE_DIR ${COMPILER_RT_SOURCE_DIR}/cmake/Modules/CustomLibcxx
- STAMP_DIR ${STAMP_DIR}
- BINARY_DIR ${BINARY_DIR}
+ PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${name}
+ SOURCE_DIR ${LLVM_MAIN_SRC_DIR}/../runtimes
+ BINARY_DIR ${prefix}
CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES}
${compiler_args}
-DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
@@ -640,10 +634,16 @@ macro(add_custom_libcxx name prefix)
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
- -DLLVM_BINARY_DIR=${prefix}
- -DLLVM_LIBRARY_OUTPUT_INTDIR=${prefix}/lib
- -DCOMPILER_RT_LIBCXX_PATH=${COMPILER_RT_LIBCXX_PATH}
- -DCOMPILER_RT_LIBCXXABI_PATH=${COMPILER_RT_LIBCXXABI_PATH}
+ -DLLVM_ENABLE_RUNTIMES=libcxx|libcxxabi
+ -DLIBCXXABI_ENABLE_SHARED=OFF
+ -DLIBCXXABI_HERMETIC_STATIC_LIBRARY=ON
+ -DLIBCXXABI_INCLUDE_TESTS=OFF
+ -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
+ -DLIBCXX_ENABLE_SHARED=OFF
+ -DLIBCXX_HERMETIC_STATIC_LIBRARY=ON
+ -DLIBCXX_INCLUDE_BENCHMARKS=OFF
+ -DLIBCXX_INCLUDE_TESTS=OFF
+ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
${LIBCXX_CMAKE_ARGS}
INSTALL_COMMAND ""
STEP_TARGETS configure build
@@ -651,14 +651,15 @@ macro(add_custom_libcxx name prefix)
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
USES_TERMINAL_INSTALL 1
+ LIST_SEPARATOR |
EXCLUDE_FROM_ALL TRUE
BUILD_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
)
if (CMAKE_GENERATOR MATCHES "Make")
- set(run_clean "$(MAKE)" "-C" "${BINARY_DIR}" "clean")
+ set(run_clean "$(MAKE)" "-C" "${prefix}" "clean")
else()
- set(run_clean ${CMAKE_COMMAND} --build ${BINARY_DIR} --target clean
+ set(run_clean ${CMAKE_COMMAND} --build ${prefix} --target clean
--config "$<CONFIG>")
endif()
@@ -667,7 +668,7 @@ macro(add_custom_libcxx name prefix)
COMMENT "Cleaning ${name}..."
DEPENDEES configure
${force_deps}
- WORKING_DIRECTORY ${BINARY_DIR}
+ WORKING_DIRECTORY ${prefix}
EXCLUDE_FROM_MAIN 1
USES_TERMINAL 1
)
diff --git a/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt b/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
deleted file mode 100644
index e69d403d6e3b2..0000000000000
--- a/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# TODO(phosek): We should use the runtimes build instead configured with
-# LLVM_ENABLE_RUNTIMES=libcxxabi;libcxx to avoid duplication of logic.
-
-cmake_minimum_required(VERSION 3.13.4)
-project(custom-libcxx C CXX)
-
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
-
-# Build static libcxxabi.
-set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_EXCEPTIONS ON CACHE BOOL "")
-set(LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE STRING "")
-set(LIBCXXABI_LIBCXX_PATH ${COMPILER_RT_LIBCXX_PATH} CACHE PATH "")
-set(LIBCXXABI_INCLUDE_TESTS OFF CACHE BOOL "")
-add_subdirectory(${COMPILER_RT_LIBCXXABI_PATH} ${CMAKE_CURRENT_BINARY_DIR}/cxxabi)
-
-# Build static libcxx without exceptions.
-set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
-set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
-set(LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
-
-# Use above libcxxabi.
-set(LIBCXX_CXX_ABI "libcxxabi" CACHE STRING "")
-set(LIBCXX_CXX_ABI_INTREE 1)
-set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
-set(LIBCXX_CXX_ABI_INCLUDE_PATHS ${COMPILER_RT_LIBCXXABI_PATH}/include CACHE PATH "")
-set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
-set(LIBCXX_INCLUDE_TESTS OFF CACHE BOOL "")
-
-add_subdirectory(${COMPILER_RT_LIBCXX_PATH} ${CMAKE_CURRENT_BINARY_DIR}/cxx)
diff --git a/compiler-rt/lib/fuzzer/CMakeLists.txt b/compiler-rt/lib/fuzzer/CMakeLists.txt
index b44569d01ea5f..3b9d7b71605ed 100644
--- a/compiler-rt/lib/fuzzer/CMakeLists.txt
+++ b/compiler-rt/lib/fuzzer/CMakeLists.txt
@@ -162,7 +162,8 @@ if(OS_NAME MATCHES "Linux|Fuchsia" AND
CMAKE_ARGS -DCMAKE_CXX_COMPILER_WORKS=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF
- -DLIBCXX_ABI_NAMESPACE=__Fuzzer)
+ -DLIBCXX_ABI_NAMESPACE=__Fuzzer
+ -DLIBCXX_ENABLE_EXCEPTIONS=OFF)
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 ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
diff --git a/compiler-rt/lib/msan/tests/CMakeLists.txt b/compiler-rt/lib/msan/tests/CMakeLists.txt
index de2b582281bac..dc8408042bd0b 100644
--- a/compiler-rt/lib/msan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/msan/tests/CMakeLists.txt
@@ -52,6 +52,7 @@ set(MSAN_UNITTEST_INSTRUMENTED_CFLAGS
-mllvm -msan-keep-going=1
)
set(MSAN_UNITTEST_LINK_FLAGS
+ -nostdlib++
${COMPILER_RT_UNITTEST_LINK_FLAGS}
-fsanitize=memory
# Don't need -stdlib=libc++ because we explicitly list libc++.a in the linker
More information about the llvm-commits
mailing list