From 7b2a87c2ebede25e88a7d22a3c647be662c18391 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 10 Aug 2022 14:45:54 -0400 Subject: IPO: Do not use -flto=auto with GCC 10.x on Windows Revise the change from commit fe57410b33 (IPO: Use -flto=auto if compiler is GCC >= 10.1, 2022-06-22, v3.24.0-rc2~2^2) to require at least GCC 11 on Windows. Fixes: #23836 Issue: #23640 --- Modules/Compiler/GNU.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index db1eab5..48639cd 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -79,8 +79,15 @@ macro(__compiler_gnu lang) # * https://gcc.gnu.org/onlinedocs/gcc-9.5.0/gcc/Optimize-Options.html#Optimize-Options (no) # * https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Optimize-Options.html#Optimize-Options (yes) # Since GCC 12.1, the abundance of a parameter produces a warning if compiling multiple targets. - if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 10.1) + # FIXME: What version of GCC for Windows added support for -flto=auto? 10.3 does not have it. + if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 11.0) list(APPEND __lto_flags -flto=auto) + elseif(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 10.1) + if (CMAKE_HOST_WIN32) + list(APPEND __lto_flags -flto=1) + else() + list(APPEND __lto_flags -flto=auto) + endif() else() list(APPEND __lto_flags -flto) endif() -- cgit v0.12