Skip to content

fix(cmake): don't pass -fno-fat-lto-objects on Apple GCC#6114

Open
henryiii wants to merge 1 commit into
pybind:masterfrom
henryiii:fix/lto-macos-gcc
Open

fix(cmake): don't pass -fno-fat-lto-objects on Apple GCC#6114
henryiii wants to merge 1 commit into
pybind:masterfrom
henryiii:fix/lto-macos-gcc

Conversation

@henryiii

@henryiii henryiii commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

See #6112.

🤖 AI text below 🤖

Description

GCC on macOS has no linker plugin. -fno-fat-lto-objects needs one, so cc1plus fails with "-fno-fat-lto-objects are 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=auto works.

This change skips the flag when APPLE is set.

Verified with Homebrew g++-16 on macOS: before, HAS_FLTO_AUTO and HAS_FLTO both fail and pybind11::lto is disabled; after, HAS_FLTO_AUTO succeeds and pybind11::lto is enabled. The Apple Clang path is unchanged.

Fixes #6060

Suggested changelog entry:

  • Do not pass -fno-fat-lto-objects to GCC on macOS, which made all LTO probes fail and silently disabled LTO.

https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3

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
henryiii marked this pull request as ready for review July 26, 2026 03:03
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.

[BUG]: Invalid flag unnecessarily forces FLTO test to fail with gcc on macOS

1 participant