Skip to content

module-template: fix the IPO check - #13

Merged
siahisaforker merged 2 commits into
moderngekko-vendorfrom
fix/pr-11-ipo-check
Aug 10, 2026
Merged

module-template: fix the IPO check#13
siahisaforker merged 2 commits into
moderngekko-vendorfrom
fix/pr-11-ipo-check

Conversation

@siahisaforker

Copy link
Copy Markdown

Replacement for #11 because its head repository is a sibling fork and GitHub does not permit maintainer pushes to it.

Includes the response-file IPO check fix while preserving the existing default of enabling IPO when supported.

Validation: configured the module template with Clang 19 and forced Ninja response files; ThinLTO remained enabled.

dougchansan and others added 2 commits August 6, 2026 10:46
The IPO support check could never pass on macOS, and the failure was silent.

moderngekko-port configures with CMAKE_NINJA_FORCE_RESPONSE_FILE=1, which the
module genuinely needs -- 186 objects do not fit on a command line.
check_ipo_supported's try-compile inherits the environment, so its static
library step runs `ar qc libfoo.a @foo.rsp`, and Apple's /usr/bin/ar has no
@file support:

    ar: @CMakeFiles/foo.rsp: No such file or directory

The check therefore failed, CMake logged one "Module IPO disabled:" line, and
the build carried on without -flto=thin -- while manifest.txt went on recording
`flags=compile:-O2 -flto=thin ... link:-flto=thin`. Object files were plain
Mach-O rather than LLVM bitcode. No module built on macOS has ever had
cross-translation-unit inlining, which is worth knowing before drawing any
conclusion about why a runtime helper did not get inlined into generated code.

Scope the variable off around the check only and restore it before the
generator reads it, so the real link keeps its response files.

Also flip RECOMPCORE_MODULE_ENABLE_IPO to OFF, because with the check repaired
LTO was measured and did not pay. Mario Kart: Double Dash on arm64, same PGO
profile, only -flto=thin differing, alternating A/B with a reversed final
block on one savestate:

    no LTO   n=5  mean 1.1826  [1.1729-1.1959]
    LTO      n=5  mean 1.1733  [1.1387-1.1879]
    -0.8%, ranges overlap -- unproven

The host was not quiet, so this is "no win" rather than "a loss". Pushing
further -- -Wl,-mllvm,-import-instr-limit=500 -Wl,-mllvm,-inline-threshold=600,
which does inline the hot FP helper, taking ppc_fmuls from 5846 call sites to
861 -- measured -1.7% and grew the module by 7 MB.

One caveat on the default. On Linux, GNU ar does support @file, so the check
presumably passed there and those builds have had thin-LTO all along; OFF takes
it away from them. That is not backed by a Linux measurement. If you would
rather not change Linux, take the check fix and drop the default change --
they are independent, and the option can still be set per build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants