From b4f46117e5eacb34e933edf4360af25343233fb9 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 25 Jul 2026 12:49:08 -0400 Subject: [PATCH] fix(cmake): don't pass -fno-fat-lto-objects on Apple GCC 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 #6060 Assisted-by: ClaudeCode:claude-opus-5 Claude-Session: https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3 --- tools/pybind11Common.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake index 1311d3faf9..f525270564 100644 --- a/tools/pybind11Common.cmake +++ b/tools/pybind11Common.cmake @@ -353,7 +353,11 @@ function(_pybind11_generate_lto target prefer_thin_lto) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE) # Clang Gold plugin does not support -Os; append -O3 to MinSizeRel builds to override it set(linker_append ";$<$:-O3>") - elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT MINGW) + elseif( + CMAKE_CXX_COMPILER_ID MATCHES "GNU" + AND NOT MINGW + AND NOT APPLE) + # GCC on macOS has no linker plugin, which -fno-fat-lto-objects requires set(cxx_append ";-fno-fat-lto-objects") endif()