Skip to content

Commit 458ead6

Browse files
committed
[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
1 parent 36e7b8d commit 458ead6

File tree

4 files changed

+24
-52
lines changed

4 files changed

+24
-52
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -565,24 +565,19 @@ macro(add_custom_libcxx name prefix)
565565
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
566566
endif()
567567

568-
set(STAMP_DIR ${prefix}-stamps/)
569-
set(BINARY_DIR ${prefix}-bins/)
570-
571568
add_custom_target(${name}-clear
572-
COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
573-
COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
574-
COMMENT "Clobbering ${name} build and stamp directories"
569+
COMMAND ${CMAKE_COMMAND} -E remove_directory ${prefix}
570+
COMMENT "Clobbering ${name} build directories"
575571
USES_TERMINAL
576572
)
577573
set_target_properties(${name}-clear PROPERTIES FOLDER "Compiler-RT Misc")
578574

579575
add_custom_command(
580576
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp
581577
DEPENDS ${LIBCXX_DEPS} ${toolchain_deps}
582-
COMMAND ${CMAKE_COMMAND} -E touch ${BINARY_DIR}/CMakeCache.txt
583-
COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_DIR}/${name}-mkdir
578+
COMMAND ${CMAKE_COMMAND} -E touch ${prefix}/CMakeCache.txt
584579
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp
585-
COMMENT "Clobbering bootstrap build and stamp directories"
580+
COMMENT "Clobbering bootstrap build directories"
586581
)
587582

588583
add_custom_target(${name}-clobber
@@ -629,36 +624,42 @@ macro(add_custom_libcxx name prefix)
629624

630625
ExternalProject_Add(${name}
631626
DEPENDS ${name}-clobber ${LIBCXX_DEPS}
632-
PREFIX ${prefix}
633-
SOURCE_DIR ${COMPILER_RT_SOURCE_DIR}/cmake/Modules/CustomLibcxx
634-
STAMP_DIR ${STAMP_DIR}
635-
BINARY_DIR ${BINARY_DIR}
627+
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${name}
628+
SOURCE_DIR ${LLVM_MAIN_SRC_DIR}/../runtimes
629+
BINARY_DIR ${prefix}
636630
CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES}
637631
${compiler_args}
638632
-DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
639633
-DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
640634
-DCMAKE_BUILD_TYPE=Release
641635
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
642636
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
643-
-DLLVM_BINARY_DIR=${prefix}
644-
-DLLVM_LIBRARY_OUTPUT_INTDIR=${prefix}/lib
645-
-DCOMPILER_RT_LIBCXX_PATH=${COMPILER_RT_LIBCXX_PATH}
646-
-DCOMPILER_RT_LIBCXXABI_PATH=${COMPILER_RT_LIBCXXABI_PATH}
637+
-DLLVM_ENABLE_RUNTIMES=libcxx|libcxxabi
638+
-DLIBCXXABI_ENABLE_SHARED=OFF
639+
-DLIBCXXABI_HERMETIC_STATIC_LIBRARY=ON
640+
-DLIBCXXABI_INCLUDE_TESTS=OFF
641+
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
642+
-DLIBCXX_ENABLE_SHARED=OFF
643+
-DLIBCXX_HERMETIC_STATIC_LIBRARY=ON
644+
-DLIBCXX_INCLUDE_BENCHMARKS=OFF
645+
-DLIBCXX_INCLUDE_TESTS=OFF
646+
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
647647
${LIBCXX_CMAKE_ARGS}
648648
INSTALL_COMMAND ""
649649
STEP_TARGETS configure build
650650
BUILD_ALWAYS 1
651651
USES_TERMINAL_CONFIGURE 1
652652
USES_TERMINAL_BUILD 1
653653
USES_TERMINAL_INSTALL 1
654+
LIST_SEPARATOR |
654655
EXCLUDE_FROM_ALL TRUE
655656
BUILD_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
656657
)
657658

658659
if (CMAKE_GENERATOR MATCHES "Make")
659-
set(run_clean "$(MAKE)" "-C" "${BINARY_DIR}" "clean")
660+
set(run_clean "$(MAKE)" "-C" "${prefix}" "clean")
660661
else()
661-
set(run_clean ${CMAKE_COMMAND} --build ${BINARY_DIR} --target clean
662+
set(run_clean ${CMAKE_COMMAND} --build ${prefix} --target clean
662663
--config "$<CONFIG>")
663664
endif()
664665

@@ -667,7 +668,7 @@ macro(add_custom_libcxx name prefix)
667668
COMMENT "Cleaning ${name}..."
668669
DEPENDEES configure
669670
${force_deps}
670-
WORKING_DIRECTORY ${BINARY_DIR}
671+
WORKING_DIRECTORY ${prefix}
671672
EXCLUDE_FROM_MAIN 1
672673
USES_TERMINAL 1
673674
)

compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt

Lines changed: 0 additions & 31 deletions
This file was deleted.

compiler-rt/lib/fuzzer/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ if(OS_NAME MATCHES "Linux|Fuchsia" AND
162162
CMAKE_ARGS -DCMAKE_CXX_COMPILER_WORKS=ON
163163
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
164164
-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF
165-
-DLIBCXX_ABI_NAMESPACE=__Fuzzer)
165+
-DLIBCXX_ABI_NAMESPACE=__Fuzzer
166+
-DLIBCXX_ENABLE_EXCEPTIONS=OFF)
166167
target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
167168
add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-build)
168169
target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ set(MSAN_UNITTEST_INSTRUMENTED_CFLAGS
5252
-mllvm -msan-keep-going=1
5353
)
5454
set(MSAN_UNITTEST_LINK_FLAGS
55+
-nostdlib++
5556
${COMPILER_RT_UNITTEST_LINK_FLAGS}
5657
-fsanitize=memory
5758
# Don't need -stdlib=libc++ because we explicitly list libc++.a in the linker

0 commit comments

Comments
 (0)