[RFC] Linux: Make GCC LTO (Link Time Optimizations) work
While building with -flto and gcc on Linux does succeed, the resulting binary crashes at seemingly random places. This set of 3 patches removes all warnings emitted by GCC during the LTO run, and the resulting binary actually works fine as well (played a few levels, mods, saved/loaded savegames from both the lto-patched and vanilla binary, no issues whatsoever).
Comparison of binary size (-O3 -march=znver4):
text data bss dec hex filename
3186051 29625 3247936 6463612 62a07c theforceengine-nolto-gcc15
2449402 26328 3119440 5595170 556022 theforceengine-lto-gcc15
Size reduction of 848kiB or 13,4% (900kiB / 10% with Editor+AngelScript also built in).
The thing that LTO was most confused by is apparently the wraparound-to-nullptr design in the TFE_Jedi Allocator. I changed it a bit to have regular nullptrs and directly use malloc/free. The rest is namespace cleanups to get rid of C++ ODR violations which only appear with lto enabled, and nullpointer checks to call allocator_newItem() callsites (which fixes an lto-only allocator pointer corruption encountered with dark tide 1 mod).
Clang LTO also works, but generates a 10% bigger binary (compared to non-lto build).
What do you think?