Skip to content

CMAKE: Add MSVC PGO support#1480

Open
EricGT wants to merge 1 commit intoSWI-Prolog:masterfrom
EricGT:add-msvc-pgo-support
Open

CMAKE: Add MSVC PGO support#1480
EricGT wants to merge 1 commit intoSWI-Prolog:masterfrom
EricGT:add-msvc-pgo-support

Conversation

@EricGT
Copy link
Contributor

@EricGT EricGT commented Feb 27, 2026

Extend PGO infrastructure to support MSVC's two-phase workflow.

See commit message for details.

Extend the existing PGO infrastructure to support MSVC's two-phase PGO
workflow (/GL + /GENPROFILE, then /GL + /USEPROFILE).

Key changes:

  - BuildType.cmake: Enable the PGO build type for MSVC, add PGO to
    CMAKE_CONFIGURATION_TYPES for multi-config generators, define
    C/CXX_FLAGS_PGO with /O2 base optimization, and map PGO to Release
    for imported targets (vcpkg).

  - PGO.cmake: Add PGO_GENERATE_LINK_FLAGS and PGO_USE_LINK_FLAGS
    variables to separate compile flags (/GL) from link flags
    (/LTCG /GENPROFILE, /LTCG /USEPROFILE).  Use /FI instead of
    -include for the PGO timestamp header on MSVC.  Wire the new
    link flags through generate_pgo_data() and use_pgo_data().

/GL is added per-target so utility tools (defatom, mkvmi) that run
during the build are unaffected.  MSVC places .pgd and .pgc files
next to the output binary automatically.
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.

1 participant