cmake
config_error
ai_generated
partial
CMake Error: check_ipo_supported() failed - LTO not supported by compiler / toolchain
ID: cmake/check-ipos-supported-false
80%Fix Rate
87%Confidence
1Evidence
2024-05-08First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| cmake 3.21.0 | active | — | — | — |
| cmake 3.22.0 | active | — | — | — |
| cmake 3.23.0 | active | — | — | — |
Root Cause
The compiler or linker does not support Link-Time Optimization (LTO) for the current build configuration, or the check_ipo_supported() call detected incompatibility.
generic中文
编译器或链接器不支持当前构建配置的链接时优化 (LTO),或者 check_ipo_supported() 调用检测到不兼容。
Official Documentation
https://cmake.org/cmake/help/latest/module/CheckIPOSupported.htmlWorkarounds
-
95% success Disable LTO for the affected target by setting the property explicitly: set_target_properties(mytarget PROPERTIES INTERPROCEDURAL_OPTIMIZATION FALSE) Or set globally: set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
Disable LTO for the affected target by setting the property explicitly: set_target_properties(mytarget PROPERTIES INTERPROCEDURAL_OPTIMIZATION FALSE) Or set globally: set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
-
80% success Use a compiler that supports LTO (e.g., GCC 4.9+ or Clang 3.9+). For GCC, ensure the 'gold' linker is available: sudo apt-get install binutils-gold Then reconfigure with: cmake -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE -DCMAKE_LINKER=/usr/bin/ld.gold /path/to/source
Use a compiler that supports LTO (e.g., GCC 4.9+ or Clang 3.9+). For GCC, ensure the 'gold' linker is available: sudo apt-get install binutils-gold Then reconfigure with: cmake -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE -DCMAKE_LINKER=/usr/bin/ld.gold /path/to/source
中文步骤
通过显式设置属性来禁用受影响目标的 LTO: set_target_properties(mytarget PROPERTIES INTERPROCEDURAL_OPTIMIZATION FALSE) 或全局设置: set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
使用支持 LTO 的编译器(例如 GCC 4.9+ 或 Clang 3.9+)。对于 GCC,确保 'gold' 链接器可用: sudo apt-get install binutils-gold 然后使用以下命令重新配置: cmake -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE -DCMAKE_LINKER=/usr/bin/ld.gold /path/to/source
Dead Ends
Common approaches that don't work:
-
Set CMAKE_INTERPROCEDURAL_OPTIMIZATION to TRUE manually
70% fail
Overrides the check but may cause linker errors if the toolchain genuinely lacks LTO support; build will fail later.
-
Upgrade CMake to the latest version
90% fail
LTO support depends on the compiler, not CMake version; upgrading CMake does not add LTO to an unsupported compiler.