From: <sv...@op...> - 2024-05-11 21:43:02
|
Author: manx Date: Sat May 11 23:42:51 2024 New Revision: 20785 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20785 Log: Merged revision(s) 20767 from trunk/OpenMPT: [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: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/common/BuildSettings.h branches/OpenMPT-1.31/src/mpt/base/detect_quirks.hpp branches/OpenMPT-1.31/src/mpt/check/compiler.hpp Modified: branches/OpenMPT-1.31/common/BuildSettings.h ============================================================================== --- branches/OpenMPT-1.31/common/BuildSettings.h Sat May 11 23:41:55 2024 (r20784) +++ branches/OpenMPT-1.31/common/BuildSettings.h Sat May 11 23:42:51 2024 (r20785) @@ -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: branches/OpenMPT-1.31/src/mpt/base/detect_quirks.hpp ============================================================================== --- branches/OpenMPT-1.31/src/mpt/base/detect_quirks.hpp Sat May 11 23:41:55 2024 (r20784) +++ branches/OpenMPT-1.31/src/mpt/base/detect_quirks.hpp Sat May 11 23:42:51 2024 (r20785) @@ -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_COMPILER_MSVC #if !defined(_MSVC_TRADITIONAL) #define MPT_COMPILER_QUIRK_MSVC_OLD_PREPROCESSOR Modified: branches/OpenMPT-1.31/src/mpt/check/compiler.hpp ============================================================================== --- branches/OpenMPT-1.31/src/mpt/check/compiler.hpp Sat May 11 23:41:55 2024 (r20784) +++ branches/OpenMPT-1.31/src/mpt/check/compiler.hpp Sat May 11 23:42:51 2024 (r20785) @@ -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.") |