Skip to content
Latchkey

gcc "lto1: fatal error" (LTO object/version mismatch) in CI

LTO embeds compiler-version-specific bytecode in each object. When objects are produced by different GCC versions or with mismatched flags, lto1 cannot merge them and aborts.

What this error means

A link with -flto fails with "lto1: fatal error", often citing an incompatible LTO bytecode version or a missing/garbled GIMPLE section.

gcc
lto1: fatal error: bytecode stream in file 'libfoo.a' generated with
LTO version 11.0 instead of the expected 12.1
compilation terminated.

Common causes

How to fix it

Rebuild everything with one toolchain

  1. Compile all objects and dependencies with the same GCC version and LTO flags.
  2. Or disable LTO on prebuilt libraries that you cannot rebuild.
gcc
make clean && CXX=g++-12 make CXXFLAGS="-flto"   # uniform compiler + flags

How to prevent it

  • Pin one compiler version and a consistent LTO flag set across the whole build, and avoid mixing LTO archives from another toolchain.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →