[compiler-rt] [llvm] [cmake][CompilerRT] Propagate CMAKE_INSTALL_CONFIG_NAME to runtime installation (PR #87961)

Taiju Tsuiki via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 22:23:04 PDT 2024


https://github.com/tzik created https://github.com/llvm/llvm-project/pull/87961

LLVM runtimes hit a build failure on Ninja Multi-Config and non-Release configuration (i.e. Debug or RelWithDebInfo), due to missing build configuration.

When the install script runs without the parameter, it uses Release configuration as a fallback, searches the binary to install from Release directory, and fails for the missing binary.
After this PR, the top-level script propagates the build configuration to the sub-project, and should fix the build error.

>From 7c1516ac8e4beb087d8c96b66783d0a6672f0fc2 Mon Sep 17 00:00:00 2001
From: tzik <mail at tzik.jp>
Date: Mon, 8 Apr 2024 13:22:50 +0900
Subject: [PATCH] [cmake][CompilerRT] Propagate CMAKE_INSTALL_CONFIG_NAME to
 runtime installation

This fixes a build error happens around LLVM runtimes on Ninja Multi-Config
generator.
LLVM runtimes use llvm_ExternalProject_Add, and have its own installation
script. However, the top-level build file doesn't propagate the build
configuration (such as Debug, Release, or RelWithDebInfo) to the sub-projects.
And sub-projects used to use Release configuration as the fallback, and
that causes a build failure.
After this changes, the top-level install configuration should be passed to
the sub-project installation script.
---
 compiler-rt/cmake/Modules/CompilerRTUtils.cmake   | 2 ++
 llvm/cmake/modules/LLVMExternalProjectUtils.cmake | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index e8e5f612d5b03c..503a935bdde5b3 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -528,11 +528,13 @@ function(add_compiler_rt_install_targets name)
                       DEPENDS ${ARG_PARENT_TARGET}
                       COMMAND "${CMAKE_COMMAND}"
                               -DCMAKE_INSTALL_COMPONENT=${ARG_PARENT_TARGET}
+                              -DCMAKE_INSTALL_CONFIG_NAME=$<CONFIG>
                               -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
     add_custom_target(install-${ARG_PARENT_TARGET}-stripped
                       DEPENDS ${ARG_PARENT_TARGET}
                       COMMAND "${CMAKE_COMMAND}"
                               -DCMAKE_INSTALL_COMPONENT=${ARG_PARENT_TARGET}
+                              -DCMAKE_INSTALL_CONFIG_NAME=$<CONFIG>
                               -DCMAKE_INSTALL_DO_STRIP=1
                               -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
     set_target_properties(install-${ARG_PARENT_TARGET} PROPERTIES
diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 2672f90f579bd9..84410f1e53b145 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -384,7 +384,7 @@ function(llvm_ExternalProject_Add name source_dir)
   endif()
 
   if(NOT ARG_NO_INSTALL)
-    install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -DCMAKE_INSTALL_DO_STRIP=\${CMAKE_INSTALL_DO_STRIP} -P ${BINARY_DIR}/cmake_install.cmake\)"
+    install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -DCMAKE_INSTALL_DO_STRIP=\${CMAKE_INSTALL_DO_STRIP} -DCMAKE_INSTALL_CONFIG_NAME=$<CONFIG> -P ${BINARY_DIR}/cmake_install.cmake\)"
       COMPONENT ${name})
 
     add_llvm_install_targets(install-${name}



More information about the llvm-commits mailing list