Skip to content

cmake: avoid MinGW static Boost LTO link failures - #12

Merged
crazy-max merged 1 commit into
devfrom
pr-209-mingw-static-boost-lto
Aug 18, 2026
Merged

crazy-max merged 1 commit into
devfrom
pr-209-mingw-static-boost-lto

Conversation

@crazy-max

Copy link
Copy Markdown
Owner

MinGW GCC can fail the final link for static Boost builds with LTO enabled when Boost exception thunks are emitted in discarded COMDAT/linkonce sections. Disable LTO only for the translation units that trigger the linker-plugin failure so the rest of the target can keep using LTO.

Also fix the BOOST_SYSTEM_USE_UTF8 condition to test CMake's standard WIN32 variable instead of the lowercase win32 spelling.

Cherry-picked from dscharrer#209 (cc @PatrykMis)

Upstream commits: 505f16e, 33e2c7d

MinGW GCC can fail the final link for static Boost builds with LTO enabled when Boost exception thunks are emitted in discarded COMDAT/linkonce sections. Disable LTO only for the translation units that trigger the linker-plugin failure so the rest of the target can keep using LTO.

Also fix the BOOST_SYSTEM_USE_UTF8 condition to test CMake's standard WIN32 variable instead of the lowercase win32 spelling.

Cherry-picked from dscharrer#209.

Upstream commits: 505f16e, 33e2c7d

Signed-off-by: Patryk Miś <foss@patrykmis.com>
@crazy-max
crazy-max marked this pull request as ready for review August 18, 2026 16:38
@crazy-max
crazy-max merged commit e3714e1 into dev Aug 18, 2026
33 checks passed
@crazy-max
crazy-max deleted the pr-209-mingw-static-boost-lto branch August 18, 2026 16:38
@PatrykMis

Copy link
Copy Markdown

While testing the merged fix, I noticed that -DDEBUG=ON enables src/cli/debug.cpp, which triggers the same GCC/MinGW LTO linker issue. The same workaround (-fno-lto) for src/cli/debug.cpp fixes it.

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