summaryrefslogtreecommitdiffhomepage
path: root/.agents/rules/lld-no-gcc-lto.md
blob: 2f20ec0d28916916d318eebb32c6427332704d3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# RULE: vendored C/C++ libs must NOT use GCC LTO

zig's linker is **lld**, which cannot link **GCC `-flto`** objects (GIMPLE
bytecode in `.gnu.lto_*` sections). Symptom: every symbol from the lib is
"undefined" at the final link, even though `nm` shows it as defined `T` (nm uses
the LTO plugin; `readelf -s`/`objdump -t` reveal the object has almost no real
symbols).

When a CMake dependency enables interprocedural optimization, turn it OFF:
`-DINTERPROCEDURAL_OPTIMIZATION=OFF` (Jolt) or `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF`.
(LLVM/emcc LTO is fine for the web build — this is specifically a GCC-LTO + lld
incompatibility.)