[compiler-rt] [CompilerRT] Apply CMake INTDIR substitution for Ninja Multi-Config build (PR #87918)

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


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

On Ninja Multi-Config mode configuration, CompilerRT generates its output to a weird directory, such as
`${CONFIGURATION}/lib/clang/19/lib/x86_64-pc-linux-gnu/libclang_rt.builtins.a`
which contains unexpanded `${CONFIGURATION}` as a directory name.
That causes a build error around syms-stamp on my environment.

After this patch applied, `${CONFIGURATION}` will be expanded to corresponding build configs such as Debug, Release, and RelWithDebInfo.
We can see similar expansion in [AddLLVM.cmake](https://github.com/llvm/llvm-project/blob/7a4e89761a13bfad27a2614ecea5e8698f50336c/llvm/cmake/modules/AddLLVM.cmake#L359).

>From 7f6fc58bc78393dc32973c9eface14d4210be110 Mon Sep 17 00:00:00 2001
From: tzik <mail at tzik.jp>
Date: Sun, 7 Apr 2024 15:05:33 +0900
Subject: [PATCH] [CompilerRT] Apply CMake INTDIR substitution for Ninja
 Multi-Config build

On Ninja Multi-Config mode configuration of CMake, CompilerRT used to generate
a directory that contains unexpanded ${CONFIGURATION}.
After this change, the variable is expanded for each configuration types.
---
 compiler-rt/cmake/Modules/AddCompilerRT.cmake | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index e0400a8ea95222..0038cfb9153e7b 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -16,11 +16,12 @@ function(set_target_output_directories target output_dir)
   # RUNTIME_OUTPUT_DIRECTORY_DEBUG, RUNTIME_OUTPUT_DIRECTORY_RELEASE, ...
   if(CMAKE_CONFIGURATION_TYPES)
     foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
+      string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} out ${output_dir})
       string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
       set_target_properties("${target}" PROPERTIES
-          "ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${output_dir}
-          "LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${output_dir}
-          "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${output_dir})
+          "ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${out}
+          "LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${out}
+          "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${out})
     endforeach()
   else()
     set_target_properties("${target}" PROPERTIES



More information about the llvm-commits mailing list