[libcxx-commits] [libcxx] 05c552a - [libc++] Fix the runtimes build after making __config_site mandatory

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 25 22:27:30 PDT 2020


Author: Louis Dionne
Date: 2020-06-26T01:26:34-04:00
New Revision: 05c552ad0535f0f7c871bdd41aed02144e27afd7

URL: https://github.com/llvm/llvm-project/commit/05c552ad0535f0f7c871bdd41aed02144e27afd7
DIFF: https://github.com/llvm/llvm-project/commit/05c552ad0535f0f7c871bdd41aed02144e27afd7.diff

LOG: [libc++] Fix the runtimes build after making __config_site mandatory

The runtimes build includes libcxx/include/CMakeLists.txt directly instead
of going through the top-level CMake file. This not-very-hygienic inclusion
caused some variables like LIBCXX_BINARY_DIR not to be defined properly,
and the config_site generation logic to fail after landing 53623d4aa710.

This patch works around this issue by defining the missing variables.
However, the proper fix for this would be for the runtimes build to
always go through libc++'s top-level CMakeLists.txt. Doing otherwise
is unsupported.

Added: 
    

Modified: 
    libcxx/CMakeLists.txt
    libcxx/include/CMakeLists.txt
    llvm/runtimes/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index f884456b1d9e..2fdb9b370c4c 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -873,16 +873,13 @@ if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED)
   config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 endif()
 
-set(site_config_path "${LIBCXX_BINARY_DIR}/__config_site")
-configure_file("include/__config_site.in"
-               "${site_config_path}"
-               @ONLY)
-
+# We generate a __config_site header (see libcxx/include/CMakeLists.txt) and
+# we make sure to include it when building the library.
 function(cxx_add_config_site target)
   if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
-    target_compile_options(${target} PUBLIC /FI "${site_config_path}")
+    target_compile_options(${target} PUBLIC /FI "${LIBCXX_BINARY_DIR}/__config_site")
   else()
-    target_compile_options(${target} PUBLIC -include "${site_config_path}")
+    target_compile_options(${target} PUBLIC -include "${LIBCXX_BINARY_DIR}/__config_site")
   endif()
 endfunction()
 

diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index c913ef9eb771..707c23173c82 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -184,6 +184,10 @@ if(LIBCXX_INSTALL_SUPPORT_HEADERS)
     )
 endif()
 
+configure_file("__config_site.in"
+               "${LIBCXX_BINARY_DIR}/__config_site"
+               @ONLY)
+
 # Generate a custom __config header. The new header is created
 # by prepending __config_site to the current __config header.
 add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config

diff  --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index ea73cec050ee..d56f7af583ed 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -222,6 +222,8 @@ else() # if this is included from LLVM's CMake
   if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR AND "libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
     # This looks wrong, but libcxx's build actually wants the header dir to be
     # the root build dir, not the include directory.
+    set(LIBCXX_BINARY_DIR ${LLVM_BINARY_DIR})
+    set(LIBCXX_SOURCE_DIR ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR})
     set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR})
     set(CXX_HEADER_TARGET runtime-libcxx-headers)
     add_subdirectory(${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include ${CXX_HEADER_TARGET})


        


More information about the libcxx-commits mailing list