Skip to content

Commit 89fec21

Browse files
authored
Fix calls to add_custom_target_command (#63740)
`add_custom_target_command` has a note in its documentation that ask for all the `COMMAND` arguments to immediately follow the first argument, or the function will misbehave. In the two cases below, the `COMMAND` arguments were after the `OUTPUT` multivalue, and ended by mistake inside the `OUTPUT` parameter. This kinda works because CMake will interpolate those back, but causes problems for dependency resolution, marking many targets as dirty. When one of those targets is dependent by the compiler, this can create a huge cascade rebuild. Fix the two cases I found where `add_custom_target_command` was used incorrectly. This removes cascade rebuilds in my working directory, and hope it applies to everybody.
1 parent 16af937 commit 89fec21

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,21 @@ function(add_swift_compiler_modules_library name)
176176
endforeach()
177177

178178
# Compile the module into an object file
179-
add_custom_command_target(dep_target OUTPUT ${module_obj_file}
179+
add_custom_command_target(dep_target
180+
COMMAND ${ALS_SWIFT_EXEC} "-c" "-o" ${module_obj_file}
181+
${sdk_option}
182+
"-target" ${target}
183+
"-module-name" ${module} "-emit-module"
184+
"-emit-module-path" "${build_dir}/${module}.swiftmodule"
185+
"-parse-as-library" ${sources}
186+
"-wmo" ${swift_compile_options}
187+
${c_include_paths_args}
188+
# Generated swift modules.
189+
"-I" "${build_dir}"
190+
OUTPUT ${module_obj_file}
180191
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
181192
DEPENDS ${sources} ${deps} ${ALS_DEPENDS}
182193
importedHeaderDependencies
183-
COMMAND ${ALS_SWIFT_EXEC} "-c" "-o" ${module_obj_file}
184-
${sdk_option}
185-
"-target" ${target}
186-
"-module-name" ${module} "-emit-module"
187-
"-emit-module-path" "${build_dir}/${module}.swiftmodule"
188-
"-parse-as-library" ${sources}
189-
"-wmo" ${swift_compile_options}
190-
${c_include_paths_args}
191-
# Generated swift modules.
192-
"-I" "${build_dir}"
193194
COMMENT "Building swift module ${module}")
194195

195196
set("${module}_dep_target" ${dep_target})

tools/swift-compatibility-symbols/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ add_swift_host_tool(swift-compatibility-symbols
77
set(syms_file "${CMAKE_BINARY_DIR}/share/swift/compatibility-symbols")
88

99
add_custom_command_target(copy_compat_target
10-
OUTPUT
11-
${syms_file}
1210
COMMAND
1311
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swift-compatibility-symbols"
14-
--output-filename ${syms_file}
12+
--output-filename ${syms_file}
13+
OUTPUT
14+
${syms_file}
1515
DEPENDS
1616
swift-compatibility-symbols
1717
)

0 commit comments

Comments
 (0)