Building with LTO optimization causes GOB engine to be "ignored"

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
vanfanel
Posts: 20
Joined: Sat Dec 15, 2012 11:14 am

Building with LTO optimization causes GOB engine to be "ignored"

Post by vanfanel » Fri Feb 08, 2019 10:44 pm

Hi there,

I usually build Scummvm with -lto flag for gcc and linker (CXXFLAGS and LDFLAGS).
In order to build, I have to do:

Code: Select all

CFLAGS="-flto" CXXFLAGS="-flto" LDFLAGS="-flto" AR="gcc-ar" NM="gcc-nm" RANLIB="gcc-ranlib" ./configure --disable-debug --enable-release --enable-optimizations --default-dynamic
However, it results on on a version of scummvm + plugins where the libgob (GOB engine) is ignored. The libgob.so file IS built, along with the rest of the engine plugins, but if I try to add a GOB engine game, it's not recognized.

Any idea on what's going on here, please? This is a mistery... No errors during build or run time.

LTO optimizations are good for small systems like the original Raspberry Pi.

Thanks!

vanfanel
Posts: 20
Joined: Sat Dec 15, 2012 11:14 am

Re: Building with LTO optimization causes GOB engine to be "ignored"

Post by vanfanel » Sun Feb 10, 2019 3:26 pm

Seems to be related to plugin building, because building scummvm with engines built-in, GOB does work with LTO optimizations active.

User avatar
Raziel
ScummVM Porter
Posts: 1043
Joined: Tue Oct 25, 2005 8:27 am
Location: a story that hasn't been written yet

Re: Building with LTO optimization causes GOB engine to be "ignored"

Post by Raziel » Mon Mar 11, 2019 9:44 am

Question:

Do i need to enable-optimizations in configure? Or any of your other flags? Maybe anything else in my toolchain?

I tried configuring with -flto in place, but configure doesn't even find a usable gcc/c++ compiler.
Removing the -flto flag from LDFLAGS and CXXFLAGS makes it configure properly again.

I'm a noob when it comes to this, so, any pointers?

Thanks a lot

vanfanel
Posts: 20
Joined: Sat Dec 15, 2012 11:14 am

Re: Building with LTO optimization causes GOB engine to be "ignored"

Post by vanfanel » Wed Mar 13, 2019 11:52 am

Raziel wrote:
Mon Mar 11, 2019 9:44 am
Question:

Do i need to enable-optimizations in configure? Or any of your other flags? Maybe anything else in my toolchain?

I tried configuring with -flto in place, but configure doesn't even find a usable gcc/c++ compiler.
Removing the -flto flag from LDFLAGS and CXXFLAGS makes it configure properly again.

I'm a noob when it comes to this, so, any pointers?

Thanks a lot
The problem with the configure not finding an usable compiler comes from this section:

https://github.com/scummvm/scummvm/blob ... gure#L2232

In short, with the "-flto" option passed to the compiler, the configure script is unable to determine endianness using the test in that part of the script. No idea why.
Anyway, just comment out the test altogether and force this:
_endian=little
(Supposing you are on X86 or ARM, of course, which are both little-endian).
Now try the configure script again passing the options I mentioned on the first post for LTO, and it will work.

User avatar
Raziel
ScummVM Porter
Posts: 1043
Joined: Tue Oct 25, 2005 8:27 am
Location: a story that hasn't been written yet

Re: Building with LTO optimization causes GOB engine to be "ignored"

Post by Raziel » Wed Mar 13, 2019 2:08 pm

That did it, thank you

But if you get the same bahaviour then maybe we should report it?

digitall
ScummVM Developer
Posts: 990
Joined: Thu Aug 02, 2012 1:40 pm

Re: Building with LTO optimization causes GOB engine to be "ignored"

Post by digitall » Wed Mar 13, 2019 5:42 pm

This may be the same issue as https://bugs.scummvm.org/ticket/10695 ...

User avatar
Raziel
ScummVM Porter
Posts: 1043
Joined: Tue Oct 25, 2005 8:27 am
Location: a story that hasn't been written yet

Re: Building with LTO optimization causes GOB engine to be "ignored"

Post by Raziel » Wed Mar 13, 2019 7:29 pm

To clear things up, the workaround by vanfanel works for me, but i need to give _endian=big to make it work for my platform.
So, not sure if the bug item would cover my problem as well?

Post Reply