|
LTO in AmigaOS4 gcc |
Posted on: 2019/2/9 14:21
#1 |
---|---|---|
Home away from home
![]() ![]() Joined:
2006/11/26 21:45 From a dying planet
Posts: 3972
|
Are LTO's supported in AmigaOS4's GCC?
Taken from here Quote:
It's often used in small systems like the original RPi but could probably help performance on AmigaOS4 too(?) Sorry if this has been answered already |
|
_________________
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg |
||
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/9 15:26
#2 |
---|---|---|
Just can't stay away
![]() ![]() Joined:
2006/11/30 11:30 From Finland
Posts: 1799
|
@Raziel
VBCC has link time optimizations if you use the -O4 option when compiling and linking. As I recall, in VBCC's case it basically postpones the actual compiling work to the link stage which means that this phase of the build process will be much slower. Not very nice if you are making small changes and recompiling a lot, but might work if you only use it for release builds only and use lower optimization otherwise. |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/9 16:00
#3 |
---|---|---|
Home away from home
![]() ![]() Joined:
2006/11/26 21:45 From a dying planet
Posts: 3972
|
@salass00
OK, but what about gcc 8.x which is used mainly (i think) on AmigaOS4 these days? |
|
_________________
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg |
||
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/9 17:25
#4 |
---|---|---|
Just can't stay away
![]() ![]() Joined:
2006/12/9 10:44 From Lyon, France
Posts: 1339
|
I never heard OS4 programs were compiled with GCC versions newer than v4
|
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/9 17:38
#5 |
---|---|---|
Just can't stay away
![]() ![]() Joined:
2006/11/30 11:30 From Finland
Posts: 1799
|
@Elwood
I've compiled quite a few programs with gcc 8.2.0 already. Quote:
Even if you are compiling natively there is no need to stick to the now ancient gcc 4.2.4 as there are newer versions that you can download from Aminet: http://aminet.net/package/dev/gcc/adtools-os4 http://aminet.net/package/dev/gcc/adtools-8-os4 |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/9 17:45
#6 |
---|---|---|
Just can't stay away
![]() ![]() Joined:
2006/11/30 11:30 From Finland
Posts: 1799
|
@Raziel
Sorry, I have no experience of LTO with gcc so I can't tell if it is working or not. I mainly just use -O2 or -O3 optimization for my programs and don't use too many of the more fancy options. |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/9 19:23
#7 |
---|---|---|
Home away from home
![]() ![]() Joined:
2006/11/26 21:45 From a dying planet
Posts: 3972
|
@salass00
Hmm, ok, guess i'll have to try it out myself then. Thank you |
|
_________________
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg |
||
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/11 10:26
#8 |
---|---|---|
Home away from home
![]() ![]() Joined:
2006/11/26 21:45 From a dying planet
Posts: 3972
|
@thread
Just for the record LTO is NOT supported in gcc...time for a feature request |
|
_________________
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg |
||
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/11 21:46
#9 |
---|---|---|
Just can't stay away
![]() ![]() Joined:
2008/1/6 17:56 From Pennsylvania, USA
Posts: 1342
|
@Raziel
Quote: Just for the record LTO is NOT supported in gcc...time for a feature request Are you sure. This would seem to indicate otherwise: http://gcc.gnu.org/wiki/LinkTimeOptimization |
|
_________________
Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450 |
||
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/11 21:56
#10 |
---|---|---|
Home away from home
![]() ![]() Joined:
2006/11/26 21:45 From a dying planet
Posts: 3972
|
@xenic
Yes, but gcc for AmigaOS has not been build supporting LTO, so it's not in (yet) See last comment by sba1 |
|
_________________
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg |
||
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/12 12:49
#11 |
---|---|---|
Just popping in
![]() ![]() Joined:
2006/12/5 2:30 From Vancouver, Canada
Posts: 192
|
@Raziel
bebbo recently got LTO support working on his gcc 6.x port for 68K. Maybe you can find some more info there? http://eab.abime.net/showpost.php?p=1297430&postcount=1024 |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/12 15:13
#12 |
---|---|---|
Home away from home
![]() ![]() Joined:
2006/11/26 21:45 From a dying planet
Posts: 3972
|
@gregthecanuck
Thank you, interesting thread, found even something that might be useful once gcc supports LTO |
|
_________________
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg |
||
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/16 17:13
#13 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 12:31 From Russia
Posts: 6820
|
So i give it a go and build gcc with LTO enabled. All i need its to add to the /amiga/adtools/gcc-build/features.mk "lto" to enabled languages as well as add "--enabled-lto" option. As i read everywhere adding "lto" to enabled-languages there is not necessary, as once configure scripts will find "--enable-lto" then will add it for you, but then i anyway add it and it works. So, my current features.mk with c,c++,objc,objc++,fortran and lto looks like this:
MAJOR_VERSION:=$(word 1, $(subst ., , $(VERSION)))
Then i clean my previous build, run "make -C native-build gcc-cross CROSS_PREFIX=/usr/local/amiga" and in end have new gcc:
$ ppc-amigaos-gcc -v
Then, i trying to find some benchmarks, some testcases which will show that lto is works for sure, etc, but fail. Only find some texts with descriptions how it works, with some pseudo-asm and stuff, so to only understand that LTO is another optimisation, which can do some more low-level optimisation. So all what i test at moment, is create such a simple test case:
#include <stdio.h>
Then i build 2 versions of it: With -O3 , but no LTO: $ ppc-amigaos-gcc -O3 test_lto1.c -o test_lto1_no_lto With -O3 , but with LTO: $ ppc-amigaos-gcc -O3 -flto test_lto1.c -o test_lto1_with_lto Now, size of the produced binary without LTO are 6176, size of binary produced with LTO enable are 6107. Difference are that version build with LTO are smaller on 69 bytes. Then i disassmble it to asm code to see how it looks like, so, version WITHOUT lto, looks like this :
$ ppc-amigaos-objdump -d test_lto1_no_lto
And version with lto enabled looks like this:
$ ppc-amigaos-objdump -d test_lto1_with_lto
If you bored to compare, can say that start() about the same (some values only changes in some place). While in case with LTO i can't see my_malloc() function code at all. Is it lto optimisation somehow remove it, or whf, dunno. But what for sure, the same happens if i build the same test code from win32. I.e. same differences in disassembled code, and the same disappeared my_malloc(). Probabaly that can mean that -flto works the same for us too. So now need to make some real lto test code, which will point out that it 100% works (or not). Any idea of simple test case ? |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/16 17:52
#14 |
---|---|---|
Home away from home
![]() ![]() Joined:
2006/12/4 23:15 Posts: 2232
|
@kas1e
Your test case is stupidly simple (no insult intended) it does nothing, calling my_malloc() has no efffect (result is unused) so it's been 'inlined then removed' by the -03 optimisation, then I expect the LTO optimsation has noticed that my_malloc() ends up not being called and removed that too. Normal optimsiation wouldn't remove the function as there would be no way to know if it was called from another module till link time. Quote:
LTO isn't really going to do too much until you have multiple object files which do something meaningful, that can be benchmarked. If you split out your my_malloc() into another src file so that there are two objects file before linking you might see a bigger difference as the non LTO case would not be able to inline / remove it as it coudn't know if there were side effects to the function call. LTO (I would guess) would end up somewhat similar to the current result, depending on just what link time optimisations are possible. |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/16 18:34
#15 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 12:31 From Russia
Posts: 6820
|
@Andy
Quote:
Yeah, will try tomorrow to build some fat by objects game with fps counter Quote:
Sure test case suck, but that point out that -flto is smart enough to make some optimisation even on single object file, just to even have 100bytes less exe. Quote:
Tried that:
$ cat my_malloc.c
And then:
ppc-amigaos-gcc -flto -O3 -c my_malloc.c -o my_malloc_with_lto.o
And now, binary where no lto used, start to be bigger than when it single object version: 6247 vs 6176, while lto version in both cases be it 1 object or two, are 6107. So in case with single object version it better on 69 bytes, and in case with 2 objects, its better on 140 bytes (seems like you expect). |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/18 17:52
#16 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 12:31 From Russia
Posts: 6820
|
Soo.. Good news !
I rebuild foobillard++ with -O3 -flto for all objects and -O3 -flto for final linking line , and compare it with pure -O3 compile without lto. And results are for the same test (same size of game's window, same settings, just rerun few times 2 different binaries): pure -O3 max: 64,1, avg: 60,19 -O3 -flto max: 72.7, avg: 68.57 What mean it works damn and give already quite a boost for first tested game ! +8fps , its about 12-13% speed increase ! Also, in the case with no lto, binary size are 16.318.671, and with lto are 15.863.290, so its not only faster by fps, but also less on 0.5mb. Probabaly that huge boost can be explained by the fact, that everything compiled statically : SDL2, gl4es, glu, sdl2_image, sdl2_mixer, and all those 3d party libs, so -flto optimize them too on the linking stage by taking from those .a all the objects. Will try to rebuild barony, frickingshark, prototype, neverball/neverput and quake3 , to see how they will behave with -flto. Edited by kas1e on 2019/2/18 18:54:06
|
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/19 12:49
#17 |
---|---|---|
Not too shy to talk
![]() ![]() Joined:
2011/6/3 13:49 Posts: 269
|
Hello
Nice ![]() Kas1e, is your lto gcc available somewhere ? Many Thanks |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/19 14:02
#18 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 12:31 From Russia
Posts: 6820
|
@thellier
At moment it just on my cross-compiler cygwin's setup. But its really easy to compile it from adtools repo by adding that --enable-lto option |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/20 8:17
#19 |
---|---|---|
Not too shy to talk
![]() ![]() Joined:
2011/6/3 13:49 Posts: 269
|
OK
I have a 32 bit cygwin cross-compiling environement too: is your gcc 32 bits ? Alain |
|
|
Re: LTO in AmigaOS4 gcc |
Posted on: 2019/2/20 11:46
#20 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 12:31 From Russia
Posts: 6820
|
@thellier
My one are x86_64-pc-cygwin, gcc 7.4.0 |
|