Link Time Optimization default value


#1

not really important, just about the default Link Time Optimization setting when creating a new project :
For xcode, it’s off by default. Perhaps that could be turned on for the release config?
For visual both config have “whole program optimisation” enabled.


#2

I second this zombie. And I don’t see LTO in default Linux makefiles (or Code::Blocks, I assume), which would be great.


#3

This is on develop now with commit 559ff67. All the exporters have a LTO option which by default is disabled for debug configs and enabled for release configs.


#4

Awesome, thanks!


#5

@ed95 Do you know how to cope with the enabled Link Time Optimization to build a Release under Linux (Ubuntu 16.04)?

I’ve installed the dependencies as mentioned in the List of Juce dependencies under linux . Building is successful when LTO is disabled, but not when LTO is enabled:

ar: build/intermediate/Release/include_juce_audio_basics_8a4e984a.o: plugin needed to handle lto object
ar: build/intermediate/Release/include_juce_audio_formats_15f82001.o: plugin needed to handle lto object
...

I also tried to explicitly set the compiler with CXX, no success either

make CXX=clang++ CONFIG=Release

Here, gcc & g++ are v5.4.0, clang++ is v3.8.0, llvm-lto-3.8 is available.


#6

Are you able to build the JUCE demo with LTO enabled? I’m also using GCC 5.4.0 on Ubuntu 16.04 and enabling LTO works fine for me, albeit with a couple of warnings in the zlib code.


#7

Thank you for your help, Ed!

The JUCE demo and the ‘audio plugin demo’ do actually build with LTO enabled. But my project doesn’t. I compared and adopted the differences in the settings in the Projucer between my project and the ‘audio plugin demo’. No success. There are no additional dependencies in my project. And of course there were no left overs from previous build attempts. Strange. Well, for now I disable LTO on Linux, no time to investigate further.


#8

That’s odd. Please let me know if you find out what the issue is.


#9

@samuel
Maybe this is helpful:

Similar issue with plugin needed to handle lto object error when using make CONFIG=Release with LTO checked in Projucer.

gcc --version
gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)

With
make AR=gcc-ar CONFIG=Release

though it seems to link, with warnings:

../../../../JUCE/modules/juce_core/zip/zlib/deflate.h:96:16: warning: type ‘struct internal_state’ violates the C++ One Definition Rule [-Wodr]
 typedef struct internal_state {
                ^
../../../../JUCE/modules/juce_graphics/image_formats/../../juce_core/zip/zlib/zlib.h:1347:12: note: a different type is defined in another translation unit
     struct internal_state {int dummy;}; /* hack for buggy compilers */
            ^
../../../../JUCE/modules/juce_core/zip/zlib/deflate.h:97:15: note: the first difference of corresponding definitions is field ‘strm’
     z_streamp strm;      /* pointer back to this zlib stream */
               ^
../../../../JUCE/modules/juce_graphics/image_formats/../../juce_core/zip/zlib/zlib.h:1347:32: note: a field with different name is defined in another translation unit
     struct internal_state {int dummy;}; /* hack for buggy compilers */

#10

Thanks @sobek!

I just tried ‘AR=gcc-ar’ and now my project compiles with the same warnings as you posted. Interestingly, after one such compilation it also compiles fine with

gcc CONFIG=Release

#11

Updated from 5.1.2 to 5.2.1 and this seemingly changed the default from disabled to enabled which caused my link time to shoot through the roof. It’s obvious now but it took a bit of digging to sort out what happened as my jucer file didn’t change. Maybe worth adding an explicit note in the change list?