From 9c29a72fbc6f52f9e2ac558811b74490355329d3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 15 Oct 2008 10:21:21 -0400 Subject: [PATCH] ENH: Support object lists longer than 128K on MSVC We use response files to list object files for the MSVC linker. The linker complains if any response file is greater than 128K, so we split the object file lists into multiple response files. --- Source/cmMakefileTargetGenerator.cxx | 37 ++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b25ae6064..41e3612dc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1634,14 +1634,35 @@ cmMakefileTargetGenerator this->WriteObjectsVariable(variableName, variableNameExternal); if(useResponseFile) { - std::string objects; - this->WriteObjectsString(objects); - std::string objects_rsp = - this->CreateResponseFile("objects.rsp", objects, makefile_depends); - buildObjs = "@"; - buildObjs += this->Convert(objects_rsp.c_str(), - cmLocalGenerator::NONE, - cmLocalGenerator::SHELL); + // MSVC response files cannot exceed 128K. + std::string::size_type const responseFileLimit = 131000; + + // Construct the individual object list strings. + std::vector object_strings; + this->WriteObjectsStrings(object_strings, responseFileLimit); + + // Write a response file for each string. + const char* sep = ""; + for(unsigned int i = 0; i < object_strings.size(); ++i) + { + // Number the response files. + char rsp[32]; + sprintf(rsp, "objects%u.rsp", i+1); + + // Create this response file. + std::string objects_rsp = + this->CreateResponseFile(rsp, object_strings[i], makefile_depends); + + // Separate from previous response file references. + buildObjs += sep; + sep = " "; + + // Reference the response file. + buildObjs += "@"; + buildObjs += this->Convert(objects_rsp.c_str(), + cmLocalGenerator::NONE, + cmLocalGenerator::SHELL); + } } else if(useLinkScript) {