fix(cmake): don't pass -fno-fat-lto-objects on Apple GCC#6114
Open
henryiii wants to merge 1 commit into
Open
Conversation
GCC on macOS has no linker plugin, so `-fno-fat-lto-objects` makes every LTO probe fail and LTO is silently disabled. Plain `-flto=auto` works. Fixes pybind#6060 Assisted-by: ClaudeCode:claude-opus-5 Claude-Session: https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3
henryiii
marked this pull request as ready for review
July 26, 2026 03:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #6112.
🤖 AI text below 🤖
Description
GCC on macOS has no linker plugin.
-fno-fat-lto-objectsneeds one, socc1plusfails with "-fno-fat-lto-objectsare supported only with linker plugin". Because the LTO probe always adds this flag for non-MinGW GNU compilers, every probe (-flto=auto,-flto) fails and LTO is silently disabled, although plain-flto=autoworks.This change skips the flag when
APPLEis set.Verified with Homebrew
g++-16on macOS: before,HAS_FLTO_AUTOandHAS_FLTOboth fail andpybind11::ltois disabled; after,HAS_FLTO_AUTOsucceeds andpybind11::ltois enabled. The Apple Clang path is unchanged.Fixes #6060
Suggested changelog entry:
-fno-fat-lto-objectsto GCC on macOS, which made all LTO probes fail and silently disabled LTO.https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3