[libclc] [libclc] Fix libclc install on Windows when MSVC generator is used (PR #152703)
Wenju He via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 10 18:28:38 PDT 2025
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/152703
>From be71d635d2de980797be595c4f35f307c703bc96 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Fri, 8 Aug 2025 05:59:54 -0700
Subject: [PATCH 1/3] [libclc] Fix libclc install on Windows when MSVC
generator is used
Fix a regression of df7473673214.
cmake MSVC generator is multiple configurations. Build type is not known
at configure time and CMAKE_CFG_INTDIR is evaluated to $(Configuration)
at configure time. libclc install fails since $(Configuration) in bitcode
file path is unresolved in libclc/cmake_install.cmake at install time.
We need a solution that resolves libclc bitcode file path at install
time. This PR fixes the issue using CMAKE_INSTALL_CONFIG_NAME which can
be evaluated at install time. This is the same solution as in
https://reviews.llvm.org/D76827
---
libclc/cmake/modules/AddLibclc.cmake | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 91d49610eee01..892d151977f83 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -425,8 +425,14 @@ function(add_libclc_builtin_set)
# targets dependent on libclc.
add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} )
+ if( NOT CMAKE_CFG_INTDIR STREQUAL "." )
+ string( REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}"
+ libclc_builtins_lib_install ${libclc_builtins_lib} )
+ else()
+ set( libclc_builtins_lib_install ${libclc_builtins_lib} )
+ endif()
install(
- FILES ${libclc_builtins_lib}
+ FILES ${libclc_builtins_lib_install}
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
)
>From 26de657925c40fa5072aa4e549e395bad52eefd5 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Fri, 8 Aug 2025 07:02:59 -0700
Subject: [PATCH 2/3] remove a space
---
libclc/cmake/modules/AddLibclc.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 892d151977f83..5a068c8e34a5f 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -425,7 +425,7 @@ function(add_libclc_builtin_set)
# targets dependent on libclc.
add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} )
- if( NOT CMAKE_CFG_INTDIR STREQUAL "." )
+ if( NOT CMAKE_CFG_INTDIR STREQUAL "." )
string( REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}"
libclc_builtins_lib_install ${libclc_builtins_lib} )
else()
>From b6cbefcbc06e42d7107723cb5b37749f3b1e0931 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Sun, 10 Aug 2025 18:00:34 -0700
Subject: [PATCH 3/3] fix alias install as well
---
libclc/cmake/modules/AddLibclc.cmake | 43 +++++++++++++++++++---------
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 5a068c8e34a5f..89d5e1dd6f164 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -199,6 +199,33 @@ function(get_libclc_device_info)
endif()
endfunction()
+# Install libclc artifacts.
+#
+# Arguments:
+# * FILES <string> ...
+# List of libclc artifact files to be installed.
+function(libclc_install)
+ cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
+
+ if( NOT ARG_FILES )
+ message( FATAL_ERROR "Must provide FILES" )
+ endif()
+
+ if( NOT CMAKE_CFG_INTDIR STREQUAL "." )
+ # Replace CMAKE_CFG_INTDIR with CMAKE_INSTALL_CONFIG_NAME for multiple-
+ # configuration generators.
+ string( REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}"
+ files ${ARG_FILES} )
+ else()
+ set( files ${ARG_FILES} )
+ endif()
+
+ install(
+ FILES ${files}
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
+ )
+endfunction()
+
# Compiles a list of library source files (provided by LIB_FILES/GEN_FILES) and
# compiles them to LLVM bytecode (or SPIR-V), links them together and optimizes
# them.
@@ -425,16 +452,7 @@ function(add_libclc_builtin_set)
# targets dependent on libclc.
add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} )
- if( NOT CMAKE_CFG_INTDIR STREQUAL "." )
- string( REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}"
- libclc_builtins_lib_install ${libclc_builtins_lib} )
- else()
- set( libclc_builtins_lib_install ${libclc_builtins_lib} )
- endif()
- install(
- FILES ${libclc_builtins_lib_install}
- DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
- )
+ libclc_install(FILES ${libclc_builtins_lib})
# SPIR-V targets can exit early here
if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
@@ -476,10 +494,7 @@ function(add_libclc_builtin_set)
set_target_properties( alias-${alias_suffix}
PROPERTIES FOLDER "libclc/Device IR/Aliases"
)
- install(
- FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
- DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
- )
+ libclc_install(FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix})
endforeach( a )
endfunction(add_libclc_builtin_set)
More information about the cfe-commits
mailing list