Godot version
4.0.beta (006e345)
System information
All
Issue description
As discussed in #66242, we have inconsistent usage of the -fomit-frame-pointer and -ftree-vectorize compiler flags in the various platform ports currently.
In current master, we apply these flags on target=release export templates on macOS, iOS and Android only, with the following logic:
target=release optimize=speed -> both flags
target=release optimize=size -> only -ftree-vectorize
macOS, iOS and Android are three platforms which rely on Clang as compiler, but these flags are also supported by GCC and the LLVM-based Emscripten so in theory we should be able to use them for all platforms aside from MSVC (where the /Oy flag, implicit in /O1 and /O2 which we use, should do something similar).
So we just need to assess what they do and whether we want them for release builds made with GCC (Linux, Windows) and Emscripten (Web) too. This may also be relevant for thirdparty platform ports (consoles, Haiku, etc.).
But first some history to know when this flags were introduced or removed:
-fomit-frame-pointer
In the first open source commit 0b806ee, it seems like all platforms used this flag, aside from iOS and JavaScript:
$ rg --sort path -l fomit-frame-pointer
platform/android/detect.py
platform/nacl/detect.py
platform/osx/detect.py
platform/server/detect.py
platform/windows/detect.py
platform/x11/detect.py
During Godot 2.0 development, it was removed from Windows/MinGW and X11 builds by two separate commits:
During Godot 3.0 development the flag was finally added to iOS by @RandomShaper in #8949 in an effort to harmonize the config between Android and iOS.
Finally during Godot 3.1 development the flag was removed for the server platform by @Calinou in #26666 while syncing it with X11.
Considerations
- So now we have macOS, iOS and Android using the flag, and Windows/MinGW, Linux and Web not using it.
- We can either make all platforms use it, or remove it from macOS, iOS and Android.
- Possibly worth a read, Facebook engineers are proposing changing default compilation in Fedora to disable
-fomit-frame-pointer: https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer
- After doing all this research I finally read the GCC docs and found out that
-fomit-frame-pointer is already implied by -O1, -O2, and -O3... so we don't need to specify it for GCC. For Clang, I can't find exhaustive information on what flags they enable for each optimization level, Clang docs are extremely terse.
-ftree-vectorize
When Godot was open sourced, this was used for Android and macOS:
$ rg --sort path -l ftree-vectorize
platform/android/detect.py
platform/osx/detect.py
It was added to iOS in #8949 like -fomit-frame-pointer.
Godot version
4.0.beta (006e345)
System information
All
Issue description
As discussed in #66242, we have inconsistent usage of the
-fomit-frame-pointerand-ftree-vectorizecompiler flags in the various platform ports currently.In current
master, we apply these flags ontarget=releaseexport templates on macOS, iOS and Android only, with the following logic:target=release optimize=speed-> both flagstarget=release optimize=size-> only-ftree-vectorizemacOS, iOS and Android are three platforms which rely on Clang as compiler, but these flags are also supported by GCC and the LLVM-based Emscripten so in theory we should be able to use them for all platforms aside from MSVC (where the
/Oyflag, implicit in/O1and/O2which we use, should do something similar).So we just need to assess what they do and whether we want them for release builds made with GCC (Linux, Windows) and Emscripten (Web) too. This may also be relevant for thirdparty platform ports (consoles, Haiku, etc.).
But first some history to know when this flags were introduced or removed:
-fomit-frame-pointerIn the first open source commit 0b806ee, it seems like all platforms used this flag, aside from iOS and JavaScript:
During Godot 2.0 development, it was removed from Windows/MinGW and X11 builds by two separate commits:
-ffast-math, which is indeed problematic and was eventually removed for all platforms by @HP in Don't use -ffast-math or other unsafe math optimizations #24855).During Godot 3.0 development the flag was finally added to iOS by @RandomShaper in #8949 in an effort to harmonize the config between Android and iOS.
Finally during Godot 3.1 development the flag was removed for the server platform by @Calinou in #26666 while syncing it with X11.
Considerations
-fomit-frame-pointer: https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer-fomit-frame-pointeris already implied by-O1,-O2, and-O3... so we don't need to specify it for GCC. For Clang, I can't find exhaustive information on what flags they enable for each optimization level, Clang docs are extremely terse.-ftree-vectorizeWhen Godot was open sourced, this was used for Android and macOS:
It was added to iOS in #8949 like
-fomit-frame-pointer.