Clang: CMake generates -flto instead of -flto=thin on Windows
On Windows, CMake incorrectly generates
-O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -O3 -fno-math-errno -flto -fvisibility-inlines-hidden -march=core-avx2
On Linux we get the expected result
-O3 -DNDEBUG -O3 -fno-math-errno -flto=thin -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -march=core-avx2
(dumped via CMAKE_EXPORT_COMPILE_COMMANDS
)
If I read the CMake source correctly, that is not supposed to happen?
cmake version 3.22.0-rc2
clang version 12.0.1
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
ninja 1.10.2
Compiler is recognised as
-- The C compiler identification is Clang 12.0.1 with GNU-like command-line
-- The CXX compiler identification is Clang 12.0.1 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
LTO is enabled via set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
Edited by Brad King