← Back to team overview

kicad-developers team mailing list archive

Re: [MacOS] compiling with link-time optimization

 

Hi again,

last comment/test:
Just dropping in “-flto” in CMakeLists.txt here:
    set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG -Wno-deprecated-declarations" )

    set( CMAKE_C_FLAGS_RELEASE   "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG -flto" )
    set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -flto" )

    if( GXX_HAS_VISIBILITY_FLAG AND NOT APPLE )

I had to remove "-fno-fat-lto-objects” since clang didn’t like it and immediately bailed out.
At least this proved that above change did make a difference.

This time I compiled the exact same version and it also doesn’t seem to have any real effect:
bstegmaier$ ls -al KiCad-5678/kicad.app/Contents/PlugIns/
total 57288
drwxr-xr-x  8 bstegmaier  staff       272 23 Mai 18:49 .
drwxr-xr-x  9 bstegmaier  staff       306 23 Mai 18:49 ..
-rwxr-xr-x  1 bstegmaier  staff   5222076 23 Mai 18:49 _cvpcb.kiface
-rwxr-xr-x  1 bstegmaier  staff   5642208 23 Mai 18:49 _eeschema.kiface
-rwxr-xr-x  1 bstegmaier  staff   2109340 23 Mai 18:49 _gerbview.kiface
-rwxr-xr-x  1 bstegmaier  staff   1801528 23 Mai 18:49 _pcb_calculator.kiface
-rwxr-xr-x  1 bstegmaier  staff  12606536 23 Mai 18:49 _pcbnew.kiface
-rwxr-xr-x  1 bstegmaier  staff   1944760 23 Mai 18:49 _pl_editor.kiface
bstegmaier$ ls -al bin/kicad.app/Contents/PlugIns/
total 58560
drwxr-xr-x  8 bstegmaier  staff       272 23 Mai 19:10 .
drwxr-xr-x  9 bstegmaier  staff       306 23 Mai 19:10 ..
-rwxr-xr-x  1 bstegmaier  staff   5317400 23 Mai 19:10 _cvpcb.kiface
-rwxr-xr-x  1 bstegmaier  staff   5776284 23 Mai 19:10 _eeschema.kiface
-rwxr-xr-x  1 bstegmaier  staff   2143724 23 Mai 19:10 _gerbview.kiface
-rwxr-xr-x  1 bstegmaier  staff   1801776 23 Mai 19:10 _pcb_calculator.kiface
-rwxr-xr-x  1 bstegmaier  staff  12948516 23 Mai 19:10 _pcbnew.kiface
-rwxr-xr-x  1 bstegmaier  staff   1979112 23 Mai 19:10 _pl_editor.kiface

First one without “-flto”, second one with (yes, really… binaries are bigger with it?).


Regards,
Bernhard

> On 23.05.2015, at 18:48, Bernhard Stegmaier <stegmaier@xxxxxxxxxxxxx> wrote:
> 
> Hi again,
> 
> I guess this is due to LTO not even being used on OS X, if I understand your cmake change correctly:
>         find_program(CMAKE_GCC_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
>         find_program(CMAKE_GCC_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
>         find_program(CMAKE_GCC_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
> 
>         if( CMAKE_GCC_AR AND CMAKE_GCC_NM AND CMAKE_GCC_RANLIB )
> On my OS X using clang there is nothing like *gcc-ar*… or any of the other two.
> Why do you have to change/set CMAKE_AR and the other two anyway?
> 
> 
> Regards,
> Bernhard
> 
>> On 23.05.2015, at 18:23, Bernhard Stegmaier <stegmaier@xxxxxxxxxxxxx <mailto:stegmaier@xxxxxxxxxxxxx>> wrote:
>> 
>> Hi,
>> 
>> built your branch on OS X.
>> 
>> Good thing is that build did work for me.
>> I just quickly fired up pcbnew and loaded an existing board… seems to work.
>> 
>> But, it doesn’t seem to have a real effect on code size (first one is my current working version, second one your branch):
>> bstegmaier$ ls -al /Applications/KiCad-5648/kicad.app/Contents/PlugIns/
>> total 58904
>> drwxr-xr-x  8 bstegmaier  admin       272  9 Mai 14:59 .
>> drwxr-xr-x  9 bstegmaier  admin       306  9 Mai 14:59 ..
>> -rwxr-xr-x  1 bstegmaier  admin   5683560  9 Mai 14:59 _cvpcb.kiface
>> -rwxr-xr-x  1 bstegmaier  admin   5652288  9 Mai 14:59 _eeschema.kiface
>> -rwxr-xr-x  1 bstegmaier  admin   2105068  9 Mai 14:59 _gerbview.kiface
>> -rwxr-xr-x  1 bstegmaier  admin   1797432  9 Mai 14:59 _pcb_calculator.kiface
>> -rwxr-xr-x  1 bstegmaier  admin  12970696  9 Mai 14:59 _pcbnew.kiface
>> -rwxr-xr-x  1 bstegmaier  admin   1944576  9 Mai 14:59 _pl_editor.kiface
>> bstegmaier$ ls -al bin/kicad.app/Contents/PlugIns/
>> total 57128
>> drwxr-xr-x  8 bstegmaier  staff       272 23 Mai 18:13 .
>> drwxr-xr-x  9 bstegmaier  staff       306 23 Mai 18:13 ..
>> -rwxr-xr-x  1 bstegmaier  staff   5215564 23 Mai 18:13 _cvpcb.kiface
>> -rwxr-xr-x  1 bstegmaier  staff   5646432 23 Mai 18:13 _eeschema.kiface
>> -rwxr-xr-x  1 bstegmaier  staff   2103556 23 Mai 18:13 _gerbview.kiface
>> -rwxr-xr-x  1 bstegmaier  staff   1758640 23 Mai 18:13 _pcb_calculator.kiface
>> -rwxr-xr-x  1 bstegmaier  staff  12570984 23 Mai 18:13 _pcbnew.kiface
>> -rwxr-xr-x  1 bstegmaier  staff   1938952 23 Mai 18:13 _pl_editor.kiface
>> 
>> The comparison isn’t accurate in any way… both binaries do use different KiCad revisions and the build of your branch is done without github plugin, my working version is with github plugin.
>> 
>> Nevertheless… I think you would have expected a quite significant difference?
>> 
>> 
>> Regards,
>> Bernhard
>> 
>> 
>>> On 22.05.2015, at 16:51, Simon Richter <Simon.Richter@xxxxxxxxxx <mailto:Simon.Richter@xxxxxxxxxx>> wrote:
>>> 
>>> Hi,
>>> 
>>> I've submitted a branch for inclusion at
>>> 
>>> https://code.launchpad.net/~sjr/kicad/lto <https://code.launchpad.net/~sjr/kicad/lto>
>>> 
>>> that seeks to use link-time optimization when possible.
>>> 
>>> We've already established that this is broken on MSYS, so I'm going to
>>> disable it there, while it does some good on Linux. This leaves MacOS.
>>> 
>>> Could anyone try building a Release configuration both with and without
>>> this branch, and check that a) the build still works, and b) we get a
>>> significant reduction in size?
>>> 
>>> Thanks,
>>>   Simon
>>> 
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>>> More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp


References