Skip to content

Commit 31a099b

Browse files
committed
Enable optimization on nacl-armhf with Saigo but limit the amount of optimization passes
1 parent 90574d7 commit 31a099b

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

‎cmake/DaemonFlags.cmake‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,28 @@ else()
401401
endif()
402402

403403
if (YOKAI_TARGET_SYSTEM_NACL AND YOKAI_CXX_COMPILER_SAIGO AND YOKAI_TARGET_ARCH_ARMHF)
404-
# Saigo produces broken arm builds when optimizing them.
404+
# Saigo produces broken ARM builds when optimizing them.
405405
# See: https://github.com/Unvanquished/Unvanquished/issues/3297
406-
# When setting this clang-specific option, we don't have to care
407-
# about the ordering of -O options that may be introduced,
408-
# all -O options added to the command line are ignored.
409-
set_c_cxx_flag("-Xclang -disable-llvm-passes")
406+
# Above limit 53696, the produced Unvanquished cgame is corrupted.
407+
# Under limit 21000 (approximation), the performance is not fully recovered.
408+
# 50000 is selected as a high value with a fair margin.
409+
# Set -1 (unlimited passes) to unlock breakage.
410+
set(SAIGO_OPT_PASS_LIMIT 50000)
411+
set(SAIGO_OPT_PASS_LIMIT_FLAG "-mllvm -opt-pass-limit=${SAIGO_OPT_PASS_LIMIT}")
412+
413+
check_CXX_compiler_flag("${SAIGO_OPT_PASS_LIMIT_FLAG}" FLAG_OPT_PASS_LIMIT)
414+
415+
if (FLAG_OPT_PASS_LIMIT)
416+
set_c_cxx_flag("${SAIGO_OPT_PASS_LIMIT_FLAG}")
417+
# The flag may be used on compilation steps not consuming LLVM backend options.
418+
set_c_cxx_flag("-Wno-unused-command-line-argument")
419+
else()
420+
# Old Saigo builds don't implement the -opt-pass-limit option.
421+
# When setting the following clang-specific option, we don't have
422+
# to care about the ordering of -O options that may be introduced,
423+
# all -O options added to the command line are ignored.
424+
set_c_cxx_flag("-Xclang -disable-llvm-passes")
425+
endif()
410426
endif()
411427

412428
# Extra debug flags.

0 commit comments

Comments
 (0)