This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, next has been updated via 41da93010df18cb1ecec68c9334305d1bdfb77f6 (commit) via c7a7c655f0433c7ca4ea6ec5ce78b7f17cbf5140 (commit) via 34ba5c53481e7f2101dafa735504cb98f94ec6db (commit) from 927ab805e5a07d266b272e56af52835f52f2c64f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=41da93010df18cb1ecec68c9334305d1bdfb77f6 commit 41da93010df18cb1ecec68c9334305d1bdfb77f6 Merge: 927ab80 c7a7c65 Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed Jul 20 15:18:13 2016 -0400 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Wed Jul 20 15:18:13 2016 -0400 Merge topic 'makefile-response-files' into next c7a7c655 Makefile: Avoid link line object list lengths nearing system limits 34ba5c53 Makefile: Factor out response file checks into common helper https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c7a7c655f0433c7ca4ea6ec5ce78b7f17cbf5140 commit c7a7c655f0433c7ca4ea6ec5ce78b7f17cbf5140 Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed Jul 20 14:57:18 2016 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Wed Jul 20 15:09:42 2016 -0400 Makefile: Avoid link line object list lengths nearing system limits Use response files for object file lists that approach the scale of the system `ARG_MAX` limit. Fixes #16206. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index abf50d6..e12fc09 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -31,6 +31,10 @@ #include <ctype.h> +#ifndef _WIN32 +#include <unistd.h> +#endif + cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) : cmCommonTargetGenerator(target) , OSXBundleGenerator(CM_NULLPTR) @@ -1447,6 +1451,15 @@ void cmMakefileTargetGenerator::CreateLinkScript( makefile_depends.push_back(linkScriptName); } +static size_t calculateCommandLineLengthLimit() +{ +#if defined(_SC_ARG_MAX) + return ((size_t)sysconf(_SC_ARG_MAX)) - 1000; +#else + return 0; +#endif +} + bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( std::string const& l) const { @@ -1459,6 +1472,32 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( } } + // Check for a system limit. + if (size_t const limit = calculateCommandLineLengthLimit()) { + // Compute the total length of our list of object files with room + // for argument separation and quoting. This does not convert paths + // relative to START_OUTPUT like the final list will be, so the actual + // list will likely be much shorter than this. However, in the worst + // case all objects will remain as absolute paths. + size_t length = 0; + for (std::vector<std::string>::const_iterator i = this->Objects.begin(); + i != this->Objects.end(); ++i) { + length += i->size() + 3; + } + for (std::vector<std::string>::const_iterator i = + this->ExternalObjects.begin(); + i != this->ExternalObjects.end(); ++i) { + length += i->size() + 3; + } + + // We need to guarantee room for both objects and libraries, so + // if the objects take up more than half then use a response file + // for them. + if (length > (limit / 2)) { + return true; + } + } + // We do not need a response file for objects. return false; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=34ba5c53481e7f2101dafa735504cb98f94ec6db commit 34ba5c53481e7f2101dafa735504cb98f94ec6db Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed Jul 20 14:39:38 2016 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Wed Jul 20 15:00:56 2016 -0400 Makefile: Factor out response file checks into common helper Factor CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_{OBJECTS,LIBRARIES} lookup out into a common helper. Use a separate helper for each because more specific logic may be added to each later. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 8730ccd..3b8bf5a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -277,27 +277,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } } - // Select whether to use a response file for objects. - bool useResponseFileForObjects = false; - { - std::string responseVar = "CMAKE_"; - responseVar += linkLanguage; - responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS"; - if (this->Makefile->IsOn(responseVar)) { - useResponseFileForObjects = true; - } - } - - // Select whether to use a response file for libraries. - bool useResponseFileForLibs = false; - { - std::string responseVar = "CMAKE_"; - responseVar += linkLanguage; - responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES"; - if (this->Makefile->IsOn(responseVar)) { - useResponseFileForLibs = true; - } - } + bool useResponseFileForObjects = + this->CheckUseResponseFileForObjects(linkLanguage); + bool const useResponseFileForLibs = + this->CheckUseResponseFileForLibraries(linkLanguage); // Expand the rule variables. { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7de2db0..68f8ff1 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -429,27 +429,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Determine whether a link script will be used. bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); - // Select whether to use a response file for objects. - bool useResponseFileForObjects = false; - { - std::string responseVar = "CMAKE_"; - responseVar += linkLanguage; - responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS"; - if (this->Makefile->IsOn(responseVar)) { - useResponseFileForObjects = true; - } - } - - // Select whether to use a response file for libraries. - bool useResponseFileForLibs = false; - { - std::string responseVar = "CMAKE_"; - responseVar += linkLanguage; - responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES"; - if (this->Makefile->IsOn(responseVar)) { - useResponseFileForLibs = true; - } - } + bool useResponseFileForObjects = + this->CheckUseResponseFileForObjects(linkLanguage); + bool const useResponseFileForLibs = + this->CheckUseResponseFileForLibraries(linkLanguage); // For static libraries there might be archiving rules. bool haveStaticLibraryRule = false; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 00b1219..abf50d6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1447,6 +1447,38 @@ void cmMakefileTargetGenerator::CreateLinkScript( makefile_depends.push_back(linkScriptName); } +bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( + std::string const& l) const +{ + // Check for an explicit setting one way or the other. + std::string const responseVar = + "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_OBJECTS"; + if (const char* val = this->Makefile->GetDefinition(responseVar)) { + if (*val) { + return cmSystemTools::IsOn(val); + } + } + + // We do not need a response file for objects. + return false; +} + +bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries( + std::string const& l) const +{ + // Check for an explicit setting one way or the other. + std::string const responseVar = + "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES"; + if (const char* val = this->Makefile->GetDefinition(responseVar)) { + if (*val) { + return cmSystemTools::IsOn(val); + } + } + + // We do not need a response file for libraries. + return false; +} + std::string cmMakefileTargetGenerator::CreateResponseFile( const char* name, std::string const& options, std::vector<std::string>& makefile_depends) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 4284549..29b8887 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -151,6 +151,9 @@ protected: std::string CreateResponseFile(const char* name, std::string const& options, std::vector<std::string>& makefile_depends); + bool CheckUseResponseFileForObjects(std::string const& l) const; + bool CheckUseResponseFileForLibraries(std::string const& l) const; + /** Create list of flags for link libraries. */ void CreateLinkLibs(std::string& linkLibs, bool relink, bool useResponseFile, std::vector<std::string>& makefile_depends, ----------------------------------------------------------------------- Summary of changes: Source/cmMakefileExecutableTargetGenerator.cxx | 25 ++------- Source/cmMakefileLibraryTargetGenerator.cxx | 25 ++------- Source/cmMakefileTargetGenerator.cxx | 71 ++++++++++++++++++++++++ Source/cmMakefileTargetGenerator.h | 3 + 4 files changed, 82 insertions(+), 42 deletions(-) hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/mailman/listinfo/cmake-commits