[PATCH] D58331: [compiler-rt] Passthrough RUNTIMES_BUILD to the custom libc++ build

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 17 15:12:37 PST 2019


phosek updated this revision to Diff 187177.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58331/new/

https://reviews.llvm.org/D58331

Files:
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt


Index: compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
===================================================================
--- compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
+++ compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
@@ -1,5 +1,24 @@
 cmake_minimum_required(VERSION 3.4.3)
 
+# TODO: We shouldn't need a working C++ library, we're building C++ library
+# using this file after all. However, libc++abi and libc++ in standalone mode
+# include LLVM's HandleLLVMOptions which checks whether the compiler support
+# C++ using check_cxx_compiler_flag which tries to link C++ library and that
+# breaks C++ library hasn't been built yet (e.g. in the runtimes build where
+# C++ library is being built using the just built compiler).
+#
+# We need to prevent CMake from trying to use the C++ library. One way to do
+# that is by using -nostdlib and then only including -lc plus runtimes which
+# requires handling runtimes compiler-rt builtins and libgcc which adds another
+# layer of complexity. We could use -nostdlib++ but that flag is only supported
+# by newer Clang versions.
+#
+# For now, we pass the RUNTIMES_BUILD option through to detect whether we're
+# performing the runtimes build, and if so we use the -nostdlib++ flag.
+if (RUNTIMES_BUILD)
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
+endif()
+
 # Build static libcxxabi.
 set(LIBCXXABI_STANDALONE_BUILD 1)
 set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -600,6 +600,7 @@
                -DLLVM_LIBRARY_OUTPUT_INTDIR=${prefix}/lib
                -DCOMPILER_RT_LIBCXX_PATH=${COMPILER_RT_LIBCXX_PATH}
                -DCOMPILER_RT_LIBCXXABI_PATH=${COMPILER_RT_LIBCXXABI_PATH}
+               -DRUNTIMES_BUILD=${RUNTIMES_BUILD}
                ${LIBCXX_CMAKE_ARGS}
     INSTALL_COMMAND ""
     STEP_TARGETS configure build


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58331.187177.patch
Type: text/x-patch
Size: 2057 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190217/05319c7e/attachment.bin>


More information about the llvm-commits mailing list