sba1 / adtools

Experimental GNU toolchain for AmigaOS
31 stars 18 forks source link

(If possible) Implement/Support LTO (LinkTime Optimization) #66

Closed raziel- closed 5 years ago

raziel- commented 5 years ago

https://gcc.gnu.org/wiki/LinkTimeOptimization and https://gcc.gnu.org/onlinedocs/gccint/LTO.html#LTO

sba1 commented 5 years ago

Am 2019-02-11 11:41, schrieb Hubert Maier:

https://gcc.gnu.org/wiki/LinkTimeOptimization and https://gcc.gnu.org/onlinedocs/gccint/LTO.html#LTO

Have you tried whether it is not already working (to some extend)?

If does not work, please provide a small example that doesn't work.

raziel- commented 5 years ago

I just tested four different configures from my projects and none got even beyond the compiler check.

As soon as "-flto" is in place (LDFDLAGS, CXXFLAGS etc.) configure breaks. So, no, unfortunately it's not working (albeit i don't know if it's because of some gcc flaw or not implemented at all)

sba1 commented 5 years ago

Am 2019-02-11 11:57, schrieb Hubert Maier:

I just tested four different configures from my projects and none got even beyond the compiler check.

As soon as "-flto" is in place (LDFDLAGS, CXXFLAGS etc.) configure breaks. So, no, unfortunately it's not working (albeit i don't know if it's because of some gcc flaw or not implemented at all)

A non-configure example would be handy.

raziel- commented 5 years ago

I know...but i can't help with that i'm afraid, sorry :-(

sba1 commented 5 years ago

Am 2019-02-11 11:57, schrieb Hubert Maier:

I just tested four different configures from my projects and none got even beyond the compiler check.

As soon as "-flto" is in place (LDFDLAGS, CXXFLAGS etc.) configure breaks. So, no, unfortunately it's not working (albeit i don't know if it's because of some gcc flaw or not implemented at all)

Wait. The official produced binaries have this feature not enabled yet. IIRC, then the gcc builds' configure needs to add a certain option (--enable-lto I think). Can you try that?

Anyway, a minimal example would still be handy.

raziel- commented 5 years ago

You mean, build my own gcc with lto enabled? :-o

I can't even provide you with a silly simple example code...

;-)

kas1e commented 5 years ago

I tried to build latest adtools with that changes In /amiga/adtools/gcc-build/features.mk:

MAJOR_VERSION:=$(word 1, $(subst ., , $(VERSION)))

FEATURES=\
        --enable-languages=c,c++,objc,obj-c++,fortran,lto \
        --enable-haifa \
        --enable-lto \
        --enable-sjlj-exceptions  \
        --disable-libstdcxx-pch \
        --disable-tls

# Check, if major version is greater than or equals to 8
ifeq ($(shell test $(MAJOR_VERSION) -ge 8; echo $$?), 0)
FEATURES+=--enable-threads=amigaos
endif

fortran and objc,objc++ already tested before and works, so for lto i only add it to default language, and add --enable-lto (as that one seems to be need too by default to have lto working , as it not "default language" in general term).

Everything compiles fine, and i can use -flto flag.

I didn't create at moment any test case which will show if it works at all or not, but by binaries produced i can see the size of binary with -flto is smaller, as well as when i watch the code via objdump it has less functions for sure.

I will write back once will 100% sure that LTO works

raziel- commented 5 years ago

Thank you for the work, interest and help

kas1e commented 5 years ago

At least some brief tests with simple objects showns that lto works. At least if one build with -O3 and without lto some test case , and build it with -flto -O3 , then lto version is smaller in terms of binary size (that because unused functions get removed, pointing our that -flto works). I will try tomorrow to build some big by objects game with fps counter, to see if it make impact on the fps , and if how big difference between final exes build with and without -flto.

kas1e commented 5 years ago

Tested it more deep: it works (tested different lto parametrs and options). So it only a matter of add --enable-lto to features.mk.

@Sebastian Can you add it by default, so everyone will have it ?

raziel- commented 5 years ago

@kas1e

Thank you

@sba1

Please? That would be grand

Thank you

sba1 commented 5 years ago

The reason why I didn't add it so far was that lto will not work with the native compile (as it requires plugins).

kas1e commented 5 years ago

@sba I use it without plugins , and as i understand to enable plugins you need special options added to configure process. I.e. just pure --enable-lto works without plugins and will works natively too imho

sba1 commented 5 years ago

Okay, I don't remember exact details either. Let's try it.

raziel- commented 5 years ago

Yay, thanks a lot. Where can I find daily builds again? null