diff options
author | Brad King <brad.king@kitware.com> | 2024-01-12 13:52:57 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-01-12 13:53:10 (GMT) |
commit | e315d7cb19f019b91e68f7d3ca5720f294c70bab (patch) | |
tree | fa5d612980b8d0bdcdf7c4ba05b716f5701cf83d | |
parent | 8728fb1efcc202cd96d244324e11d1a348738482 (diff) | |
parent | b767917ebb2130f097b7190713605cef481803fa (diff) | |
download | CMake-e315d7cb19f019b91e68f7d3ca5720f294c70bab.zip CMake-e315d7cb19f019b91e68f7d3ca5720f294c70bab.tar.gz CMake-e315d7cb19f019b91e68f7d3ca5720f294c70bab.tar.bz2 |
Merge topic 'swift-sources-in-resp-file'
b767917ebb Swift/Ninja: Include sources in response file
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9143
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 10 | ||||
-rw-r--r-- | Source/cmPlaceholderExpander.cxx | 4 | ||||
-rw-r--r-- | Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt | 6 |
3 files changed, 14 insertions, 6 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index bc97e88..9bc292c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -848,6 +848,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, flags = cmStrCat(responseFlag, rule.RspFile); vars.Defines = ""; vars.Includes = ""; + + // Swift consumes all source files in a module at once, which reaches + // command line length limits pretty quickly. Inject source files into the + // response file in this case as well. + if (lang == "Swift") { + rule.RspContent = cmStrCat(rule.RspContent, ' ', vars.Source); + vars.Source = ""; + } } // Tell ninja dependency format so all deps can be loaded into a database @@ -1925,8 +1933,6 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement( // For that, we need the "NEW" behavior for CMP0157. Otherwise, we have to // fall back on the old "linker" build. Otherwise, this should be // indistinguishable from the old behavior. - // - // FIXME(#25490): Add response file support to Swift object build step if (sources.empty()) { return; diff --git a/Source/cmPlaceholderExpander.cxx b/Source/cmPlaceholderExpander.cxx index 118017e..11c7485 100644 --- a/Source/cmPlaceholderExpander.cxx +++ b/Source/cmPlaceholderExpander.cxx @@ -48,6 +48,10 @@ std::string& cmPlaceholderExpander::ExpandVariables(std::string& s) } // add the rest of the input expandedInput += s.substr(pos, s.size() - pos); + // remove trailing whitespace + if (!expandedInput.empty() && expandedInput.back() == ' ') { + expandedInput.pop_back(); + } s = expandedInput; return s; diff --git a/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt b/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt index 576f5a1..3d70f12 100644 --- a/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt +++ b/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt @@ -1,4 +1,2 @@ -swiftc [^ -]* -c @CMakeFiles/L.dir/L.o.swift.rsp [^ -]* -.*swiftc -emit-library -static -o libL.a @CMakeFiles/L.rsp.* +swiftc -j [0-9]+ -num-threads [0-9]+ -c @CMakeFiles/L.dir/L.o.swift.rsp +.*swiftc -emit-library -static -o libL.a @CMakeFiles/L.rsp |