[libclc] effb2f1 - [libclc] Use a response file when building on Windows (#89756)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 24 02:11:30 PDT 2024


Author: Fraser Cormack
Date: 2024-04-24T10:11:26+01:00
New Revision: effb2f1917f11b58262d0e13aa085303b5896852

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

LOG: [libclc] Use a response file when building on Windows (#89756)

We've recently seen the libclc llvm-link invocations become so long that
they exceed the character limits on certain platforms.

Using a 'response file' should solve this by offloading the list of
inputs into a separate file, and using special syntax to pass it to
llvm-link. Note that neither the response file nor syntax aren't
specific to Windows but we restrict it to that platform regardless. We
have the option of expanding it to other platforms in the future.

Added: 
    

Modified: 
    libclc/cmake/modules/AddLibclc.cmake

Removed: 
    


################################################################################
diff  --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index bbedc244a72899..7f4620fa6a21df 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -88,10 +88,25 @@ function(link_bc)
     ${ARGN}
   )
 
+  set( LINK_INPUT_ARG ${ARG_INPUTS} )
+  if( WIN32 OR CYGWIN )
+    # Create a response file in case the number of inputs exceeds command-line
+    # character limits on certain platforms.
+    file( TO_CMAKE_PATH ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.rsp RSP_FILE )
+    # Turn it into a space-separate list of input files
+    list( JOIN ARG_INPUTS " " RSP_INPUT )
+    file( WRITE ${RSP_FILE} ${RSP_INPUT} )
+    # Ensure that if this file is removed, we re-run CMake
+    set_property( DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
+      ${RSP_FILE}
+    )
+    set( LINK_INPUT_ARG "@${RSP_FILE}" )
+  endif()
+
   add_custom_command(
     OUTPUT ${ARG_TARGET}.bc
-    COMMAND libclc::llvm-link -o ${ARG_TARGET}.bc ${ARG_INPUTS}
-    DEPENDS libclc::llvm-link ${ARG_INPUTS}
+    COMMAND libclc::llvm-link -o ${ARG_TARGET}.bc ${LINK_INPUT_ARG}
+    DEPENDS libclc::llvm-link ${ARG_INPUTS} ${RSP_FILE}
   )
 
   add_custom_target( ${ARG_TARGET} ALL DEPENDS ${ARG_TARGET}.bc )


        


More information about the cfe-commits mailing list