diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index f999e5e272..79da178839 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -401,12 +401,28 @@ else() endif() if (YOKAI_TARGET_SYSTEM_NACL AND YOKAI_CXX_COMPILER_SAIGO AND YOKAI_TARGET_ARCH_ARMHF) - # Saigo produces broken arm builds when optimizing them. + # Saigo produces broken ARM builds when optimizing them. # See: https://github.com/Unvanquished/Unvanquished/issues/3297 - # When setting this clang-specific option, we don't have to care - # about the ordering of -O options that may be introduced, - # all -O options added to the command line are ignored. - set_c_cxx_flag("-Xclang -disable-llvm-passes") + # Above limit 53696, the produced Unvanquished cgame is corrupted. + # Under limit 21000 (approximation), the performance is not fully recovered. + # 50000 is selected as a high value with a fair margin. + # Set -1 (unlimited passes) to unlock breakage. + set(SAIGO_OPT_PASS_LIMIT 50000) + set(SAIGO_OPT_PASS_LIMIT_FLAG "-mllvm -opt-pass-limit=${SAIGO_OPT_PASS_LIMIT}") + + check_CXX_compiler_flag("${SAIGO_OPT_PASS_LIMIT_FLAG}" FLAG_OPT_PASS_LIMIT) + + if (FLAG_OPT_PASS_LIMIT) + set_c_cxx_flag("${SAIGO_OPT_PASS_LIMIT_FLAG}") + # The flag may be used on compilation steps not consuming LLVM backend options. + set_c_cxx_flag("-Wno-unused-command-line-argument") + else() + # Old Saigo builds don't implement the -opt-pass-limit option. + # When setting the following clang-specific option, we don't have + # to care about the ordering of -O options that may be introduced, + # all -O options added to the command line are ignored. + set_c_cxx_flag("-Xclang -disable-llvm-passes") + endif() endif() # Extra debug flags.