https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129244
Bug ID: 129244
Summary: -flto-incremental misses LTRANS cache across build
directories even with -fdebug-prefix-map
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: luolongjuna at gmail dot com
Target Milestone: ---
I found this issue when preparing my patch for LTO debuginfo. When building
identical sources from different directories (e.g. package builds in separate
buildroots A and B) mapped to the same path via -fdebug-prefix-map,
-flto-incremental misses the shared LTRANS cache and recompiles (1/1 instead of
0/1).
Steps to reproduce in an empty directory:
mkdir -p A/src B/src output/cache
echo 'int main(void) { return 0; }' > A/src/main.c
cp A/src/main.c B/src/main.c
# 1. Build A
gcc -v -g -flto -flto-incremental=output/cache "-fdebug-prefix-map=$PWD/A=/pkg"
"$PWD/A/src/main.c" -o output/main 2>&1 | grep "LTRANS:"
# -> LTRANS: recompiling 1/1
# 2. Build A again
gcc -v -g -flto -flto-incremental=output/cache "-fdebug-prefix-map=$PWD/A=/pkg"
"$PWD/A/src/main.c" -o output/main 2>&1 | grep "LTRANS:"
# -> LTRANS: recompiling 0/1
# 3. Build B
gcc -v -g -flto -flto-incremental=output/cache "-fdebug-prefix-map=$PWD/B=/pkg"
"$PWD/B/src/main.c" -o output/main 2>&1 | grep "LTRANS:"
# -> LTRANS: recompiling 1/1 (expected: 0/1)
Reproduced on x86_64 Linux with GCC 16.2.1 and GCC 17 trunk (0c5668ea94a6).