[llvm] [cmake] Serialize native builds for Make generator (PR #121021)
Shoaib Meenai via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 13:55:28 PST 2025
================
@@ -2,14 +2,18 @@ include(ExternalProject)
# llvm_ExternalProject_BuildCmd(out_var target)
# Utility function for constructing command lines for external project targets
-function(llvm_ExternalProject_BuildCmd out_var target bin_dir)
+function(llvm_ExternalProject_BuildCmd out_var target bin_dir stamp_dir)
cmake_parse_arguments(ARG "" "CONFIGURATION" "" ${ARGN})
if(NOT ARG_CONFIGURATION)
set(ARG_CONFIGURATION "$<CONFIG>")
endif()
if (CMAKE_GENERATOR MATCHES "Make")
# Use special command for Makefiles to support parallelism.
- set(${out_var} "$(MAKE)" "-C" "${bin_dir}" "${target}" PARENT_SCOPE)
+ set(make_cmd "$(MAKE)" "-C" "${bin_dir}" "${target}")
+ set(file_lock_script "${LLVM_CMAKE_DIR}/FileLock.cmake")
+ set(${out_var} ${CMAKE_COMMAND} "-DLOCK_FILE_PATH=${stamp_dir}/cmake.lock"
+ "-DCOMMAND='${make_cmd}'"
----------------
smeenai wrote:
We might be better off using something like `|` instead of a semicolon-separated list when constructing `make_cmd` above; and then replacing `|` with `;` inside FileLock.cmake. Using `\;` or `$<SEMICOLON>` (since all places this will be used support generator expressions) would also work. You can then remove the `separate_arguments` inside FileLock.cmake and have things still work correctly for paths with spaces.
The single quotes here will also likely cause issues on Windows; you can use `\"` instead so that the command ends up with double quotes instead.
https://github.com/llvm/llvm-project/pull/121021
More information about the llvm-commits
mailing list