cmake: make possible to enable LTO when compiling dll games#1481
cmake: make possible to enable LTO when compiling dll games#1481
Conversation
0ed3c26 to
301b420
Compare
The ASLR for DLLs is prioritized over ASLR for executables? That’s bad. DLLs are only for debugging and no one should give a shit about using ASLR for them. It would make more sense to just force BUILD_GAME_DLL to off when LTO is requested. |
|
Building a dll game is only meaningful for debugging or profiling anyway, and I want to be able to profile binaries built with LTO enabled. Why caring about engine debugging builds not being like release ones? |
301b420 to
67812ef
Compare
|
It's a bad and suprising-to-the-user idea to make the engine build behave differently depending on whether the DLL build is enabled or not. For builds intended to be use as "release" it's surely very common to have the DLL builds enabled. For a user who is not intimately familiar with Unvanquished development, the obvious thing to do is checkout out |
|
I don't get why the default game build is dll and not nexe, to begin with. The dll game is never meant for release.. |
Well, building any gamelogic at all is something that is for developers/maintainers, not users. But catering purely to end users would be too perverse as the Unvanquished repo wouldn't build any of its own code by default :) DLL is the most commonly used dev workflow, so that is the default. |
|
If dll is a dev workflow I don't think we should worry about the engine not being a release build… But anyway, I did that instead: It builds the dll game in a cmake subproject so we can use different compilation and linker flags than when building the engine. |
The
-fPIEand-fpieflags should not be used when building a shared library. For some unknown reasons that works with GCC and Clang until we enable LTO.This patch makes CMake uses
-fpiewhen linking executables, and-fpicwhen linking libraries.Because common object files from shared source between engine and game cane be built once for both engine executable and game dll, all objects are built with
-fPICif building dll games is enabled, or built with-fPIEotherwise.It is then not possible to build an engine executable with
-fPIEwhen building dll games in the same build folder. To build engine executable with-fPIEand dll games with-fPIEin the same build folder, we would have to implement a sub-cmake like we do for NaCl, losing the ability to reuse object files.When building a release we not only don't build the dll game but also build the engine separately with any game disabled, so this should change nothing to the way releases are built.
For information, here is the kind of linking error I get with GCC when enabling both HARDENING (and then PIE) and LTO with dll games: