Browse Source

Fixed some bugs in LTO builds

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
f2261faee7
3 changed files with 24 additions and 8 deletions
  1. +18
    -8
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h
  2. +3
    -0
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_CodeBlocks.h
  3. +3
    -0
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Make.h

+ 18
- 8
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h View File

@@ -376,11 +376,6 @@ protected:
{
return "${ANDROID_ABI}";
}
String getLinkerFlagsString() const
{
return String ("\"-DCMAKE_EXE_LINKER_FLAGS_") + (isDebug() ? "DEBUG" : "RELEASE") + "=-flto\"";
}
};
BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
@@ -476,6 +471,22 @@ private:
mo << newLine;
}
if (cfg.isLinkTimeOptimisationEnabled())
{
// There's no MIPS support for LTO
String mipsCondition ("NOT (ANDROID_ABI STREQUAL \"mips\" OR ANDROID_ABI STREQUAL \"mips64\")");
mo << " if(" << mipsCondition << ")" << newLine;
StringArray cmakeVariables ("CMAKE_C_FLAGS", "CMAKE_CXX_FLAGS", "CMAKE_EXE_LINKER_FLAGS");
for (auto& variable : cmakeVariables)
{
auto configVariable = variable + "_" + cfg.getProductFlavourCMakeIdentifier();
mo << " SET(" << configVariable << " \"${" << configVariable << "} -flto\")" << newLine;
}
mo << " ENDIF(" << mipsCondition << ")" << newLine;
}
first = false;
}
@@ -633,9 +644,8 @@ private:
<< ", \"-DCMAKE_CXX_FLAGS_" << (cfg.isDebug() ? "DEBUG" : "RELEASE")
<< "=-O" << cfg.getGCCOptimisationFlag() << "\""
<< ", \"-DCMAKE_C_FLAGS_" << (cfg.isDebug() ? "DEBUG" : "RELEASE")
<< "=-O" << cfg.getGCCOptimisationFlag() << "\""
<< (cfg.isLinkTimeOptimisationEnabled() ? ", " + cfg.getLinkerFlagsString() : "")
<< newLine;
<< "=-O" << cfg.getGCCOptimisationFlag() << "\"" << newLine;
mo << " }" << newLine;
mo << " }" << newLine << newLine;
mo << " dimension \"default\"" << newLine;


+ 3
- 0
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_CodeBlocks.h View File

@@ -481,6 +481,9 @@ private:
if (! config.isDebug())
flags.add ("-s");
if (config.isLinkTimeOptimisationEnabled())
flags.add ("-flto");
flags.addTokens (replacePreprocessorTokens (config, getExtraLinkerFlagsString()).trim(), " \n", "\"'");
const auto packages = getPackages();


+ 3
- 0
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Make.h View File

@@ -585,6 +585,9 @@ private:
if (! config.isDebug())
result.add ("-fvisibility=hidden");
if (config.isLinkTimeOptimisationEnabled())
result.add ("-flto");
auto extraFlags = getExtraLinkerFlagsString().trim();
if (extraFlags.isNotEmpty())


Loading…
Cancel
Save