Author: manx
Date: Sat May 11 22:24:19 2024
New Revision: 20767
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20767
Log:
[Fix/Reg] Force optimization down to -O1 when building with GCC 14. GCC 14 has shown severe miscompilation of inline functions that has caused the test suite to crash on MinGW-w64 amd64 builds. This is a drastic safety measure until GCC fixes their bug. The performance impact is roughly ~15%.
Modified:
trunk/OpenMPT/common/BuildSettings.h
trunk/OpenMPT/src/mpt/base/detect_quirks.hpp
trunk/OpenMPT/src/mpt/check/compiler.hpp
Modified: trunk/OpenMPT/common/BuildSettings.h
==============================================================================
--- trunk/OpenMPT/common/BuildSettings.h Sat May 11 22:23:38 2024 (r20766)
+++ trunk/OpenMPT/common/BuildSettings.h Sat May 11 22:24:19 2024 (r20767)
@@ -388,6 +388,16 @@
#endif // MPT_COMPILER_MSVC
+#if MPT_COMPILER_GCC
+
+#ifdef MPT_COMPILER_QUIRK_GCC_NO_O2
+#if defined(__OPTIMIZE__)
+#pragma GCC optimize("O1")
+#endif
+#endif // MPT_COMPILER_QUIRK_GCC_NO_O2
+
+#endif // MPT_COMPILER_GCC
+
#if MPT_COMPILER_CLANG
#if defined(MPT_BUILD_MSVC)
Modified: trunk/OpenMPT/src/mpt/base/detect_quirks.hpp
==============================================================================
--- trunk/OpenMPT/src/mpt/base/detect_quirks.hpp Sat May 11 22:23:38 2024 (r20766)
+++ trunk/OpenMPT/src/mpt/base/detect_quirks.hpp Sat May 11 22:24:19 2024 (r20767)
@@ -19,6 +19,16 @@
+#if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 0, 0)
+// GCC 14 causes severe miscompilation of inline functions.
+// Link to bug report will follow.
+#if defined(__OPTIMIZE__)
+#define MPT_COMPILER_QUIRK_GCC_NO_O2
+#endif
+#endif
+
+
+
#if MPT_OS_DJGPP
#define MPT_ARCH_QUIRK_NO_SIMD256
#endif
Modified: trunk/OpenMPT/src/mpt/check/compiler.hpp
==============================================================================
--- trunk/OpenMPT/src/mpt/check/compiler.hpp Sat May 11 22:23:38 2024 (r20766)
+++ trunk/OpenMPT/src/mpt/check/compiler.hpp Sat May 11 22:24:19 2024 (r20767)
@@ -7,6 +7,12 @@
#include "mpt/base/detect_quirks.hpp"
#include "mpt/base/compiletime_warning.hpp"
+#ifndef MPT_CHECK_CXX_IGNORE_WARNING_O2
+#if defined(MPT_COMPILER_QUIRK_GCC_NO_O2)
+MPT_WARNING("GCC 14 is known to cause severe miscompilation of inline functions. OpenMPT has forced optimization settings down to -O1. This comes at a roughly 15% performance cost. It is strongly recommended to stay with GCC 13 for the time being. You will need to edit the source to opt-out of this safety guard.")
+#endif
+#endif
+
#ifndef MPT_CHECK_CXX_IGNORE_PREPROCESSOR
#if defined(MPT_COMPILER_QUIRK_MSVC_OLD_PREPROCESSOR)
MPT_WARNING("C++ preprocessor is not standard conformings.")
|