qmake/msbuild: Support all /LTCG:xxx options

/LTCG:OFF now turns off LTCG.
/LTCG:INCREMENTAL maps to UseFastLinkTimeCodeGeneration.
Unknown /LTCG:xxx values are passed to AdditionalOptions.

Pick-to: 5.15 6.2 6.3 6.4
Task-number: QTBUG-104450
Change-Id: If85942dbeec204dc2571a861a43201cb3d5993ae
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2022-06-21 13:57:38 +02:00
parent 73e1bc09e6
commit 566ede6ee1
3 changed files with 24 additions and 17 deletions

View File

@ -1064,6 +1064,8 @@ static inline QString toString(optLinkTimeCodeGenType option)
break; break;
case optLTCGEnabled: case optLTCGEnabled:
return "UseLinkTimeCodeGeneration"; return "UseLinkTimeCodeGeneration";
case optLTCGIncremental:
return "UseFastLinkTimeCodeGeneration";
case optLTCGInstrument: case optLTCGInstrument:
return "PGInstrument"; return "PGInstrument";
case optLTCGOptimize: case optLTCGOptimize:

View File

@ -1567,24 +1567,28 @@ bool VCLinkerTool::parseOption(const char* option)
case 0x0d745c8: // /LIBPATH:dir case 0x0d745c8: // /LIBPATH:dir
AdditionalLibraryDirectories += option+9; AdditionalLibraryDirectories += option+9;
break; break;
case 0x0341877: // /LTCG[:NOSTATUS|:STATUS] case 0x0341877: // /LTCG[:{INCREMENTAL|NOSTATUS|STATUS|OFF}]
config->WholeProgramOptimization = _True; // /LTCG:{PGINSTRUMENT|PGOPTIMIZE|PGUPDATE}
if (config->CompilerVersion >= NET2005) {
LinkTimeCodeGeneration = optLTCGEnabled; LinkTimeCodeGeneration = optLTCGEnabled;
if(*(option+5) == ':') { if (*(option + 5) == ':') {
const char* str = option+6; const char* str = option + 6;
if (*str == 'S') if (qstricmp(str, "status") == 0)
ShowProgress = linkProgressAll; ShowProgress = linkProgressAll;
else if (qstricmp(str, "off") == 0)
LinkTimeCodeGeneration = optLTCGDefault;
else if (qstricmp(str, "incremental") == 0)
LinkTimeCodeGeneration = optLTCGIncremental;
else if (qstricmp(str, "pginstrument") == 0) else if (qstricmp(str, "pginstrument") == 0)
LinkTimeCodeGeneration = optLTCGInstrument; LinkTimeCodeGeneration = optLTCGInstrument;
else if (qstricmp(str, "pgoptimize") == 0) else if (qstricmp(str, "pgoptimize") == 0)
LinkTimeCodeGeneration = optLTCGOptimize; LinkTimeCodeGeneration = optLTCGOptimize;
else if (qstricmp(str, "pgupdate") == 0) else if (qstricmp(str, "pgupdate") == 0)
LinkTimeCodeGeneration = optLTCGUpdate; LinkTimeCodeGeneration = optLTCGUpdate;
} else
} else {
AdditionalOptions.append(option); AdditionalOptions.append(option);
} }
if (LinkTimeCodeGeneration != optLTCGDefault)
config->WholeProgramOptimization = _True;
break; break;
case 0x379ED25: case 0x379ED25:
case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE} case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE}

View File

@ -331,6 +331,7 @@ enum optWin98Type {
enum optLinkTimeCodeGenType { enum optLinkTimeCodeGenType {
optLTCGDefault, optLTCGDefault,
optLTCGEnabled, optLTCGEnabled,
optLTCGIncremental,
optLTCGInstrument, optLTCGInstrument,
optLTCGOptimize, optLTCGOptimize,
optLTCGUpdate optLTCGUpdate