Skip to content

[CMake] Add BYN_PGO_GENERATE and BYN_PGO_PROFILE_FILE options - #9420

Open
dschuff wants to merge 2 commits into
WebAssembly:mainfrom
dschuff:byn-pgo-cmake
Open

dschuff wants to merge 2 commits into
WebAssembly:mainfrom
dschuff:byn-pgo-cmake

Conversation

@dschuff

@dschuff dschuff commented Nov 22, 2026

Copy link
Copy Markdown
Member

Add CMake options for 2-phase IR Profile-Guided Optimization (PGO)
builds with Clang:

  • BYN_PGO_GENERATE: Adds -fprofile-generate to compile flags. On
    Windows with clang-cl (MSVC), CMake invokes lld-link directly
    rather than linking through the compiler driver, so query clang-cl
    for its compiler-rt directory and pass /libpath:"<dir>" so
    lld-link resolves the embedded clang_rt.profile-*.lib directive;
    on other platforms, pass -fprofile-generate to the linker driver.
  • BYN_PGO_PROFILE_FILE: Adds -fprofile-instr-use="<path>" and
    -Wno-backend-plugin (to avoid harmless main() CFG hash-mismatch
    warnings across tools other than wasm-opt when -Werror is enabled)
    to compile flags, and passes -fprofile-instr-use="<path>" to link
    flags on non-MSVC platforms.

Add CMake options for 2-phase IR Profile-Guided Optimization (PGO)
builds with Clang:

- `BYN_PGO_GENERATE`: Adds `-fprofile-generate` to compile flags. On
  Windows with `clang-cl` (`MSVC`), CMake invokes `lld-link` directly
  rather than linking through the compiler driver, so query `clang-cl`
  for its compiler-rt directory and pass `/libpath:"<dir>"` so
  `lld-link` resolves the embedded `clang_rt.profile-*.lib` directive;
  on other platforms, pass `-fprofile-generate` to the linker driver.
- `BYN_PGO_PROFILE_FILE`: Adds `-fprofile-instr-use="<path>"` and
  `-Wno-backend-plugin` (to avoid harmless `main()` CFG hash-mismatch
  warnings across tools other than `wasm-opt` when `-Werror` is enabled)
  to compile flags, and passes `-fprofile-instr-use="<path>"` to link
  flags on non-MSVC platforms.
@github-actions
github-actions Bot requested a review from tlively November 22, 2026 00:03
@dschuff

dschuff commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

We'll use this for the emscripten-releases release-optimized builds. So... maybe we can get away without CI coverage for this on the Binaryen side?

This branch has not been deployed

No deployments
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