diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h index 613a647021..cd1c6f4a32 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h @@ -360,6 +360,11 @@ 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 @@ -595,7 +600,9 @@ private: << ", \"-DCMAKE_CXX_FLAGS_" << (cfg.isDebug() ? "DEBUG" : "RELEASE") << "=-O" << cfg.getGCCOptimisationFlag() << "\"" << ", \"-DCMAKE_C_FLAGS_" << (cfg.isDebug() ? "DEBUG" : "RELEASE") - << "=-O" << cfg.getGCCOptimisationFlag() << "\"" << newLine; + << "=-O" << cfg.getGCCOptimisationFlag() << "\"" + << (cfg.isLinkTimeOptimisationEnabled() ? ", " + cfg.getLinkerFlagsString() : "") + << newLine; mo << " }" << newLine; mo << " }" << newLine; mo << " }" << newLine; diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_CodeBlocks.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_CodeBlocks.h index a2c0ac84db..7ab7e693c7 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_CodeBlocks.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_CodeBlocks.h @@ -380,6 +380,9 @@ private: flags.add ("-O" + config.getGCCOptimisationFlag()); + if (config.isLinkTimeOptimisationEnabled()) + flags.add ("-flto"); + { auto cppStandard = config.project.getCppStandardValue().toString(); diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h index 0d45deec0c..4e50964f96 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h @@ -160,6 +160,9 @@ public: setValueIfVoid (shouldGenerateManifestValue(), true); setValueIfVoid (getArchitectureType(), get64BitArchName()); + + if (! isDebug()) + updateOldLTOSetting(); } Value getWarningLevelValue() { return getValue (Ids::winWarningLevel); } @@ -182,9 +185,6 @@ public: Value shouldLinkIncrementalValue() { return getValue (Ids::enableIncrementalLinking); } bool shouldLinkIncremental() const { return config [Ids::enableIncrementalLinking]; } - Value getWholeProgramOptValue() { return getValue (Ids::wholeProgramOptimisation); } - bool shouldDisableWholeProgramOpt() const { return static_cast (config [Ids::wholeProgramOptimisation]) > 0; } - Value getUsingRuntimeLibDLL() { return getValue (Ids::useRuntimeLibDLL); } bool isUsingRuntimeLibDLL() const { return config [Ids::useRuntimeLibDLL]; } @@ -263,15 +263,6 @@ public: "used by the libraries."); } - { - static const char* wpoNames[] = { "Enable link-time code generation when possible", - "Always disable link-time code generation", nullptr }; - const var wpoValues[] = { var(), var (1) }; - - props.add (new ChoicePropertyComponent (getWholeProgramOptValue(), "Whole Program Optimisation", - StringArray (wpoNames), Array (wpoValues, numElementsInArray (wpoValues)))); - } - { props.add (new BooleanPropertyComponent (shouldLinkIncrementalValue(), "Incremental Linking", "Enable"), "Enable to avoid linking from scratch for every new build. " @@ -304,6 +295,11 @@ public: return result; } + + void updateOldLTOSetting() + { + getLinkTimeOptimisationEnabledValue() = (static_cast (config ["wholeProgramOptimisation"]) == 0); + } }; //============================================================================== @@ -371,7 +367,7 @@ public: if (charSet.isNotEmpty()) e->createNewChildElement ("CharacterSet")->addTextElement (charSet); - if (! (config.isDebug() || config.shouldDisableWholeProgramOpt())) + if (config.isLinkTimeOptimisationEnabled()) e->createNewChildElement ("WholeProgramOptimization")->addTextElement ("true"); if (config.shouldLinkIncremental()) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Make.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Make.h index 2b69ae1461..a2c2d97feb 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Make.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Make.h @@ -601,6 +601,7 @@ private: out << " -g -ggdb"; out << " -O" << config.getGCCOptimisationFlag() + << (config.isLinkTimeOptimisationEnabled() ? " -flto" : "") << (" " + replacePreprocessorTokens (config, getExtraCompilerFlagsString())).trimEnd() << " $(CFLAGS)" << newLine; diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h index 39af2d38d4..ce28dd654e 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h @@ -399,7 +399,6 @@ protected: cppStandardLibrary (config, Ids::cppLibType, nullptr), codeSignIdentity (config, Ids::codeSigningIdentity, nullptr, iOS ? "iPhone Developer" : "Mac Developer"), fastMathEnabled (config, Ids::fastMath, nullptr), - linkTimeOptimisationEnabled (config, Ids::linkTimeOptimisation, nullptr), stripLocalSymbolsEnabled (config, Ids::stripLocalSymbols, nullptr), vstBinaryLocation (config, Ids::xcodeVstBinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/VST/"), vst3BinaryLocation (config, Ids::xcodeVst3BinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/VST3/"), @@ -414,7 +413,7 @@ protected: CachedValue osxSDKVersion, osxDeploymentTarget, iosDeploymentTarget, osxArchitecture, customXcodeFlags, plistPreprocessorDefinitions, cppStandardLibrary, codeSignIdentity; - CachedValue fastMathEnabled, linkTimeOptimisationEnabled, stripLocalSymbolsEnabled; + CachedValue fastMathEnabled, stripLocalSymbolsEnabled; CachedValue vstBinaryLocation, vst3BinaryLocation, auBinaryLocation, rtasBinaryLocation, aaxBinaryLocation; //========================================================================== @@ -489,9 +488,6 @@ protected: props.add (new BooleanPropertyComponent (fastMathEnabled.getPropertyAsValue(), "Relax IEEE compliance", "Enabled"), "Enable this to use FAST_MATH non-IEEE mode. (Warning: this can have unexpected results!)"); - props.add (new BooleanPropertyComponent (linkTimeOptimisationEnabled.getPropertyAsValue(), "Link-Time Optimisation", "Enabled"), - "Enable this to perform link-time code generation. This is recommended for release builds."); - props.add (new BooleanPropertyComponent (stripLocalSymbolsEnabled.getPropertyAsValue(), "Strip local symbols", "Enabled"), "Enable this to strip any locally defined symbols resulting in a smaller binary size. Enabling this " "will also remove any function names from crash logs. Must be disabled for static library projects."); @@ -910,7 +906,7 @@ public: s.add ("INFOPLIST_PREPROCESSOR_DEFINITIONS = " + indentParenthesisedList (defsList)); } - if (config.linkTimeOptimisationEnabled.get()) + if (config.isLinkTimeOptimisationEnabled()) s.add ("LLVM_LTO = YES"); if (config.fastMathEnabled.get()) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp index 757205ca0a..742bb42149 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp @@ -715,6 +715,7 @@ void ProjectExporter::createDefaultConfigs() config->getNameValue() = debugConfig ? "Debug" : "Release"; config->isDebugValue() = debugConfig; config->getOptimisationLevel() = config->getDefaultOptimisationLevel(); + config->getLinkTimeOptimisationEnabledValue() = ! debugConfig; config->getTargetBinaryName() = project.getProjectFilenameRoot(); } } @@ -890,6 +891,9 @@ void ProjectExporter::BuildConfiguration::createPropertyEditors (PropertyListBui "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, or " "new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash."); + props.add (new BooleanPropertyComponent (getLinkTimeOptimisationEnabledValue(), "Link-Time Optimisation", "Enabled"), + "Enable this to perform link-time code optimisation. This is recommended for release builds."); + createConfigProperties (props); props.add (new TextPropertyComponent (getUserNotes(), "Notes", 32768, true), diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h index cd2f2e13d7..9d68a020f6 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h @@ -261,6 +261,9 @@ public: int getOptimisationLevelInt() const { return config [Ids::optimisation]; } String getGCCOptimisationFlag() const; + Value getLinkTimeOptimisationEnabledValue() { return getValue (Ids::linkTimeOptimisation); } + bool isLinkTimeOptimisationEnabled() const { return config [Ids::linkTimeOptimisation]; } + Value getBuildConfigPreprocessorDefs() { return getValue (Ids::defines); } String getBuildConfigPreprocessorDefsString() const { return config [Ids::defines]; } StringPairArray getAllPreprocessorDefs() const; // includes inherited definitions diff --git a/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h b/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h index d4ed1794d7..1222363f44 100644 --- a/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h +++ b/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h @@ -133,7 +133,6 @@ namespace Ids DECLARE_ID (postbuildCommand); DECLARE_ID (generateManifest); DECLARE_ID (useRuntimeLibDLL); - DECLARE_ID (wholeProgramOptimisation); DECLARE_ID (enableIncrementalLinking); DECLARE_ID (buildVST); DECLARE_ID (bundleIdentifier);