ENH: Enable use of link script whenever incremental archive construction rules are available. Enable use of archive construction rules on MSYS.
This commit is contained in:
parent
66e0b4212f
commit
52b3f85642
|
@ -50,6 +50,7 @@ cmLocalGenerator::cmLocalGenerator()
|
||||||
this->MinGWMake = false;
|
this->MinGWMake = false;
|
||||||
this->NMake = false;
|
this->NMake = false;
|
||||||
this->MSYSShell = false;
|
this->MSYSShell = false;
|
||||||
|
this->LinkScriptShell = false;
|
||||||
this->IgnoreLibPrefix = false;
|
this->IgnoreLibPrefix = false;
|
||||||
this->UseRelativePaths = false;
|
this->UseRelativePaths = false;
|
||||||
this->Configured = false;
|
this->Configured = false;
|
||||||
|
@ -1995,7 +1996,7 @@ std::string cmLocalGenerator::Convert(const char* source,
|
||||||
// For the MSYS shell convert drive letters to posix paths, so
|
// For the MSYS shell convert drive letters to posix paths, so
|
||||||
// that c:/some/path becomes /c/some/path. This is needed to
|
// that c:/some/path becomes /c/some/path. This is needed to
|
||||||
// avoid problems with the shell path translation.
|
// avoid problems with the shell path translation.
|
||||||
if(this->MSYSShell)
|
if(this->MSYSShell && !this->LinkScriptShell)
|
||||||
{
|
{
|
||||||
if(result.size() > 2 && result[1] == ':')
|
if(result.size() > 2 && result[1] == ':')
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,6 +210,9 @@ public:
|
||||||
const char* Defines;
|
const char* Defines;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Set whether to treat conversions to SHELL as a link script shell. */
|
||||||
|
void SetLinkScriptShell(bool b) { this->LinkScriptShell = b; }
|
||||||
|
|
||||||
/** Escape the given string to be used as a command line argument in
|
/** Escape the given string to be used as a command line argument in
|
||||||
the native build system shell. Optionally allow the build
|
the native build system shell. Optionally allow the build
|
||||||
system to replace make variable references. Optionally adjust
|
system to replace make variable references. Optionally adjust
|
||||||
|
@ -346,6 +349,7 @@ protected:
|
||||||
bool NMake;
|
bool NMake;
|
||||||
bool ForceUnixPath;
|
bool ForceUnixPath;
|
||||||
bool MSYSShell;
|
bool MSYSShell;
|
||||||
|
bool LinkScriptShell;
|
||||||
bool UseRelativePaths;
|
bool UseRelativePaths;
|
||||||
bool IgnoreLibPrefix;
|
bool IgnoreLibPrefix;
|
||||||
bool Configured;
|
bool Configured;
|
||||||
|
|
|
@ -367,6 +367,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
||||||
|
|
||||||
// Expand the rule variables.
|
// Expand the rule variables.
|
||||||
{
|
{
|
||||||
|
// Set path conversion for link script shells.
|
||||||
|
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
|
||||||
|
|
||||||
// Collect up flags to link in needed libraries.
|
// Collect up flags to link in needed libraries.
|
||||||
cmOStringStream linklibs;
|
cmOStringStream linklibs;
|
||||||
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink);
|
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink);
|
||||||
|
@ -428,6 +431,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
||||||
this->LocalGenerator->ExpandRuleVariables(*i, vars);
|
this->LocalGenerator->ExpandRuleVariables(*i, vars);
|
||||||
}
|
}
|
||||||
this->LocalGenerator->TargetImplib = "";
|
this->LocalGenerator->TargetImplib = "";
|
||||||
|
|
||||||
|
// Restore path conversion to normal shells.
|
||||||
|
this->LocalGenerator->SetLinkScriptShell(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optionally convert the build rule to use a script to avoid long
|
// Optionally convert the build rule to use a script to avoid long
|
||||||
|
|
|
@ -673,7 +673,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
||||||
std::vector<std::string> archiveAppendCommands;
|
std::vector<std::string> archiveAppendCommands;
|
||||||
std::vector<std::string> archiveFinishCommands;
|
std::vector<std::string> archiveFinishCommands;
|
||||||
std::string::size_type archiveCommandLimit = std::string::npos;
|
std::string::size_type archiveCommandLimit = std::string::npos;
|
||||||
if(useLinkScript && this->Target->GetType() == cmTarget::STATIC_LIBRARY)
|
if(this->Target->GetType() == cmTarget::STATIC_LIBRARY)
|
||||||
{
|
{
|
||||||
std::string arCreateVar = "CMAKE_";
|
std::string arCreateVar = "CMAKE_";
|
||||||
arCreateVar += linkLanguage;
|
arCreateVar += linkLanguage;
|
||||||
|
@ -696,18 +696,28 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
||||||
{
|
{
|
||||||
cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
|
cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decide whether to use archiving rules.
|
||||||
|
bool useArchiveRules =
|
||||||
|
!archiveCreateCommands.empty() && !archiveAppendCommands.empty();
|
||||||
|
if(useArchiveRules)
|
||||||
|
{
|
||||||
|
// Archiving rules are always run with a link script.
|
||||||
|
useLinkScript = true;
|
||||||
|
|
||||||
// Limit the length of individual object lists to less than the
|
// Limit the length of individual object lists to less than the
|
||||||
// 32K command line length limit on Windows. We could make this a
|
// 32K command line length limit on Windows. We could make this a
|
||||||
// platform file variable but this should work everywhere.
|
// platform file variable but this should work everywhere.
|
||||||
archiveCommandLimit = 30000;
|
archiveCommandLimit = 30000;
|
||||||
}
|
}
|
||||||
bool useArchiveRules =
|
|
||||||
!archiveCreateCommands.empty() && !archiveAppendCommands.empty();
|
|
||||||
|
|
||||||
// Expand the rule variables.
|
// Expand the rule variables.
|
||||||
std::vector<std::string> real_link_commands;
|
std::vector<std::string> real_link_commands;
|
||||||
{
|
{
|
||||||
|
// Set path conversion for link script shells.
|
||||||
|
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
|
||||||
|
|
||||||
// Collect up flags to link in needed libraries.
|
// Collect up flags to link in needed libraries.
|
||||||
cmOStringStream linklibs;
|
cmOStringStream linklibs;
|
||||||
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink);
|
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink);
|
||||||
|
@ -864,6 +874,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->LocalGenerator->TargetImplib = "";
|
this->LocalGenerator->TargetImplib = "";
|
||||||
|
|
||||||
|
// Restore path conversion to normal shells.
|
||||||
|
this->LocalGenerator->SetLinkScriptShell(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optionally convert the build rule to use a script to avoid long
|
// Optionally convert the build rule to use a script to avoid long
|
||||||
|
|
Loading…
Reference in New Issue