diff options
author | Fraser Cormack <fraser@codeplay.com> | 2024-04-24 10:11:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 10:11:26 +0100 |
commit | effb2f1917f11b58262d0e13aa085303b5896852 (patch) | |
tree | 7cee151508e7829ed8106642e46430ef80586b24 /libclc | |
parent | e400e908b2d97529b1a65dd0bdad80d481c39527 (diff) | |
download | llvm-effb2f1917f11b58262d0e13aa085303b5896852.zip llvm-effb2f1917f11b58262d0e13aa085303b5896852.tar.gz llvm-effb2f1917f11b58262d0e13aa085303b5896852.tar.bz2 |
[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.
Diffstat (limited to 'libclc')
-rw-r--r-- | libclc/cmake/modules/AddLibclc.cmake | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index bbedc24..7f4620f 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 ) |